use of org.neo4j.kernel.impl.transaction.state.storeview.GenerateIndexUpdatesStep.GeneratedIndexUpdates in project neo4j by neo4j.
the class GenerateIndexUpdatesStepTest method shouldSendBatchesOverMaxByteSizeThreshold.
@ValueSource(booleans = { true, false })
@ParameterizedTest
void shouldSendBatchesOverMaxByteSizeThreshold(boolean alsoWrite) throws Exception {
// given
StubStorageCursors data = someUniformData(10);
TestPropertyScanConsumer scanConsumer = new TestPropertyScanConsumer();
GenerateIndexUpdatesStep<StorageNodeCursor> step = new GenerateIndexUpdatesStep<>(new SimpleStageControl(), DEFAULT, data, alwaysTrue(), new NodeCursorBehaviour(data), new int[] { LABEL }, scanConsumer, null, NO_LOCKING, 1, 100, alsoWrite, PageCacheTracer.NULL, INSTANCE);
// when
CapturingBatchSender<GeneratedIndexUpdates> sender = new CapturingBatchSender<>();
step.process(allNodeIds(data), sender, NULL);
// then
if (alsoWrite) {
assertThat(scanConsumer.batches.size()).isGreaterThan(1);
assertThat(sender.batches).isEmpty();
} else {
assertThat(scanConsumer.batches).isEmpty();
assertThat(sender.batches.size()).isGreaterThan(1);
}
}
use of org.neo4j.kernel.impl.transaction.state.storeview.GenerateIndexUpdatesStep.GeneratedIndexUpdates in project neo4j by neo4j.
the class GenerateIndexUpdatesStepTest method shouldGenerateEntityPropertyUpdatesForRelevantPropertyTokens.
@ValueSource(booleans = { true, false })
@ParameterizedTest
void shouldGenerateEntityPropertyUpdatesForRelevantPropertyTokens(boolean alsoWrite) throws Exception {
// given
StubStorageCursors data = new StubStorageCursors();
int numNodes = 10;
MutableLongSet relevantNodeIds = LongSets.mutable.empty();
for (int i = 0; i < numNodes; i++) {
StubStorageCursors.NodeData node = data.withNode(i).labels(LABEL);
Map<String, Value> properties = new HashMap<>();
properties.put(KEY, stringValue("name_" + i));
if (i % 2 == 0) {
properties.put(OTHER_KEY, intValue(i));
relevantNodeIds.add(i);
}
node.properties(properties);
}
int otherKeyId = data.propertyKeyTokenHolder().getIdByName(OTHER_KEY);
TestPropertyScanConsumer scanConsumer = new TestPropertyScanConsumer();
GenerateIndexUpdatesStep<StorageNodeCursor> step = new GenerateIndexUpdatesStep(new SimpleStageControl(), DEFAULT, data, pid -> pid == otherKeyId, new NodeCursorBehaviour(data), new int[] { LABEL }, scanConsumer, null, NO_LOCKING, 1, mebiBytes(1), alsoWrite, PageCacheTracer.NULL, INSTANCE);
// when
CapturingBatchSender<GeneratedIndexUpdates> sender = new CapturingBatchSender<>();
step.process(allNodeIds(data), sender, NULL);
// then
if (alsoWrite) {
for (TestPropertyScanConsumer.Record update : scanConsumer.batches.get(0)) {
assertThat(relevantNodeIds.remove(update.getEntityId())).isTrue();
}
} else {
GeneratedIndexUpdates updates = sender.batches.get(0);
updates.completeBatch();
for (TestPropertyScanConsumer.Record update : scanConsumer.batches.get(0)) {
assertThat(relevantNodeIds.remove(update.getEntityId())).isTrue();
}
}
assertThat(relevantNodeIds.isEmpty()).isTrue();
}
Aggregations