use of org.neo4j.index.internal.gbptree.Hit in project neo4j by neo4j.
the class NativeLabelScanReader method nodesWithLabel.
@Override
public PrimitiveLongIterator nodesWithLabel(int labelId) {
RawCursor<Hit<LabelScanKey, LabelScanValue>, IOException> cursor;
try {
ensureOpenCursorsClosed();
cursor = seekerForLabel(labelId);
openCursors.offer(cursor);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return new LabelScanValueIterator(cursor);
}
use of org.neo4j.index.internal.gbptree.Hit in project neo4j by neo4j.
the class NativeLabelScanReader method iteratorsForLabels.
private List<PrimitiveLongIterator> iteratorsForLabels(int[] labelIds) {
List<PrimitiveLongIterator> iterators = new ArrayList<>();
try {
ensureOpenCursorsClosed();
for (int labelId : labelIds) {
RawCursor<Hit<LabelScanKey, LabelScanValue>, IOException> cursor = seekerForLabel(labelId);
openCursors.offer(cursor);
iterators.add(new LabelScanValueIterator(cursor));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return iterators;
}
use of org.neo4j.index.internal.gbptree.Hit in project neo4j by neo4j.
the class NativeLabelScanReaderTest method shouldFindMultipleNodesInEachRange.
@SuppressWarnings("unchecked")
@Test
public void shouldFindMultipleNodesInEachRange() throws Exception {
// GIVEN
GBPTree<LabelScanKey, LabelScanValue> index = mock(GBPTree.class);
RawCursor<Hit<LabelScanKey, LabelScanValue>, IOException> cursor = mock(RawCursor.class);
when(cursor.next()).thenReturn(true, true, true, false);
when(cursor.get()).thenReturn(// range, bits
hit(0, 0b1000_1000__1100_0010L), hit(1, 0b0000_0010__0000_1000L), hit(3, 0b0010_0000__1010_0001L), null);
when(index.seek(any(LabelScanKey.class), any(LabelScanKey.class))).thenReturn(cursor);
try (NativeLabelScanReader reader = new NativeLabelScanReader(index)) {
// WHEN
PrimitiveLongIterator iterator = reader.nodesWithLabel(LABEL_ID);
// THEN
assertArrayEquals(new long[] { // base 0*64 = 0
1, 6, 7, 11, 15, // base 1*64 = 64
64 + 3, 64 + 9, // base 3*64 = 192
192 + 0, 192 + 5, 192 + 7, 192 + 13 }, asArray(iterator));
}
}
Aggregations