From a54798354b0b6681fae451c9eccd647f522446dd Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 21 Dec 2017 19:42:32 +0100 Subject: [PATCH] simplify methods --- .../bucket/nested/NestedAggregator.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java index c3571ccbf8a..45995072507 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregator.java @@ -118,7 +118,7 @@ class NestedAggregator extends BucketsAggregator implements SingleBucketAggregat private void processBufferedDocs() throws IOException { if (bufferingNestedLeafBucketCollector != null) { - bufferingNestedLeafBucketCollector.postCollect(); + bufferingNestedLeafBucketCollector.processBufferedChildBuckets(); } } @@ -158,27 +158,27 @@ class NestedAggregator extends BucketsAggregator implements SingleBucketAggregat } if (currentParentDoc != parentDoc) { - processChildBuckets(currentParentDoc, bucketBuffer); + processBufferedChildBuckets(); currentParentDoc = parentDoc; } bucketBuffer.add(bucket); } - void processChildBuckets(int parentDoc, LongArrayList buckets) throws IOException { + void processBufferedChildBuckets() throws IOException { if (bucketBuffer.isEmpty()) { return; } - final int prevParentDoc = parentDocs.prevSetBit(parentDoc - 1); + final int prevParentDoc = parentDocs.prevSetBit(currentParentDoc - 1); int childDocId = childDocs.docID(); if (childDocId <= prevParentDoc) { childDocId = childDocs.advance(prevParentDoc + 1); } - for (; childDocId < parentDoc; childDocId = childDocs.nextDoc()) { - final long[] buffer = buckets.buffer; - final int size = buckets.size(); + for (; childDocId < currentParentDoc; childDocId = childDocs.nextDoc()) { + final long[] buffer = bucketBuffer.buffer; + final int size = bucketBuffer.size(); for (int i = 0; i < size; i++) { collectBucket(sub, childDocId, buffer[i]); } @@ -186,10 +186,6 @@ class NestedAggregator extends BucketsAggregator implements SingleBucketAggregat bucketBuffer.clear(); } - void postCollect() throws IOException { - processChildBuckets(currentParentDoc, bucketBuffer); - } - } }