use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedLuceneLabelScanStoreReaderTest method nodesWithLabelOverPartitions.
@Test
public void nodesWithLabelOverPartitions() {
PartitionedLuceneLabelScanStoreReader storeReader = createPartitionedReaderWithReaders();
when(indexReader1.nodesWithLabel(1)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.nodesWithLabel(1)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.nodesWithLabel(1)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet result = PrimitiveLongCollections.asSet(storeReader.nodesWithLabel(1));
verifyResult(result);
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedIndexReaderTest method rangeSeekByStringOverPartitions.
@Test
public void rangeSeekByStringOverPartitions() throws Exception {
PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
IndexQuery.StringRangePredicate query = IndexQuery.range(1, "a", false, "b", true);
when(indexReader1.query(query)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.query(query)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.query(query)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet results = PrimitiveLongCollections.asSet(indexReader.query(query));
verifyResult(results);
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class PartitionedIndexReaderTest method seekOverAllPartitions.
@Test
public void seekOverAllPartitions() throws Exception {
PartitionedIndexReader indexReader = createPartitionedReaderFromReaders();
IndexQuery.ExactPredicate query = IndexQuery.exact(1, "Test");
when(indexReader1.query(query)).thenReturn(PrimitiveLongCollections.iterator(1));
when(indexReader2.query(query)).thenReturn(PrimitiveLongCollections.iterator(2));
when(indexReader3.query(query)).thenReturn(PrimitiveLongCollections.iterator(3));
PrimitiveLongSet results = PrimitiveLongCollections.asSet(indexReader.query(query));
verifyResult(results);
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class NodeRangeDocumentLabelScanStorageStrategy method labelsForNode.
@Override
public PrimitiveLongIterator labelsForNode(IndexSearcher searcher, long nodeId) {
try {
TopDocs topDocs = searcher.search(format.rangeQuery(format.bitmapFormat().rangeOf(nodeId)), 1);
if (topDocs.scoreDocs.length < 1) {
return PrimitiveLongCollections.emptyIterator();
} else if (topDocs.scoreDocs.length > 1) {
throw new RuntimeException("This label scan store seems to contain an incorrect number of entries (" + topDocs.scoreDocs.length + ")");
}
int doc = topDocs.scoreDocs[0].doc;
PrimitiveLongSet labels = Primitive.longSet();
for (IndexableField fields : searcher.doc(doc).getFields()) {
if ("range".equals(fields.name())) {
continue;
}
Number numericValue = fields.numericValue();
if (numericValue != null) {
Long bitmap = numericValue.longValue();
if (format.bitmapFormat().hasLabel(bitmap, nodeId)) {
labels.add(Long.decode(fields.name()));
}
}
}
return labels.iterator();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.neo4j.collection.primitive.PrimitiveLongSet in project neo4j by neo4j.
the class NodeLabelReader method getListOfLabels.
public static long[] getListOfLabels(NodeRecord nodeRecord, RecordStore<DynamicRecord> labels) {
long field = nodeRecord.getLabelField();
if (NodeLabelsField.fieldPointsToDynamicRecordOfLabels(field)) {
List<DynamicRecord> recordList = new ArrayList<>();
PrimitiveLongSet alreadySeen = Primitive.longSet(16);
long id = NodeLabelsField.firstDynamicLabelRecordId(field);
while (!Record.NULL_REFERENCE.is(id)) {
DynamicRecord record = labels.getRecord(id, labels.newRecord(), FORCE);
if (!record.inUse() || !alreadySeen.add(id)) {
return PrimitiveLongCollections.EMPTY_LONG_ARRAY;
}
recordList.add(record);
}
return LabelChainWalker.labelIds(recordList);
}
return InlineNodeLabels.get(nodeRecord);
}
Aggregations