Search in sources :

Example 1 with BridgingIndexProgressor

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();
        }
    }
}
Also used : IndexNotApplicableKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException) PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) BridgingIndexProgressor(org.neo4j.kernel.api.index.BridgingIndexProgressor)

Example 2 with BridgingIndexProgressor

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);
    }
}
Also used : PropertyIndexQuery(org.neo4j.internal.kernel.api.PropertyIndexQuery) SpaceFillingCurve(org.neo4j.gis.spatial.index.curves.SpaceFillingCurve) CoordinateReferenceSystem(org.neo4j.values.storable.CoordinateReferenceSystem) BridgingIndexProgressor(org.neo4j.kernel.api.index.BridgingIndexProgressor)

Example 3 with BridgingIndexProgressor

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();
    }
}
Also used : IndexNotApplicableKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException) BridgingIndexProgressor(org.neo4j.kernel.api.index.BridgingIndexProgressor)

Aggregations

BridgingIndexProgressor (org.neo4j.kernel.api.index.BridgingIndexProgressor)3 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)2 IndexNotApplicableKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException)2 SpaceFillingCurve (org.neo4j.gis.spatial.index.curves.SpaceFillingCurve)1 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)1