Search in sources :

Example 36 with Pair

use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringRangeSearchWithChangedEntityInTxState.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringRangeSearchWithChangedEntityInTxState(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);
        TextValue newProperty = stringValue("kiwi");
        setProperty(tx, 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 37 with Pair

use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformScan.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformScan(boolean needsValues) throws Exception {
    // given
    Set<Pair<Long, Value>> expected = new HashSet<>();
    long entityToDelete;
    long entityToChange;
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "suff1"));
        expected.add(entityWithProp(tx, "supp"));
        entityToDelete = entityWithPropId(tx, "supp");
        entityToChange = entityWithPropId(tx, "supper");
        tx.commit();
    }
    createIndex();
    // when
    try (KernelTransaction tx = beginTransaction()) {
        expected.add(entityWithProp(tx, "suff2"));
        deleteEntity(tx, entityToDelete);
        removeProperty(tx, entityToChange);
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        assertEntityAndValueForScan(expected, tx, index, needsValues, "noff");
    }
}
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 38 with Pair

use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringRangeSearchWithDeletedEntityInTxState.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringRangeSearchWithDeletedEntityInTxState(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()) {
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        expected.add(entityWithProp(tx, "cherry"));
        entityWithProp(tx, "dragonfruit");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
        deleteEntity(tx, entityToChange);
        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 39 with Pair

use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.

the class IndexTransactionStateTestBase method shouldPerformStringRangeSearch.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringRangeSearch(boolean needsValues) 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()) {
        int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
        expected.add(entityWithProp(tx, "cherry"));
        entityWithProp(tx, "dragonfruit");
        IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_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)

Aggregations

Pair (org.neo4j.internal.helpers.collection.Pair)39 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)22 ArrayList (java.util.ArrayList)15 HashSet (java.util.HashSet)12 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)12 EnumSource (org.junit.jupiter.params.provider.EnumSource)11 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)11 ValueSource (org.junit.jupiter.params.provider.ValueSource)9 TextValue (org.neo4j.values.storable.TextValue)9 PointValue (org.neo4j.values.storable.PointValue)8 Value (org.neo4j.values.storable.Value)8 Values.stringValue (org.neo4j.values.storable.Values.stringValue)8 Values.pointValue (org.neo4j.values.storable.Values.pointValue)7 Test (org.junit.jupiter.api.Test)6 HashMap (java.util.HashMap)5 Label (org.neo4j.graphdb.Label)5 Path (java.nio.file.Path)4 Transaction (org.neo4j.graphdb.Transaction)4 Map (java.util.Map)3