use of org.neo4j.kernel.api.labelscan.NodeLabelUpdate in project neo4j by neo4j.
the class PartitionedLuceneLabelScanWriter method updateFields.
private void updateFields(Iterable<NodeLabelUpdate> updates, Map<Long, /*label*/
Bitmap> fields) {
for (NodeLabelUpdate update : updates) {
clearLabels(fields, update);
setLabels(fields, update);
}
}
use of org.neo4j.kernel.api.labelscan.NodeLabelUpdate in project neo4j by neo4j.
the class LabelScanStoreTest method shouldUpdateAFullRange.
@Test
public void shouldUpdateAFullRange() throws Exception {
// given
long label0Id = 0;
List<NodeLabelUpdate> label0Updates = new ArrayList<>();
Set<Long> nodes = new HashSet<>();
for (int i = 0; i < 34; i++) {
label0Updates.add(NodeLabelUpdate.labelChanges(i, new long[] {}, new long[] { label0Id }));
nodes.add((long) i);
}
start(label0Updates);
// when
write(Collections.emptyIterator());
// then
LabelScanReader reader = store.newReader();
Set<Long> nodesWithLabel0 = PrimitiveLongCollections.toSet(reader.nodesWithLabel((int) label0Id));
assertEquals(nodes, nodesWithLabel0);
}
use of org.neo4j.kernel.api.labelscan.NodeLabelUpdate in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldBeAbleToCancelPopulationJob.
@Test
public void shouldBeAbleToCancelPopulationJob() throws Exception {
// GIVEN
createNode(map(name, "Mattias"), FIRST);
IndexPopulator populator = mock(IndexPopulator.class);
FlippableIndexProxy index = mock(FlippableIndexProxy.class);
IndexStoreView storeView = mock(IndexStoreView.class);
ControlledStoreScan storeScan = new ControlledStoreScan();
when(storeView.visitNodes(any(int[].class), any(IntPredicate.class), Matchers.<Visitor<NodeUpdates, RuntimeException>>any(), Matchers.<Visitor<NodeLabelUpdate, RuntimeException>>any(), anyBoolean())).thenReturn(storeScan);
final IndexPopulationJob job = newIndexPopulationJob(populator, index, storeView, NullLogProvider.getInstance(), false);
OtherThreadExecutor<Void> populationJobRunner = cleanup.add(new OtherThreadExecutor<>("Population job test runner", null));
Future<Void> runFuture = populationJobRunner.executeDontWait(state -> {
job.run();
return null;
});
storeScan.latch.waitForAllToStart();
job.cancel().get();
storeScan.latch.waitForAllToFinish();
// WHEN
runFuture.get();
// THEN
verify(populator, times(1)).close(false);
verify(index, times(0)).flip(Matchers.any(), Matchers.any());
}
use of org.neo4j.kernel.api.labelscan.NodeLabelUpdate in project neo4j by neo4j.
the class NativeLabelScanStoreIT method randomModifications.
private void randomModifications(long[] expected, int count) throws IOException {
BitSet editedNodes = new BitSet();
try (LabelScanWriter writer = store.newWriter()) {
for (int i = 0; i < count; i++) {
int nodeId = random.nextInt(NODE_COUNT);
if (editedNodes.get(nodeId)) {
i--;
continue;
}
int changeSize = random.nextInt(3) + 1;
long labels = expected[nodeId];
long[] labelsBefore = getLabels(labels);
for (int j = 0; j < changeSize; j++) {
labels = flipRandom(labels, LABEL_COUNT, random.random());
}
long[] labelsAfter = getLabels(labels);
editedNodes.set(nodeId);
NodeLabelUpdate labelChanges = labelChanges(nodeId, labelsBefore, labelsAfter);
writer.write(labelChanges);
expected[nodeId] = labels;
}
}
}
use of org.neo4j.kernel.api.labelscan.NodeLabelUpdate in project neo4j by neo4j.
the class PhysicalToLogicalLabelChangesTest method convertAndAssert.
private void convertAndAssert(long[] before, long[] after, long[] expectedRemoved, long[] expectedAdded) {
NodeLabelUpdate update = NodeLabelUpdate.labelChanges(0, before, after);
PhysicalToLogicalLabelChanges.convertToAdditionsAndRemovals(update);
assertArrayEquals(terminate(update.getLabelsBefore()), expectedRemoved);
assertArrayEquals(terminate(update.getLabelsAfter()), expectedAdded);
}
Aggregations