Search in sources :

Example 66 with MutableLongSet

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

the class IndexingStringQueryAcceptanceTest method shouldIncludeEntitiesCreatedInSameTxInIndexSeek.

@ParameterizedTest(name = "shouldIncludeEntitiesCreatedInSameTxInIndexSeek using {0} match with {1} index on {2}")
@MethodSource("data")
void shouldIncludeEntitiesCreatedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
    // GIVEN
    createIndex(entityControl, withIndex);
    createEntities(entityControl, db, tokenName, dataSet.nonMatching[0], dataSet.nonMatching[1]);
    MutableLongSet expected = createEntities(entityControl, db, tokenName, dataSet.matching[0], dataSet.matching[1]);
    // WHEN
    LongSet found;
    try (Transaction tx = db.beginTx()) {
        expected.add(entityControl.createEntity(tx, tokenName, map(KEY, dataSet.matching[2])));
        entityControl.createEntity(tx, tokenName, map(KEY, dataSet.nonMatching[2]));
        found = entityControl.findEntities(tx, tokenName, KEY, dataSet.template, dataSet.searchMode);
    }
    // THEN
    assertThat(found).isEqualTo(expected);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 67 with MutableLongSet

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

the class IndexingStringQueryAcceptanceTest method shouldConsiderEntitiesChangedInSameTxInIndexSeek.

@ParameterizedTest(name = "shouldConsiderEntitiesChangedInSameTxInIndexSeek using {0} match with {1} index on {2}")
@MethodSource("data")
void shouldConsiderEntitiesChangedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
    // GIVEN
    createIndex(entityControl, withIndex);
    createEntities(entityControl, db, tokenName, dataSet.nonMatching[0]);
    LongSet toChangeToMatch = createEntities(entityControl, db, tokenName, dataSet.nonMatching[1]);
    MutableLongSet toChangeToNotMatch = createEntities(entityControl, db, tokenName, dataSet.matching[0]);
    MutableLongSet expected = createEntities(entityControl, db, tokenName, dataSet.matching[1]);
    // WHEN
    LongSet found;
    try (Transaction tx = db.beginTx()) {
        toChangeToMatch.each(id -> {
            entityControl.setProperty(tx, id, KEY, dataSet.matching[2]);
            expected.add(id);
        });
        toChangeToNotMatch.each(id -> {
            entityControl.setProperty(tx, id, KEY, dataSet.nonMatching[2]);
            expected.remove(id);
        });
        found = entityControl.findEntities(tx, tokenName, KEY, dataSet.template, dataSet.searchMode);
    }
    // THEN
    assertThat(found).isEqualTo(expected);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 68 with MutableLongSet

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

the class IndexingCompositeQueryAcceptanceTest method shouldConsiderEntitiesChangedInSameTxInIndexSeek.

@ParameterizedTest(name = "shouldConsiderEntitiesChangedInSameTxInIndexSeek using {0} with {1} index for {2}")
@MethodSource("data")
public void shouldConsiderEntitiesChangedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
    createIndex(withIndex, dataSet.keys, entityControl);
    // GIVEN
    createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[0]);
    LongSet toChangeToMatch = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[1]);
    LongSet toChangeToNotMatch = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
    MutableLongSet expected = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
    // WHEN
    LongSet found;
    try (Transaction tx = db.beginTx()) {
        LongIterator toMatching = toChangeToMatch.longIterator();
        while (toMatching.hasNext()) {
            long id = toMatching.next();
            entityControl.setProperties(tx, id, dataSet.keys, dataSet.values);
            expected.add(id);
        }
        LongIterator toNotMatching = toChangeToNotMatch.longIterator();
        while (toNotMatching.hasNext()) {
            long id = toNotMatching.next();
            entityControl.setProperties(tx, id, dataSet.keys, dataSet.nonMatching[2]);
            expected.remove(id);
        }
        found = dataSet.indexSeek.findEntities(tx, dataSet.keys, dataSet.values, entityControl);
    }
    // THEN
    assertThat(found).isEqualTo(expected);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) LongIterator(org.eclipse.collections.api.iterator.LongIterator) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 69 with MutableLongSet

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

the class IndexingCompositeQueryAcceptanceTest method shouldIncludeEntitiesCreatedInSameTxInIndexSeek.

@ParameterizedTest(name = "shouldIncludeEntitiesCreatedInSameTxInIndexSeek using {0} with {1} index for {2}")
@MethodSource("data")
public void shouldIncludeEntitiesCreatedInSameTxInIndexSeek(DataSet dataSet, IndexingMode withIndex, EntityControl entityControl) {
    createIndex(withIndex, dataSet.keys, entityControl);
    // GIVEN
    createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.nonMatching[0], dataSet.nonMatching[1]);
    MutableLongSet expected = createEntities(db, entityControl, TOKEN_NAME, dataSet.keys, dataSet.values);
    // WHEN
    LongSet found;
    try (Transaction tx = db.beginTx()) {
        expected.add(entityControl.createEntity(tx, TOKEN_NAME, propertyMap(dataSet.keys, dataSet.values)));
        entityControl.createEntity(tx, TOKEN_NAME, propertyMap(dataSet.keys, dataSet.nonMatching[2]));
        found = dataSet.indexSeek.findEntities(tx, dataSet.keys, dataSet.values, entityControl);
    }
    // THEN
    assertThat(found).isEqualTo(expected);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongSet(org.eclipse.collections.api.set.primitive.LongSet) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 70 with MutableLongSet

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

the class IndexingCompositeQueryAcceptanceTest method mapToIds.

private static LongSet mapToIds(ResourceIterator<? extends Entity> nodes) {
    MutableLongSet found = new LongHashSet();
    nodes.stream().mapToLong(Entity::getId).forEach(found::add);
    return found;
}
Also used : LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet)

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