@Override public long ramBytesUsed() { long mem = RamUsageEstimator.shallowSizeOf(this); try { if (searcherMgr != null) { IndexSearcher searcher = searcherMgr.acquire(); try { for (AtomicReaderContext context : searcher.getIndexReader().leaves()) { AtomicReader reader = FilterAtomicReader.unwrap(context.reader()); if (reader instanceof SegmentReader) { mem += ((SegmentReader) context.reader()).ramBytesUsed(); } } } finally { searcherMgr.release(searcher); } } return mem; } catch (IOException ioe) { throw new RuntimeException(ioe); } }
private static Terms intTerms(Terms terms) { return new FilterAtomicReader.FilterTerms(terms) { @Override public TermsEnum iterator(TermsEnum reuse) throws IOException { return filterPrefixCodedInts(in.iterator(reuse)); } }; }
private static Terms longTerms(Terms terms) { return new FilterAtomicReader.FilterTerms(terms) { @Override public TermsEnum iterator(TermsEnum reuse) throws IOException { return filterPrefixCodedLongs(in.iterator(reuse)); } }; }
private static AtomicReader setDocSize(AtomicReader reader, final int count) { return new FilterAtomicReader(reader) { @Override public Bits getLiveDocs() { return new Bits() { @Override public boolean get(int index) { return true; } @Override public int length() { return count; } }; } @Override public int numDocs() { return count; } @Override public int maxDoc() { return count; } @Override public void document(int docID, StoredFieldVisitor visitor) throws IOException { // Do nothing } }; }