Search in sources :

Example 1 with IndexMaintainer

use of com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer in project fdb-record-layer by FoundationDB.

the class GeophileSpatialJoin method getSpatialIndex.

@Nonnull
public SpatialIndex<GeophileRecordImpl> getSpatialIndex(@Nonnull String indexName, @Nonnull ScanComparisons prefixComparisons, @Nonnull BiFunction<IndexEntry, Tuple, GeophileRecordImpl> recordFunction) {
    if (!prefixComparisons.isEquality()) {
        throw new RecordCoreArgumentException("prefix comparisons must only have equality");
    }
    // TODO: Add a FDBRecordStoreBase.getIndexMaintainer String overload to do this.
    final IndexMaintainer indexMaintainer = store.getIndexMaintainer(store.getRecordMetaData().getIndex(indexName));
    final TupleRange prefixRange = prefixComparisons.toTupleRange(store, context);
    // Since this is an equality, will match getHigh(), too.
    final Tuple prefix = prefixRange.getLow();
    final Index<GeophileRecordImpl> index = new GeophileIndexImpl(indexMaintainer, prefix, recordFunction);
    final Space space = ((GeophileIndexMaintainer) indexMaintainer).getSpace();
    try {
        return SpatialIndex.newSpatialIndex(space, index);
    } catch (IOException ex) {
        throw new RecordCoreException("Unexpected IO exception", ex);
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new RecordCoreException(ex);
    }
}
Also used : Space(com.geophile.z.Space) RecordCoreException(com.apple.foundationdb.record.RecordCoreException) IndexMaintainer(com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer) TupleRange(com.apple.foundationdb.record.TupleRange) IOException(java.io.IOException) RecordCoreArgumentException(com.apple.foundationdb.record.RecordCoreArgumentException) Tuple(com.apple.foundationdb.tuple.Tuple) Nonnull(javax.annotation.Nonnull)

Aggregations

RecordCoreArgumentException (com.apple.foundationdb.record.RecordCoreArgumentException)1 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)1 TupleRange (com.apple.foundationdb.record.TupleRange)1 IndexMaintainer (com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer)1 Tuple (com.apple.foundationdb.tuple.Tuple)1 Space (com.geophile.z.Space)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1