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());
}
}
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"));
}
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);
}
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);
});
}
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());
}
Aggregations