Search in sources :

Example 1 with MappedMultiFields

use of org.apache.lucene.index.MappedMultiFields 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);
}
Also used : Fields(org.apache.lucene.index.Fields) MultiFields(org.apache.lucene.index.MultiFields) MappedMultiFields(org.apache.lucene.index.MappedMultiFields) ArrayList(java.util.ArrayList) MultiFields(org.apache.lucene.index.MultiFields) MappedMultiFields(org.apache.lucene.index.MappedMultiFields) MappedMultiFields(org.apache.lucene.index.MappedMultiFields) ReaderSlice(org.apache.lucene.index.ReaderSlice)

Aggregations

ArrayList (java.util.ArrayList)1 Fields (org.apache.lucene.index.Fields)1 MappedMultiFields (org.apache.lucene.index.MappedMultiFields)1 MultiFields (org.apache.lucene.index.MultiFields)1 ReaderSlice (org.apache.lucene.index.ReaderSlice)1