Search in sources :

Example 16 with IndexReadSession

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

the class EntityValueIndexCursorTestBase method shouldNotFindDeletedEntityInIndexSeek.

@Test
void shouldNotFindDeletedEntityInIndexSeek() throws Exception {
    // Given
    boolean needsValues = false;
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    try (KernelTransaction tx = beginTransaction();
        var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        // when
        entityParams.entityDelete(tx, strOne);
        entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.exact(prop, "one"));
        // then
        assertFalse(cursor.next());
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 17 with IndexReadSession

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

the class EntityValueIndexCursorTestBase method shouldFindUpdatedEntityInPrefixSearch.

@Test
void shouldFindUpdatedEntityInPrefixSearch() throws Exception {
    // Given
    boolean needsValues = indexParams.indexProvidesStringValues();
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    try (KernelTransaction tx = beginTransaction();
        var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        // when
        entityParams.entitySetProperty(tx, strOne, prop, "ett");
        entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.stringPrefix(prop, stringValue("et")));
        // then
        assertTrue(cursor.next());
        assertEquals(strOne, entityParams.entityReference(cursor));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 18 with IndexReadSession

use of org.neo4j.internal.kernel.api.IndexReadSession 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 19 with IndexReadSession

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

the class EntityValueIndexCursorTestBase method shouldNotFindDeletedEntityInPrefixSearch.

@Test
void shouldNotFindDeletedEntityInPrefixSearch() throws Exception {
    // Given
    boolean needsValues = indexParams.indexProvidesStringValues();
    int prop = token.propertyKey(PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(PROP_INDEX_NAME));
    try (KernelTransaction tx = beginTransaction();
        var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        // when
        entityParams.entityDelete(tx, strOne);
        entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.stringPrefix(prop, stringValue("on")));
        // then
        assertFalse(cursor.next());
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Example 20 with IndexReadSession

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

the class EntityValueIndexCursorTestBase method shouldNotFindUpdatedEntityInCompositeIndex.

@Test
void shouldNotFindUpdatedEntityInCompositeIndex() throws Exception {
    // Given
    boolean needsValues = false;
    int firstName = token.propertyKey(FIRSTNAME_PROP_NAME);
    int surname = token.propertyKey(SURNAME_PROP_NAME);
    IndexReadSession index = read.indexReadSession(schemaRead.indexGetForName(COMPOSITE_INDEX_NAME));
    try (KernelTransaction tx = beginTransaction();
        var cursor = entityParams.allocateEntityValueIndexCursor(tx, cursors)) {
        // when
        entityParams.entitySetProperty(tx, jackDalton, firstName, "Jesse");
        entityParams.entitySetProperty(tx, jackDalton, surname, "James");
        entityParams.entityIndexSeek(tx, index, cursor, unordered(needsValues), PropertyIndexQuery.exact(firstName, "Jack"), PropertyIndexQuery.exact(surname, "Dalton"));
        // then
        assertFalse(cursor.next());
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession) Test(org.junit.jupiter.api.Test)

Aggregations

IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)93 Test (org.junit.jupiter.api.Test)62 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)47 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)22 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)20 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)17 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)15 ArrayList (java.util.ArrayList)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 EnumSource (org.junit.jupiter.params.provider.EnumSource)12 RelationshipValueIndexCursor (org.neo4j.internal.kernel.api.RelationshipValueIndexCursor)12 IndexValueCapability (org.neo4j.internal.schema.IndexValueCapability)12 Pair (org.neo4j.internal.helpers.collection.Pair)11 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)10 Transaction (org.neo4j.graphdb.Transaction)9 IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)9 IndexOrderCapability (org.neo4j.internal.schema.IndexOrderCapability)7 Read (org.neo4j.internal.kernel.api.Read)6 TokenRead (org.neo4j.internal.kernel.api.TokenRead)6 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)5