当前位置: 首页>>代码示例>>Java>>正文


Java LeafBucketCollector类代码示例

本文整理汇总了Java中org.elasticsearch.search.aggregations.LeafBucketCollector的典型用法代码示例。如果您正苦于以下问题:Java LeafBucketCollector类的具体用法?Java LeafBucketCollector怎么用?Java LeafBucketCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LeafBucketCollector类属于org.elasticsearch.search.aggregations包,在下文中一共展示了LeafBucketCollector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@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);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:AvgAggregator.java

示例2: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@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);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:SumAggregator.java

示例3: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@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);
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MaxAggregator.java

示例4: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@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());
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ValueCountAggregator.java

示例5: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@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);
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MinAggregator.java

示例6: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    return new LeafBucketCollectorBase(super.getLeafCollector(ctx, sub), null) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            assert bucket == 0;
            numCollectedDocs++;
            globalOrds.setDocument(doc);
            final int numOrds = globalOrds.cardinality();
            for (int i = 0; i < numOrds; i++) {
                final long globalOrd = globalOrds.ordAt(i);
                long bucketOrd = bucketOrds.add(globalOrd);
                if (bucketOrd < 0) {
                    bucketOrd = -1 - bucketOrd;
                    collectExistingBucket(sub, doc, bucketOrd);
                } else {
                    collectBucket(sub, doc, bucketOrd);
                }
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:GlobalOrdinalsSignificantTermsAggregator.java

示例7: SortedBinaryRangeLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
SortedBinaryRangeLeafCollector(SortedBinaryDocValues values,
        Range[] ranges, LeafBucketCollector sub) {
    super(sub, values);
    for (int i = 1; i < ranges.length; ++i) {
        if (RANGE_COMPARATOR.compare(ranges[i-1], ranges[i]) > 0) {
            throw new IllegalArgumentException("Ranges must be sorted");
        }
    }
    this.values = values;
    this.sub = sub;
    this.ranges = ranges;
    maxTos = new BytesRef[ranges.length];
    if (ranges.length > 0) {
        maxTos[0] = ranges[0].to;
    }
    for (int i = 1; i < ranges.length; ++i) {
        if (compare(ranges[i].to, maxTos[i-1], -1) >= 0) {
            maxTos[i] = ranges[i].to;
        } else {
            maxTos[i] = maxTos[i-1];
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BinaryRangeAggregator.java

示例8: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {

    globalOrds = valuesSource.globalOrdinalsValues(ctx);

    if (acceptedGlobalOrdinals == null && includeExclude != null) {
        acceptedGlobalOrdinals = includeExclude.acceptedGlobalOrdinals(globalOrds);
    }

    if (acceptedGlobalOrdinals != null) {
        globalOrds = new FilteredOrdinals(globalOrds, acceptedGlobalOrdinals);
    }

    return newCollector(globalOrds, sub);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:GlobalOrdinalsStringTermsAggregator.java

示例9: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx) throws IOException {
    perSegCollector = new PerSegmentCollects(ctx);
    entries.add(perSegCollector);

    // Deferring collector
    return new LeafBucketCollector() {
        @Override
        public void setScorer(Scorer scorer) throws IOException {
            perSegCollector.setScorer(scorer);
        }

        @Override
        public void collect(int doc, long bucket) throws IOException {
            perSegCollector.collect(doc, bucket);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:BestDocsDeferringCollector.java

示例10: replayRelatedMatches

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
public void replayRelatedMatches(ScoreDoc[] sd) throws IOException {
    final LeafBucketCollector leafCollector = deferred.getLeafCollector(readerContext);
    leafCollector.setScorer(this);

    currentScore = 0;
    currentDocId = -1;
    if (maxDocId < 0) {
        return;
    }
    for (ScoreDoc scoreDoc : sd) {
        // Doc ids from TopDocCollector are root-level Reader so
        // need rebasing
        int rebased = scoreDoc.doc - readerContext.docBase;
        if ((rebased >= 0) && (rebased <= maxDocId)) {
            currentScore = scoreDoc.score;
            currentDocId = rebased;
            // We stored the bucket ID in Lucene's shardIndex property
            // for convenience.
            leafCollector.collect(rebased, scoreDoc.shardIndex);
        }
    }

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:BestDocsDeferringCollector.java

示例11: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx) throws IOException {
    finishLeaf();

    context = ctx;
    docDeltas = PackedLongValues.packedBuilder(PackedInts.DEFAULT);
    buckets = PackedLongValues.packedBuilder(PackedInts.DEFAULT);

    return new LeafBucketCollector() {
        int lastDoc = 0;

        @Override
        public void collect(int doc, long bucket) throws IOException {
            docDeltas.add(doc - lastDoc);
            buckets.add(bucket);
            lastDoc = doc;
            maxBucket = Math.max(maxBucket, bucket);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:BestBucketsDeferringCollector.java

示例12: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {

    final Bits docsWithValue;
    if (valuesSource != null) {
        docsWithValue = valuesSource.docsWithValue(ctx);
    } else {
        docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc());
    }
    return new LeafBucketCollectorBase(sub, docsWithValue) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (docsWithValue != null && !docsWithValue.get(doc)) {
                collectBucket(sub, doc, bucket);
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:MissingAggregator.java

示例13: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final LeafBucketCollector sub) throws IOException {
    // no need to provide deleted docs to the filter
    final Bits[] bits = new Bits[filters.length + totalNumIntersections];
    for (int i = 0; i < filters.length; ++i) {
        bits[i] = Lucene.asSequentialAccessBits(ctx.reader().maxDoc(), filters[i].scorer(ctx));
    }
    // Add extra Bits for intersections
    int pos = filters.length;
    for (int i = 0; i < filters.length; i++) {
        for (int j = i + 1; j < filters.length; j++) {
            bits[pos++] = new BitsIntersector(bits[i], bits[j]);
        }
    }
    assert pos == bits.length;
    return new LeafBucketCollectorBase(sub, null) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            for (int i = 0; i < bits.length; i++) {
                if (bits[i].get(doc)) {
                    collectBucket(sub, doc, bucketOrd(bucket, i));
                }
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:AdjacencyMatrixAggregator.java

示例14: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    // no need to provide deleted docs to the filter
    final Bits[] bits = new Bits[filters.length];
    for (int i = 0; i < filters.length; ++i) {
        bits[i] = Lucene.asSequentialAccessBits(ctx.reader().maxDoc(), filters[i].scorer(ctx));
    }
    return new LeafBucketCollectorBase(sub, null) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            boolean matched = false;
            for (int i = 0; i < bits.length; i++) {
                if (bits[i].get(doc)) {
                    collectBucket(sub, doc, bucketOrd(bucket, i));
                    matched = true;
                }
            }
            if (showOtherBucket && !matched) {
                collectBucket(sub, doc, bucketOrd(bucket, bits.length));
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:FiltersAggregator.java

示例15: getLeafCollector

import org.elasticsearch.search.aggregations.LeafBucketCollector; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {

    globalOrds = valuesSource.globalOrdinalsValues(ctx);

    if (acceptedGlobalOrdinals == null && includeExclude != null) {
        acceptedGlobalOrdinals = includeExclude.acceptedGlobalOrdinals(globalOrds, valuesSource);
    }

    if (acceptedGlobalOrdinals != null) {
        globalOrds = new FilteredOrdinals(globalOrds, acceptedGlobalOrdinals);
    }

    return newCollector(globalOrds, sub);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:GlobalOrdinalsStringTermsAggregator.java


注:本文中的org.elasticsearch.search.aggregations.LeafBucketCollector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。