use of org.apache.lucene.index.ReaderSlice in project lucene-solr by apache.
the class FieldsConsumer method merge.
/** Merges in the fields from the readers in
* <code>mergeState</code>. The default implementation skips
* and maps around deleted documents, and calls {@link #write(Fields)}.
* Implementations can override this method for more sophisticated
* merging (bulk-byte copying, etc). */
public void merge(MergeState mergeState) throws IOException {
final List<Fields> fields = new ArrayList<>();
final List<ReaderSlice> slices = new ArrayList<>();
int docBase = 0;
for (int readerIndex = 0; readerIndex < mergeState.fieldsProducers.length; readerIndex++) {
final FieldsProducer f = mergeState.fieldsProducers[readerIndex];
final int maxDoc = mergeState.maxDocs[readerIndex];
f.checkIntegrity();
slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
fields.add(f);
docBase += maxDoc;
}
Fields mergedFields = new MappedMultiFields(mergeState, new MultiFields(fields.toArray(Fields.EMPTY_ARRAY), slices.toArray(ReaderSlice.EMPTY_ARRAY)));
write(mergedFields);
}
use of org.apache.lucene.index.ReaderSlice in project neo4j by neo4j.
the class PartitionedUniquenessVerifier method termsForField.
private Terms termsForField(String fieldName) throws IOException {
List<Terms> terms = new ArrayList<>();
List<ReaderSlice> readerSlices = new ArrayList<>();
for (LeafReader leafReader : allLeafReaders()) {
Fields fields = leafReader.fields();
Terms leafTerms = fields.terms(fieldName);
if (leafTerms != null) {
ReaderSlice readerSlice = new ReaderSlice(0, Math.toIntExact(leafTerms.size()), 0);
terms.add(leafTerms);
readerSlices.add(readerSlice);
}
}
Terms[] termsArray = terms.toArray(new Terms[terms.size()]);
ReaderSlice[] readerSlicesArray = readerSlices.toArray(new ReaderSlice[readerSlices.size()]);
return new MultiTerms(termsArray, readerSlicesArray);
}
Aggregations