Search in sources :

Example 6 with AddedAndRemoved

use of org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved in project neo4j by neo4j.

the class DefaultEntityValueIndexCursor method scanQuery.

private void scanQuery(IndexDescriptor descriptor) {
    TransactionState txState = read.txState();
    if (needsValues) {
        AddedWithValuesAndRemoved changes = indexUpdatesWithValuesForScan(txState, descriptor, indexOrder);
        addedWithValues = changes.getAdded().iterator();
        removed = removed(txState, changes.getRemoved());
    } else {
        AddedAndRemoved changes = indexUpdatesForScan(txState, descriptor, indexOrder);
        added = changes.getAdded().longIterator();
        removed = removed(txState, changes.getRemoved());
    }
}
Also used : TransactionState(org.neo4j.kernel.api.txstate.TransactionState) AddedWithValuesAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedWithValuesAndRemoved) AddedAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved)

Example 7 with AddedAndRemoved

use of org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved in project neo4j by neo4j.

the class TxStateIndexChangesTest method shouldComputeIndexUpdatesForScanWhenThereAreNewEntities.

@Test
void shouldComputeIndexUpdatesForScanWhenThereAreNewEntities() {
    // GIVEN
    final ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build();
    // WHEN
    AddedAndRemoved changes = indexUpdatesForScan(state, index, IndexOrder.NONE);
    AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, index, IndexOrder.NONE);
    // THEN
    assertContains(changes.getAdded(), 42L, 43L);
    assertContains(changesWithValues.getAdded(), entityWithPropertyValues(42L, "foo"), entityWithPropertyValues(43L, "bar"));
}
Also used : AddedWithValuesAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedWithValuesAndRemoved) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) AddedAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 8 with AddedAndRemoved

use of org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved in project neo4j by neo4j.

the class TxStateIndexChangesTest method shouldComputeIndexUpdatesForSeekWhenThereAreNewEntities.

@Test
void shouldComputeIndexUpdatesForSeekWhenThereAreNewEntities() {
    // GIVEN
    final ReadableTransactionState state = new TxStateBuilder().withAdded(42L, "foo").withAdded(43L, "bar").build();
    // WHEN
    AddedAndRemoved changes = indexUpdatesForSeek(state, index, ValueTuple.of("bar"));
    // THEN
    assertContains(changes.getAdded(), 43L);
}
Also used : ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) AddedAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 9 with AddedAndRemoved

use of org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved in project neo4j by neo4j.

the class TxStateIndexChangesTest method rangeTest.

private DynamicTest rangeTest(ReadableTransactionState state, IndexOrder indexOrder, Value lo, boolean includeLo, Value hi, boolean includeHi, EntityWithPropertyValues... expected) {
    return DynamicTest.dynamicTest(String.format("range seek: lo=%s (incl: %s), hi=%s (incl: %s)", lo, includeLo, hi, includeHi), () -> {
        // Internal production code relies on null for unbounded, and cannot cope with NO_VALUE in this case
        assert lo != NO_VALUE;
        assert hi != NO_VALUE;
        final AddedAndRemoved changes = indexUpdatesForRangeSeek(state, index, new Value[0], PropertyIndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder);
        final AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForRangeSeek(state, index, new Value[0], PropertyIndexQuery.range(-1, lo, includeLo, hi, includeHi), indexOrder);
        assertContains(indexOrder, changes, changesWithValues, expected);
    });
}
Also used : AddedWithValuesAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedWithValuesAndRemoved) AddedAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved)

Example 10 with AddedAndRemoved

use of org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved in project neo4j by neo4j.

the class TxStateIndexChangesTest method shouldComputeIndexUpdatesForScanOnAnEmptyTxState.

@Test
void shouldComputeIndexUpdatesForScanOnAnEmptyTxState() {
    final ReadableTransactionState state = Mockito.mock(ReadableTransactionState.class);
    // WHEN
    AddedAndRemoved changes = indexUpdatesForScan(state, index, IndexOrder.NONE);
    AddedWithValuesAndRemoved changesWithValues = indexUpdatesWithValuesForScan(state, index, IndexOrder.NONE);
    // THEN
    assertTrue(changes.isEmpty());
    assertTrue(changesWithValues.isEmpty());
}
Also used : AddedWithValuesAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedWithValuesAndRemoved) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) AddedAndRemoved(org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

AddedAndRemoved (org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedAndRemoved)10 AddedWithValuesAndRemoved (org.neo4j.kernel.impl.newapi.TxStateIndexChanges.AddedWithValuesAndRemoved)9 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)5 ReadableTransactionState (org.neo4j.storageengine.api.txstate.ReadableTransactionState)4 DynamicTest (org.junit.jupiter.api.DynamicTest)3 Test (org.junit.jupiter.api.Test)3