Search in sources :

Example 36 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet 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 37 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.

the class EntityValueIndexCursorTestBase method shouldPerformExactLookupInCompositeIndex.

@Test
void shouldPerformExactLookupInCompositeIndex() throws Exception {
    // given
    int firstName = token.propertyKey(FIRSTNAME_PROP_NAME);
    int surname = token.propertyKey(SURNAME_PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(COMPOSITE_INDEX_NAME));
    try (var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        MutableLongSet uniqueIds = new LongHashSet();
        // when
        entityParams.entityIndexSeek(tx, index, cursor, unconstrained(), PropertyIndexQuery.exact(firstName, "Joe"), PropertyIndexQuery.exact(surname, "Dalton"));
        // then
        assertThat(cursor.numberOfProperties()).isEqualTo(2);
        assertFoundEntitiesAndNoValue(cursor, 1, uniqueIds);
    }
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 38 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet 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 39 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.

the class EntityValueIndexCursorTestBase method shouldPerformStringPrefixSearch.

@Test
void shouldPerformStringPrefixSearch() throws Exception {
    // given
    boolean needsValues = indexParams.indexProvidesStringValues();
    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, unordered(needsValues), PropertyIndexQuery.stringPrefix(prop, stringValue("t")));
        // then
        assertThat(cursor.numberOfProperties()).isEqualTo(1);
        assertFoundEntitiesAndValue(cursor, uniqueIds, stringCapability, needsValues, strTwo1, strTwo2, strThree1, strThree2, strThree3);
    }
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) IndexValueCapability(org.neo4j.internal.schema.IndexValueCapability) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 40 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet 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)

Aggregations

MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)153 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)57 Test (org.junit.jupiter.api.Test)54 Test (org.junit.Test)49 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)17 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 ArrayList (java.util.ArrayList)13 IndexValueCapability (org.neo4j.internal.schema.IndexValueCapability)12 LongIterator (org.eclipse.collections.api.iterator.LongIterator)10 LongSet (org.eclipse.collections.api.set.primitive.LongSet)9 Value (org.neo4j.values.storable.Value)8 Map (java.util.Map)7 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)7 Transaction (org.neo4j.graphdb.Transaction)7 Write (org.neo4j.internal.kernel.api.Write)7 NavigableMap (java.util.NavigableMap)6 UnmodifiableMap (org.eclipse.collections.impl.UnmodifiableMap)6 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)6 IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)6