mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-18 19:05:06 +00:00
Parent/child: Reduce memory usage in top children query.
Closes #8165 Closes #8160
This commit is contained in:
parent
0ff61e1d6f
commit
6dac6ecd93
@ -208,7 +208,9 @@ public class TopChildrenQuery extends Query {
|
|||||||
// we found a match, add it and break
|
// we found a match, add it and break
|
||||||
IntObjectOpenHashMap<ParentDoc> readerParentDocs = parentDocsPerReader.get(indexReader.getCoreCacheKey());
|
IntObjectOpenHashMap<ParentDoc> readerParentDocs = parentDocsPerReader.get(indexReader.getCoreCacheKey());
|
||||||
if (readerParentDocs == null) {
|
if (readerParentDocs == null) {
|
||||||
readerParentDocs = new IntObjectOpenHashMap<>(indexReader.maxDoc());
|
//The number of docs in the reader and in the query both upper bound the size of parentDocsPerReader
|
||||||
|
int mapSize = Math.min(indexReader.maxDoc(), context.from() + context.size());
|
||||||
|
readerParentDocs = new IntObjectOpenHashMap<>(mapSize);
|
||||||
parentDocsPerReader.put(indexReader.getCoreCacheKey(), readerParentDocs);
|
parentDocsPerReader.put(indexReader.getCoreCacheKey(), readerParentDocs);
|
||||||
}
|
}
|
||||||
ParentDoc parentDoc = readerParentDocs.get(parentDocId);
|
ParentDoc parentDoc = readerParentDocs.get(parentDocId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user