use of org.neo4j.kernel.api.labelscan.NodeLabelRange in project neo4j by neo4j.
the class NativeAllEntriesLabelScanReaderTest method assertRanges.
private static void assertRanges(AllEntriesLabelScanReader reader, Labels[] data) {
Iterator<NodeLabelRange> iterator = reader.iterator();
long highestRangeId = highestRangeId(data);
for (long rangeId = 0; rangeId <= highestRangeId; rangeId++) {
SortedMap<Long, List<Long>> /*labelIds*/
expected = rangeOf(data, rangeId);
if (expected != null) {
assertTrue("Was expecting range " + expected, iterator.hasNext());
NodeLabelRange range = iterator.next();
assertEquals(rangeId, range.id());
assertArrayEquals("Unexpected data in range " + rangeId, nodesOf(expected), range.nodes());
for (Map.Entry<Long, List<Long>> expectedEntry : expected.entrySet()) {
long[] labels = range.labels(expectedEntry.getKey());
assertArrayEquals(asArray(expectedEntry.getValue().iterator()), labels);
}
}
// else there was nothing in this range
}
assertFalse(iterator.hasNext());
}
use of org.neo4j.kernel.api.labelscan.NodeLabelRange in project neo4j by neo4j.
the class LabelScanStoreTest method shouldScanMultipleRanges.
@Test
public void shouldScanMultipleRanges() throws Exception {
// GIVEN
int labelId1 = 1, labelId2 = 2;
long nodeId1 = 10, nodeId2 = 1280;
start(asList(labelChanges(nodeId1, NO_LABELS, new long[] { labelId1 }), labelChanges(nodeId2, NO_LABELS, new long[] { labelId1, labelId2 })));
// WHEN
BoundedIterable<NodeLabelRange> reader = store.allNodeLabelRanges();
Iterator<NodeLabelRange> iterator = reader.iterator();
NodeLabelRange range1 = iterator.next();
NodeLabelRange range2 = iterator.next();
assertFalse(iterator.hasNext());
// THEN
assertArrayEquals(new long[] { nodeId1 }, sorted(range1.nodes()));
assertArrayEquals(new long[] { nodeId2 }, sorted(range2.nodes()));
assertArrayEquals(new long[] { labelId1 }, sorted(range1.labels(nodeId1)));
assertArrayEquals(new long[] { labelId1, labelId2 }, sorted(range2.labels(nodeId2)));
}
use of org.neo4j.kernel.api.labelscan.NodeLabelRange in project neo4j by neo4j.
the class LabelScanStoreTest method shouldScanSingleRange.
@Test
public void shouldScanSingleRange() throws Exception {
// GIVEN
int labelId1 = 1, labelId2 = 2;
long nodeId1 = 10, nodeId2 = 11;
start(asList(labelChanges(nodeId1, NO_LABELS, new long[] { labelId1 }), labelChanges(nodeId2, NO_LABELS, new long[] { labelId1, labelId2 })));
// WHEN
BoundedIterable<NodeLabelRange> reader = store.allNodeLabelRanges();
NodeLabelRange range = single(reader.iterator());
// THEN
assertArrayEquals(new long[] { nodeId1, nodeId2 }, sorted(range.nodes()));
assertArrayEquals(new long[] { labelId1 }, sorted(range.labels(nodeId1)));
assertArrayEquals(new long[] { labelId1, labelId2 }, sorted(range.labels(nodeId2)));
}
Aggregations