use of org.neo4j.kernel.api.impl.index.collector.FirstHitCollector in project neo4j by neo4j.
the class PartitionedLuceneLabelScanWriter method readLabelBitMapsInRange.
private Map<Long, /*range*/
Bitmap> readLabelBitMapsInRange(IndexSearcher searcher, long range) throws IOException {
Map<Long, Bitmap> /*label*/
fields = new HashMap<>();
Term documentTerm = format.rangeTerm(range);
TermQuery query = new TermQuery(documentTerm);
FirstHitCollector hitCollector = new FirstHitCollector();
searcher.search(query, hitCollector);
if (hitCollector.hasMatched()) {
Document document = searcher.doc(hitCollector.getMatchedDoc());
for (IndexableField field : document.getFields()) {
if (!format.isRangeOrLabelField(field)) {
Long label = Long.valueOf(field.name());
fields.put(label, format.readBitmap(field));
}
}
}
return fields;
}
use of org.neo4j.kernel.api.impl.index.collector.FirstHitCollector in project neo4j by neo4j.
the class NodeRangeDocumentLabelScanStorageStrategyTest method newIndexPartitionMock.
private WritableIndexPartition newIndexPartitionMock(IndexWriter indexWriter, Document... documents) throws IOException {
WritableIndexPartition partition = mock(WritableIndexPartition.class);
PartitionSearcher partitionSearcher = mock(PartitionSearcher.class);
when(partition.acquireSearcher()).thenReturn(partitionSearcher);
when(partition.getIndexWriter()).thenReturn(indexWriter);
IndexSearcher searcher = mock(IndexSearcher.class);
when(partitionSearcher.getIndexSearcher()).thenReturn(searcher);
for (int i = 0; i < documents.length; i++) {
int docId = i;
doAnswer(invocation -> {
FirstHitCollector collector = (FirstHitCollector) invocation.getArguments()[1];
try {
collector.collect(docId);
} catch (CollectionTerminatedException swallow) {
}
return null;
}).when(searcher).search(eq(new TermQuery(format.rangeTerm(documents[i]))), any(FirstHitCollector.class));
when(searcher.doc(i)).thenReturn(documents[i]);
}
return partition;
}
Aggregations