simplify methods
@@ -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);
- }
-
}
}
