Java Code Examples for org.apache.lucene.codecs.StoredFieldsReader#getMergeInstance()
The following examples show how to use
org.apache.lucene.codecs.StoredFieldsReader#getMergeInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MergeReaderWrapper.java From lucene-solr with Apache License 2.0 | 5 votes |
MergeReaderWrapper(CodecReader in) throws IOException { this.in = in; FieldsProducer fields = in.getPostingsReader(); if (fields != null) { fields = fields.getMergeInstance(); } this.fields = fields; NormsProducer norms = in.getNormsReader(); if (norms != null) { norms = norms.getMergeInstance(); } this.norms = norms; DocValuesProducer docValues = in.getDocValuesReader(); if (docValues != null) { docValues = docValues.getMergeInstance(); } this.docValues = docValues; StoredFieldsReader store = in.getFieldsReader(); if (store != null) { store = store.getMergeInstance(); } this.store = store; TermVectorsReader vectors = in.getTermVectorsReader(); if (vectors != null) { vectors = vectors.getMergeInstance(); } this.vectors = vectors; }
Example 2
Source File: SortingStoredFieldsConsumer.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override void flush(SegmentWriteState state, Sorter.DocMap sortMap) throws IOException { super.flush(state, sortMap); if (sortMap == null) { // we're lucky the index is already sorted, just rename the temporary file and return for (Map.Entry<String, String> entry : tmpDirectory.getTemporaryFiles().entrySet()) { tmpDirectory.rename(entry.getValue(), entry.getKey()); } return; } StoredFieldsReader reader = docWriter.codec.storedFieldsFormat() .fieldsReader(tmpDirectory, state.segmentInfo, state.fieldInfos, IOContext.DEFAULT); StoredFieldsReader mergeReader = reader.getMergeInstance(); StoredFieldsWriter sortWriter = docWriter.codec.storedFieldsFormat() .fieldsWriter(state.directory, state.segmentInfo, IOContext.DEFAULT); try { reader.checkIntegrity(); CopyVisitor visitor = new CopyVisitor(sortWriter); for (int docID = 0; docID < state.segmentInfo.maxDoc(); docID++) { sortWriter.startDocument(); mergeReader.visitDocument(sortMap.newToOld(docID), visitor); sortWriter.finishDocument(); } sortWriter.finish(state.fieldInfos, state.segmentInfo.maxDoc()); } finally { IOUtils.close(reader, sortWriter); IOUtils.deleteFiles(tmpDirectory, tmpDirectory.getTemporaryFiles().values()); } }
Example 3
Source File: IndexSizeEstimator.java From lucene-solr with Apache License 2.0 | 5 votes |
private void estimateStoredFields(Map<String, Object> result) throws IOException { log.info("- estimating stored fields..."); Map<String, Map<String, Object>> stats = new HashMap<>(); for (LeafReaderContext context : reader.leaves()) { LeafReader leafReader = context.reader(); EstimatingVisitor visitor = new EstimatingVisitor(stats, topN, maxLength, samplingStep); Bits liveDocs = leafReader.getLiveDocs(); if (leafReader instanceof CodecReader) { CodecReader codecReader = (CodecReader)leafReader; StoredFieldsReader storedFieldsReader = codecReader.getFieldsReader(); // this instance may be faster for a full sequential pass StoredFieldsReader mergeInstance = storedFieldsReader.getMergeInstance(); for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) { if (liveDocs != null && !liveDocs.get(docId)) { continue; } mergeInstance.visitDocument(docId, visitor); } if (mergeInstance != storedFieldsReader) { mergeInstance.close(); } } else { for (int docId = 0; docId < leafReader.maxDoc(); docId += samplingStep) { if (liveDocs != null && !liveDocs.get(docId)) { continue; } leafReader.document(docId, visitor); } } } result.put(STORED_FIELDS, stats); }