From e356d793caf2a899f23261baba922d4a08b362ed Mon Sep 17 00:00:00 2001 From: Toke Eskildsen Date: Mon, 3 Dec 2018 14:30:30 +0100 Subject: [PATCH] LUCENE-8374 part 4/4: Reduce reads for sparse DocValues Offset and index jump-table for norm blocks. --- .../lucene/codecs/lucene70/Lucene70NormsProducer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70NormsProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70NormsProducer.java index c7310e848d0..321fcff6d8b 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70NormsProducer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene70/Lucene70NormsProducer.java @@ -45,6 +45,7 @@ final class Lucene70NormsProducer extends NormsProducer implements Cloneable { private final Map norms = new HashMap<>(); private final int maxDoc; private IndexInput data; + private final IndexedDISICacheFactory disiCacheFactory = new IndexedDISICacheFactory(); private boolean merging; private Map disiInputs; private Map dataInputs; @@ -293,7 +294,9 @@ final class Lucene70NormsProducer extends NormsProducer implements Cloneable { } else { // sparse final IndexInput disiInput = getDisiInput(field, entry); - final IndexedDISI disi = new IndexedDISI(disiInput, entry.numDocsWithField); + final IndexedDISI disi = disiCacheFactory.createCachedIndexedDISI( + disiInput, entry.docsWithFieldOffset + entry.docsWithFieldLength, entry.numDocsWithField, field.name); + if (entry.bytesPerNorm == 0) { return new SparseNormsIterator(disi) { @Override @@ -342,11 +345,12 @@ final class Lucene70NormsProducer extends NormsProducer implements Cloneable { @Override public void close() throws IOException { data.close(); + disiCacheFactory.releaseAll(); } @Override public long ramBytesUsed() { - return 64L * norms.size(); // good enough + return 64L * norms.size() + disiCacheFactory.ramBytesUsed(); // good enough } @Override