Cut other aggregations over to use collectExistingBucket() if a bucket ord has been hit, that already exists.

Closes #5955
This commit is contained in:
Martijn van Groningen 2014-04-28 00:50:46 +07:00
parent f3219f7098
commit fc3efda6af
6 changed files with 25 additions and 9 deletions

View File

@ -77,8 +77,10 @@ public class GeoHashGridAggregator extends BucketsAggregator {
long bucketOrdinal = bucketOrds.add(val);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
}
collectBucket(doc, bucketOrdinal);
}
}

View File

@ -34,7 +34,6 @@ import org.elasticsearch.search.aggregations.support.ValuesSource;
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
import org.elasticsearch.search.aggregations.support.format.ValueFormatter;
import org.elasticsearch.search.aggregations.support.format.ValueParser;
import java.io.IOException;
import java.util.ArrayList;
@ -101,8 +100,10 @@ public class HistogramAggregator extends BucketsAggregator {
long bucketOrd = bucketOrds.add(key);
if (bucketOrd < 0) { // already seen
bucketOrd = -1 - bucketOrd;
collectExistingBucket(doc, bucketOrd);
} else {
collectBucket(doc, bucketOrd);
}
collectBucket(doc, bucketOrd);
previousKey = key;
}
}

View File

@ -166,11 +166,15 @@ public class SignificantStringTermsAggregator extends StringTermsAggregator {
bucketOrd = bucketOrds.add(bytes, hash);
if (bucketOrd < 0) { // already seen in another segment
bucketOrd = -1 - bucketOrd;
collectExistingBucket(doc, bucketOrd);
} else {
collectBucket(doc, bucketOrd);
}
ordinalToBucket.set(ord, bucketOrd);
} else {
collectExistingBucket(doc, bucketOrd);
}
collectBucket(doc, bucketOrd);
}
}

View File

@ -83,8 +83,10 @@ public class DoubleTermsAggregator extends BucketsAggregator {
long bucketOrdinal = bucketOrds.add(bits);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
}
collectBucket(doc, bucketOrdinal);
}
}

View File

@ -83,8 +83,10 @@ public class LongTermsAggregator extends BucketsAggregator {
long bucketOrdinal = bucketOrds.add(val);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
}
collectBucket(doc, bucketOrdinal);
}
}

View File

@ -87,8 +87,10 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator {
long bucketOrdinal = bucketOrds.add(bytes, hash);
if (bucketOrdinal < 0) { // already seen
bucketOrdinal = - 1 - bucketOrdinal;
collectExistingBucket(doc, bucketOrdinal);
} else {
collectBucket(doc, bucketOrdinal);
}
collectBucket(doc, bucketOrdinal);
}
}
@ -289,11 +291,14 @@ public class StringTermsAggregator extends AbstractStringTermsAggregator {
bucketOrd = bucketOrds.add(bytes, hash);
if (bucketOrd < 0) { // already seen in another segment
bucketOrd = - 1 - bucketOrd;
collectExistingBucket(doc, bucketOrd);
} else {
collectBucket(doc, bucketOrd);
}
ordinalToBucket.set(ord, bucketOrd);
} else {
collectExistingBucket(doc, bucketOrd);
}
collectBucket(doc, bucketOrd);
}
}