Search in sources :

Example 1 with IndexQueryConstraints

use of org.neo4j.internal.kernel.api.IndexQueryConstraints in project neo4j by neo4j.

the class EntityValueIndexCursorTestBase method shouldPerformSpatialRangeSearch.

@Test
void shouldPerformSpatialRangeSearch() throws KernelException {
    // given
    boolean needsValues = indexParams.indexProvidesSpatialValues();
    IndexQueryConstraints constraints = unordered(needsValues);
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    IndexValueCapability spatialCapability = index.reference().getCapability().valueCapability(ValueCategory.GEOMETRY);
    try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        MutableLongSet uniqueIds = new LongHashSet();
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, Cartesian));
        // then
        assertFoundEntitiesAndValue(cursor, 5, uniqueIds, spatialCapability, needsValues);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, Cartesian_3D));
        // then
        assertFoundEntitiesAndValue(cursor, 1, uniqueIds, spatialCapability, needsValues);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, WGS84));
        // then
        assertFoundEntitiesAndValue(cursor, 1, uniqueIds, spatialCapability, needsValues);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, WGS84_3D));
        // then
        assertFoundEntitiesAndValue(cursor, 1, uniqueIds, spatialCapability, needsValues);
    }
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IndexQueryConstraints(org.neo4j.internal.kernel.api.IndexQueryConstraints) IndexValueCapability(org.neo4j.internal.schema.IndexValueCapability) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 2 with IndexQueryConstraints

use of org.neo4j.internal.kernel.api.IndexQueryConstraints in project neo4j by neo4j.

the class EntityValueIndexCursorTestBase method shouldPerformStringRangeSearch.

@Test
void shouldPerformStringRangeSearch() throws Exception {
    // given
    boolean needsValues = indexParams.indexProvidesStringValues();
    IndexQueryConstraints constraints = unordered(needsValues);
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    IndexValueCapability stringCapability = index.reference().getCapability().valueCapability(ValueCategory.TEXT);
    try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        MutableLongSet uniqueIds = new LongHashSet();
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, "one", true, "three", true));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strOne, strThree1, strThree2, strThree3);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, "one", true, "three", false));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strOne);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, "one", false, "three", true));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strThree1, strThree2, strThree3);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, "one", false, "two", false));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strThree1, strThree2, strThree3);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, "one", true, "two", true));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strOne, strThree1, strThree2, strThree3, strTwo1, strTwo2);
    }
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IndexQueryConstraints(org.neo4j.internal.kernel.api.IndexQueryConstraints) IndexValueCapability(org.neo4j.internal.schema.IndexValueCapability) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 3 with IndexQueryConstraints

use of org.neo4j.internal.kernel.api.IndexQueryConstraints in project neo4j by neo4j.

the class EntityValueIndexCursorTestBase method shouldPerformTemporalRangeSearch.

@Test
void shouldPerformTemporalRangeSearch() throws KernelException {
    // given
    boolean needsValues = indexParams.indexProvidesTemporalValues();
    IndexQueryConstraints constraints = unordered(needsValues);
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    IndexValueCapability temporalCapability = index.reference().getCapability().valueCapability(ValueCategory.TEMPORAL);
    try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        MutableLongSet uniqueIds = new LongHashSet();
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), true));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, temporalCapability, needsValues, date86, date891, date892);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), true, DateValue.date(1989, 3, 24), false));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, temporalCapability, needsValues, date86);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), false, DateValue.date(1989, 3, 24), true));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, temporalCapability, needsValues, date891, date892);
        // when
        entityParams.entityIndexSeek(tx, index, cursor, constraints, PropertyIndexQuery.range(prop, DateValue.date(1986, 11, 18), false, DateValue.date(1989, 3, 24), false));
        // then
        assertFoundEntitiesAndValue(cursor, uniqueIds, temporalCapability, needsValues);
    }
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IndexQueryConstraints(org.neo4j.internal.kernel.api.IndexQueryConstraints) IndexValueCapability(org.neo4j.internal.schema.IndexValueCapability) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 4 with IndexQueryConstraints

use of org.neo4j.internal.kernel.api.IndexQueryConstraints in project neo4j by neo4j.

the class FulltextIndexProgressorTest method mustReturnNoElementsWhenSkipIsGreaterThanIterator.

@Test
void mustReturnNoElementsWhenSkipIsGreaterThanIterator() {
    StubValuesIterator iterator = new StubValuesIterator();
    iterator.add(1, 1.0f);
    iterator.add(2, 2.0f);
    iterator.add(3, 3.0f);
    iterator.add(4, 4.0f);
    IndexQueryConstraints constraints = unconstrained().skip(4).limit(1);
    StubEntityValueClient client = new StubEntityValueClient();
    FulltextIndexProgressor progressor = new FulltextIndexProgressor(iterator, client, constraints);
    boolean keepGoing;
    do {
        keepGoing = progressor.next();
    } while (keepGoing);
    assertThat(client.entityIds).isEmpty();
    assertThat(client.scores).isEmpty();
}
Also used : IndexQueryConstraints(org.neo4j.internal.kernel.api.IndexQueryConstraints) Test(org.junit.jupiter.api.Test)

Example 5 with IndexQueryConstraints

use of org.neo4j.internal.kernel.api.IndexQueryConstraints in project neo4j by neo4j.

the class FulltextIndexProgressorTest method mustLimitToOneEntryPerConstraints.

@Test
void mustLimitToOneEntryPerConstraints() {
    StubValuesIterator iterator = new StubValuesIterator();
    iterator.add(1, 1.0f);
    iterator.add(2, 2.0f);
    iterator.add(3, 3.0f);
    iterator.add(4, 4.0f);
    IndexQueryConstraints constraints = unconstrained().skip(1).limit(1);
    StubEntityValueClient client = new StubEntityValueClient();
    FulltextIndexProgressor progressor = new FulltextIndexProgressor(iterator, client, constraints);
    boolean keepGoing;
    do {
        keepGoing = progressor.next();
    } while (keepGoing);
    assertThat(client.entityIds).containsExactly(2L);
    assertThat(client.scores).containsExactly(2.0f);
}
Also used : IndexQueryConstraints(org.neo4j.internal.kernel.api.IndexQueryConstraints) Test(org.junit.jupiter.api.Test)

Aggregations

IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)15 Test (org.junit.jupiter.api.Test)11 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)9 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)6 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)6 IndexValueCapability (org.neo4j.internal.schema.IndexValueCapability)6 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)3 Consumer (java.util.function.Consumer)2 EntityType (org.neo4j.common.EntityType)2 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)2 SystemProcedure (org.neo4j.kernel.api.procedure.SystemProcedure)2 Description (org.neo4j.procedure.Description)2 Procedure (org.neo4j.procedure.Procedure)2 ArrayList (java.util.ArrayList)1 Read (org.neo4j.internal.kernel.api.Read)1 RelationshipValueIndexCursor (org.neo4j.internal.kernel.api.RelationshipValueIndexCursor)1 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)1 TokenRead (org.neo4j.internal.kernel.api.TokenRead)1 IndexProgressor (org.neo4j.kernel.api.index.IndexProgressor)1 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)1