mirror of https://github.com/apache/lucene.git
LUCENE-6477: include delegate heap usage in Accountable; fix javadocs
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1684086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5eb870f24e
commit
eaea4cda1d
|
@ -40,7 +40,7 @@ import org.apache.lucene.index.SegmentWriteState;
|
|||
* smaller rectangles, until the smallest rectangles have approximately
|
||||
* between X/2 and X (X default is 1024) points in them, at which point
|
||||
* such leaf cells are written as a block to disk, while the index tree
|
||||
* structure recording how space was sub-divided is loaded into HEAP
|
||||
* structure records how space was sub-divided is loaded into HEAP
|
||||
* at search time. At search time, the tree is recursed based on whether
|
||||
* each of left or right child overlap with the query shape, and once
|
||||
* a leaf block is reached, all documents in that leaf block are collected
|
||||
|
|
|
@ -153,6 +153,7 @@ class BKDTreeDocValuesProducer extends DocValuesProducer {
|
|||
for(Map.Entry<String,BKDTreeReader> ent : treeReaders.entrySet()) {
|
||||
resources.add(Accountables.namedAccountable("field " + ent.getKey(), ent.getValue()));
|
||||
}
|
||||
resources.add(Accountables.namedAccountable("delegate", delegate));
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
@ -164,6 +165,6 @@ class BKDTreeDocValuesProducer extends DocValuesProducer {
|
|||
|
||||
@Override
|
||||
public long ramBytesUsed() {
|
||||
return ramBytesUsed.get();
|
||||
return ramBytesUsed.get() + delegate.ramBytesUsed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,10 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.SimpleCollector;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.Accountable;
|
||||
import org.apache.lucene.util.Accountables;
|
||||
import org.apache.lucene.util.FixedBitSet;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.Nightly;
|
||||
|
@ -592,4 +595,24 @@ public class TestBKDTree extends LuceneTestCase {
|
|||
int y = BKDTreeWriter.encodeLon(Math.nextAfter(180.0, Double.POSITIVE_INFINITY));
|
||||
assertTrue(y < Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void testAccountableHasDelegate() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig iwc = newIndexWriterConfig();
|
||||
Codec codec = TestUtil.alwaysDocValuesFormat(new BKDTreeDocValuesFormat());
|
||||
iwc.setCodec(codec);
|
||||
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
|
||||
Document doc = new Document();
|
||||
doc.add(new BKDPointField("field", -18.2861, 147.7));
|
||||
w.addDocument(doc);
|
||||
IndexReader r = w.getReader();
|
||||
|
||||
// We can't wrap with "exotic" readers because the BKD query must see the BKDDVFormat:
|
||||
IndexSearcher s = newSearcher(r, false);
|
||||
// Need to run a query so the DV field is really loaded:
|
||||
TopDocs hits = s.search(new BKDPointInBBoxQuery("field", -30, 0, 140, 150), 1);
|
||||
assertEquals(1, hits.totalHits);
|
||||
assertTrue(Accountables.toString((Accountable) r.leaves().get(0).reader()).contains("delegate"));
|
||||
IOUtils.close(r, w, dir);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue