Java Code Examples for org.elasticsearch.search.aggregations.LeafBucketCollector#NO_OP_COLLECTOR
The following examples show how to use
org.elasticsearch.search.aggregations.LeafBucketCollector#NO_OP_COLLECTOR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvgAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { counts = bigArrays.grow(counts, bucket + 1); sums = bigArrays.grow(sums, bucket + 1); values.setDocument(doc); final int valueCount = values.count(); counts.increment(bucket, valueCount); double sum = 0; for (int i = 0; i < valueCount; i++) { sum += values.valueAt(i); } sums.increment(bucket, sum); } }; }
Example 2
Source File: SumAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { sums = bigArrays.grow(sums, bucket + 1); values.setDocument(doc); final int valuesCount = values.count(); double sum = 0; for (int i = 0; i < valuesCount; i++) { sum += values.valueAt(i); } sums.increment(bucket, sum); } }; }
Example 3
Source File: MaxAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx); final NumericDoubleValues values = MultiValueMode.MAX.select(allValues, Double.NEGATIVE_INFINITY); return new LeafBucketCollectorBase(sub, allValues) { @Override public void collect(int doc, long bucket) throws IOException { if (bucket >= maxes.size()) { long from = maxes.size(); maxes = bigArrays.grow(maxes, bucket + 1); maxes.fill(from, maxes.size(), Double.NEGATIVE_INFINITY); } final double value = values.get(doc); double max = maxes.get(bucket); max = Math.max(max, value); maxes.set(bucket, max); } }; }
Example 4
Source File: ValueCountAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedBinaryDocValues values = valuesSource.bytesValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { counts = bigArrays.grow(counts, bucket + 1); values.setDocument(doc); counts.increment(bucket, values.count()); } }; }
Example 5
Source File: MinAggregator.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx); final NumericDoubleValues values = MultiValueMode.MIN.select(allValues, Double.POSITIVE_INFINITY); return new LeafBucketCollectorBase(sub, allValues) { @Override public void collect(int doc, long bucket) throws IOException { if (bucket >= mins.size()) { long from = mins.size(); mins = bigArrays.grow(mins, bucket + 1); mins.fill(from, mins.size(), Double.POSITIVE_INFINITY); } final double value = values.get(doc); double min = mins.get(bucket); min = Math.min(min, value); mins.set(bucket, min); } }; }
Example 6
Source File: AbstractTDigestPercentilesAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { states = bigArrays.grow(states, bucket + 1); TDigestState state = states.get(bucket); if (state == null) { state = new TDigestState(compression); states.set(bucket, state); } values.setDocument(doc); final int valueCount = values.count(); for (int i = 0; i < valueCount; i++) { state.add(values.valueAt(i)); } } }; }
Example 7
Source File: StatsAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { if (bucket >= counts.size()) { final long from = counts.size(); final long overSize = BigArrays.overSize(bucket + 1); counts = bigArrays.resize(counts, overSize); sums = bigArrays.resize(sums, overSize); mins = bigArrays.resize(mins, overSize); maxes = bigArrays.resize(maxes, overSize); mins.fill(from, overSize, Double.POSITIVE_INFINITY); maxes.fill(from, overSize, Double.NEGATIVE_INFINITY); } values.setDocument(doc); final int valuesCount = values.count(); counts.increment(bucket, valuesCount); double sum = 0; double min = mins.get(bucket); double max = maxes.get(bucket); for (int i = 0; i < valuesCount; i++) { double value = values.valueAt(i); sum += value; min = Math.min(min, value); max = Math.max(max, value); } sums.increment(bucket, sum); mins.set(bucket, min); maxes.set(bucket, max); } }; }
Example 8
Source File: GeoCentroidAggregator.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final MultiGeoPointValues values = valuesSource.geoPointValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { centroids = bigArrays.grow(centroids, bucket + 1); counts = bigArrays.grow(counts, bucket + 1); values.setDocument(doc); final int valueCount = values.count(); if (valueCount > 0) { double[] pt = new double[2]; // get the previously accumulated number of counts long prevCounts = counts.get(bucket); // increment by the number of points for this document counts.increment(bucket, valueCount); // get the previous GeoPoint if a moving avg was computed if (prevCounts > 0) { final GeoPoint centroid = GeoPoint.fromIndexLong(centroids.get(bucket)); pt[0] = centroid.lon(); pt[1] = centroid.lat(); } // update the moving average for (int i = 0; i < valueCount; ++i) { GeoPoint value = values.valueAt(i); pt[0] = pt[0] + (value.getLon() - pt[0]) / ++prevCounts; pt[1] = pt[1] + (value.getLat() - pt[1]) / prevCounts; } centroids.set(bucket, GeoEncodingUtils.mortonHash(pt[0], pt[1])); } } }; }
Example 9
Source File: GeoBoundsAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCollector sub) { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final MultiGeoPointValues values = valuesSource.geoPointValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { if (bucket >= tops.size()) { long from = tops.size(); tops = bigArrays.grow(tops, bucket + 1); tops.fill(from, tops.size(), Double.NEGATIVE_INFINITY); bottoms = bigArrays.resize(bottoms, tops.size()); bottoms.fill(from, bottoms.size(), Double.POSITIVE_INFINITY); posLefts = bigArrays.resize(posLefts, tops.size()); posLefts.fill(from, posLefts.size(), Double.POSITIVE_INFINITY); posRights = bigArrays.resize(posRights, tops.size()); posRights.fill(from, posRights.size(), Double.NEGATIVE_INFINITY); negLefts = bigArrays.resize(negLefts, tops.size()); negLefts.fill(from, negLefts.size(), Double.POSITIVE_INFINITY); negRights = bigArrays.resize(negRights, tops.size()); negRights.fill(from, negRights.size(), Double.NEGATIVE_INFINITY); } values.setDocument(doc); final int valuesCount = values.count(); for (int i = 0; i < valuesCount; ++i) { GeoPoint value = values.valueAt(i); double top = tops.get(bucket); if (value.lat() > top) { top = value.lat(); } double bottom = bottoms.get(bucket); if (value.lat() < bottom) { bottom = value.lat(); } double posLeft = posLefts.get(bucket); if (value.lon() >= 0 && value.lon() < posLeft) { posLeft = value.lon(); } double posRight = posRights.get(bucket); if (value.lon() >= 0 && value.lon() > posRight) { posRight = value.lon(); } double negLeft = negLefts.get(bucket); if (value.lon() < 0 && value.lon() < negLeft) { negLeft = value.lon(); } double negRight = negRights.get(bucket); if (value.lon() < 0 && value.lon() > negRight) { negRight = value.lon(); } tops.set(bucket, top); bottoms.set(bucket, bottom); posLefts.set(bucket, posLeft); posRights.set(bucket, posRight); negLefts.set(bucket, negLeft); negRights.set(bucket, negRight); } } }; }
Example 10
Source File: ExtendedStatsAggregator.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException { if (valuesSource == null) { return LeafBucketCollector.NO_OP_COLLECTOR; } final BigArrays bigArrays = context.bigArrays(); final SortedNumericDoubleValues values = valuesSource.doubleValues(ctx); return new LeafBucketCollectorBase(sub, values) { @Override public void collect(int doc, long bucket) throws IOException { if (bucket >= counts.size()) { final long from = counts.size(); final long overSize = BigArrays.overSize(bucket + 1); counts = bigArrays.resize(counts, overSize); sums = bigArrays.resize(sums, overSize); mins = bigArrays.resize(mins, overSize); maxes = bigArrays.resize(maxes, overSize); sumOfSqrs = bigArrays.resize(sumOfSqrs, overSize); mins.fill(from, overSize, Double.POSITIVE_INFINITY); maxes.fill(from, overSize, Double.NEGATIVE_INFINITY); } values.setDocument(doc); final int valuesCount = values.count(); counts.increment(bucket, valuesCount); double sum = 0; double sumOfSqr = 0; double min = mins.get(bucket); double max = maxes.get(bucket); for (int i = 0; i < valuesCount; i++) { double value = values.valueAt(i); sum += value; sumOfSqr += value * value; min = Math.min(min, value); max = Math.max(max, value); } sums.increment(bucket, sum); sumOfSqrs.increment(bucket, sumOfSqr); mins.set(bucket, min); maxes.set(bucket, max); } }; }