org.apache.lucene.index.BaseCompositeReader Java Examples
The following examples show how to use
org.apache.lucene.index.BaseCompositeReader.
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: UnifiedHighlighter.java From lucene-solr with Apache License 2.0 | 6 votes |
static IndexReader wrap(IndexReader reader) throws IOException { LeafReader[] leafReaders = reader.leaves().stream() .map(LeafReaderContext::reader) .map(TermVectorReusingLeafReader::new) .toArray(LeafReader[]::new); return new BaseCompositeReader<IndexReader>(leafReaders) { @Override protected void doClose() throws IOException { reader.close(); } @Override public CacheHelper getReaderCacheHelper() { return null; } }; }
Example #2
Source File: IndexManager.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static boolean isFiltered(int notAdjustedDocId, IndexReader reader, Filter filter) throws IOException { if (filter == null) { return false; } if (reader instanceof BaseCompositeReader) { BaseCompositeReader<IndexReader> indexReader = (BaseCompositeReader<IndexReader>) reader; List<? extends IndexReader> sequentialSubReaders = BaseCompositeReaderUtil.getSequentialSubReaders(indexReader); int readerIndex = BaseCompositeReaderUtil.readerIndex(indexReader, notAdjustedDocId); int readerBase = BaseCompositeReaderUtil.readerBase(indexReader, readerIndex); int docId = notAdjustedDocId - readerBase; IndexReader orgReader = sequentialSubReaders.get(readerIndex); SegmentReader sReader = AtomicReaderUtil.getSegmentReader(orgReader); if (sReader != null) { SegmentReader segmentReader = (SegmentReader) sReader; DocIdSet docIdSet = filter.getDocIdSet(segmentReader.getContext(), segmentReader.getLiveDocs()); DocIdSetIterator iterator = docIdSet.iterator(); if (iterator == null) { return true; } if (iterator.advance(docId) == docId) { return false; } return true; } throw new RuntimeException("Reader has to be a SegmentReader [" + orgReader + "]"); } else { throw new RuntimeException("Reader has to be a BaseCompositeReader [" + reader + "]"); } }