use of org.neo4j.internal.kernel.api.Scan in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldScanASubsetOfNodes.
@Test
void shouldScanASubsetOfNodes() {
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
for (int label : ALL_LABELS) {
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(label);
assertTrue(scan.reserveBatch(nodes, 11));
MutableLongList found = LongLists.mutable.empty();
while (nodes.next()) {
found.add(nodes.nodeReference());
}
assertThat(found.size()).isGreaterThan(0);
if (label == FOO_LABEL) {
assertTrue(FOO_NODES.containsAll(found));
assertTrue(found.noneSatisfy(f -> BAR_NODES.contains(f)));
} else if (label == BAR_LABEL) {
assertTrue(BAR_NODES.containsAll(found));
assertTrue(found.noneSatisfy(f -> FOO_NODES.contains(f)));
} else {
fail();
}
}
}
}
use of org.neo4j.internal.kernel.api.Scan in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldHandleSizeHintOverflow.
@Test
void shouldHandleSizeHintOverflow() {
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(FOO_LABEL);
assertTrue(scan.reserveBatch(nodes, NUMBER_OF_NODES * 2));
MutableLongList ids = LongLists.mutable.empty();
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
assertEquals(FOO_NODES.size(), ids.size());
assertTrue(FOO_NODES.containsAll(ids));
assertTrue(ids.noneSatisfy(f -> BAR_NODES.contains(f)));
}
}
use of org.neo4j.internal.kernel.api.Scan in project neo4j by neo4j.
the class ParallelNodeLabelScanTestBase method shouldScanAllNodesInBatches.
@Test
void shouldScanAllNodesInBatches() {
// given
try (NodeLabelIndexCursor nodes = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
Scan<NodeLabelIndexCursor> scan = read.nodeLabelScan(FOO_LABEL);
MutableLongList ids = LongLists.mutable.empty();
while (scan.reserveBatch(nodes, 3)) {
while (nodes.next()) {
ids.add(nodes.nodeReference());
}
}
// then
assertEquals(FOO_NODES.size(), ids.size());
assertTrue(FOO_NODES.containsAll(ids));
assertTrue(ids.noneSatisfy(f -> BAR_NODES.contains(f)));
}
}
Aggregations