use of org.neo4j.kernel.api.index.BridgingIndexProgressor in project neo4j by neo4j.
the class FusionIndexReader method query.
@Override
public void query(QueryContext context, IndexProgressor.EntityValueClient cursor, IndexQueryConstraints constraints, PropertyIndexQuery... predicates) throws IndexNotApplicableKernelException {
IndexSlot slot = slotSelector.selectSlot(predicates, PropertyIndexQuery::valueCategory);
if (slot != null) {
instanceSelector.select(slot).query(context, cursor, constraints, predicates);
} else {
if (constraints.isOrdered()) {
throw new UnsupportedOperationException(format("Tried to query index with unsupported order %s. Supported orders for query %s are %s.", constraints.order(), Arrays.toString(predicates), IndexOrder.NONE));
}
BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(cursor, descriptor.schema().getPropertyIds());
cursor.initialize(descriptor, multiProgressor, predicates, constraints, false);
try {
instanceSelector.forAll(reader -> {
try {
reader.query(context, multiProgressor, constraints, predicates);
} catch (IndexNotApplicableKernelException e) {
throw new InnerException(e);
}
});
} catch (InnerException e) {
throw e.getCause();
}
}
}
use of org.neo4j.kernel.api.index.BridgingIndexProgressor in project neo4j by neo4j.
the class GenericNativeIndexReader method query.
@Override
public void query(QueryContext context, IndexProgressor.EntityValueClient client, IndexQueryConstraints constraints, PropertyIndexQuery... query) {
PropertyIndexQuery.GeometryRangePredicate geometryRangePredicate = getGeometryRangePredicateIfAny(query);
if (geometryRangePredicate != null) {
validateQuery(constraints, query);
try {
// If there's a GeometryRangeQuery among the predicates then this query changes from a straight-forward: build from/to and seek...
// into a query that is split into multiple sub-queries. Predicates both before and after will have to be accompanied each sub-query.
BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, descriptor.schema().getPropertyIds());
client.initialize(descriptor, multiProgressor, query, constraints, false);
double[] from = geometryRangePredicate.from() == null ? null : geometryRangePredicate.from().coordinate();
double[] to = geometryRangePredicate.to() == null ? null : geometryRangePredicate.to().coordinate();
CoordinateReferenceSystem crs = geometryRangePredicate.crs();
SpaceFillingCurve curve = spaceFillingCurveSettings.forCrs(crs);
List<SpaceFillingCurve.LongRange> ranges = curve.getTilesIntersectingEnvelope(from, to, configuration);
for (SpaceFillingCurve.LongRange range : ranges) {
// Here's a sub-query that we'll have to do for this geometry range. Build this query from all predicates
// and when getting to the geometry range predicate that sparked these sub-query chenanigans, swap in this sub-query in its place.
GenericKey treeKeyFrom = layout.newKey();
GenericKey treeKeyTo = layout.newKey();
initializeFromToKeys(treeKeyFrom, treeKeyTo);
boolean needFiltering = initializeRangeForGeometrySubQuery(treeKeyFrom, treeKeyTo, query, crs, range);
startSeekForInitializedRange(multiProgressor, treeKeyFrom, treeKeyTo, query, constraints, needFiltering, context.cursorContext());
}
} catch (IllegalArgumentException e) {
// Invalid query ranges will cause this state (eg. min>max)
client.initialize(descriptor, IndexProgressor.EMPTY, query, constraints, false);
}
} else {
super.query(context, client, constraints, query);
}
}
use of org.neo4j.kernel.api.index.BridgingIndexProgressor in project neo4j by neo4j.
the class PartitionedValueIndexReader method query.
@Override
public void query(QueryContext context, IndexProgressor.EntityValueClient client, IndexQueryConstraints constraints, PropertyIndexQuery... query) throws IndexNotApplicableKernelException {
try {
BridgingIndexProgressor bridgingIndexProgressor = new BridgingIndexProgressor(client, descriptor.schema().getPropertyIds());
indexReaders.parallelStream().forEach(reader -> {
try {
reader.query(context, bridgingIndexProgressor, constraints, query);
} catch (IndexNotApplicableKernelException e) {
throw new InnerException(e);
}
});
client.initialize(descriptor, bridgingIndexProgressor, query, constraints, false);
} catch (InnerException e) {
throw e.getCause();
}
}
Aggregations