Search in sources :

Example 76 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringRangeSearchWithRemovedRemovedPropertyInTxState.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringRangeSearchWithRemovedRemovedPropertyInTxState(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    long entityToChange;
    try (KernelTransaction tx = beginTransaction()) {
        entityToChange = entityWithPropId(tx, "banana");
        entityWithPropId(tx, "apple");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "cherry"));
        entityWithProp(tx, "dragonfruit");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        removeProperty(tx, entityToChange);
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "berry", PropertyIndexQuery.range(prop, "b", true, "d", false));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 77 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringRangeSearchWithAddedEntityInTxState.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringRangeSearchWithAddedEntityInTxState(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    long entityToChange;
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "banana"));
        entityToChange = entityWithPropId(tx, "apple");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "cherry"));
        entityWithProp(tx, "dragonfruit");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        TextValue newProperty = stringValue("blueberry");
        setProperty(tx, entityToChange, newProperty);
        expected.add(Pair.of(entityToChange, newProperty));
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "berry", PropertyIndexQuery.range(prop, "b", true, "d", false));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TextValue(org.neo4j.values.storable.TextValue) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 78 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformEqualitySeek.

@Test
void shouldPerformEqualitySeek() throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "banana"));
        entityWithProp(tx, "apple");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "banana"));
        entityWithProp(tx, "dragonfruit");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        // Equality seek does never provide values
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        assertEntityAndValueForSeek(expected, tx, index, false, "banana", PropertyIndexQuery.exact(prop, "banana"));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringSuffixSearch.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringSuffixSearch(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "1suff"));
        entityWithProp(tx, "pluff");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        expected.add(entityWithProp(tx, "2suff"));
        entityWithPropId(tx, "skruff");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "pasuff", PropertyIndexQuery.stringSuffix(prop, stringValue("suff")));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 80 with IndexDescriptor

use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringContainsSearch.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringContainsSearch(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "gnomebat"));
        entityWithPropId(tx, "fishwombat");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "homeopatic"));
        entityWithPropId(tx, "telephonecompany");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        assertEntityAndValueForSeek(expected, tx, index, needsValues, "immense", PropertyIndexQuery.stringContains(prop, stringValue("me")));
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Pair(org.neo4j.internal.helpers.collection.Pair) HashSet(java.util.HashSet) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)404 Test (org.junit.jupiter.api.Test)231 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)81 Value (org.neo4j.values.storable.Value)43 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)33 ArrayList (java.util.ArrayList)31 Transaction (org.neo4j.graphdb.Transaction)31 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)31 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)30 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)30 TokenRead (org.neo4j.internal.kernel.api.TokenRead)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)26 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)25 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)25 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)23 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)23 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)23 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)22 KernelException (org.neo4j.exceptions.KernelException)20