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);
}
}
Aggregations