Last active
December 27, 2015 01:49
-
-
Save jpountz/7247998 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Licensed to ElasticSearch and Shay Banon under one | |
| * or more contributor license agreements. See the NOTICE file | |
| * distributed with this work for additional information | |
| * regarding copyright ownership. ElasticSearch licenses this | |
| * file to you under the Apache License, Version 2.0 (the | |
| * "License"); you may not use this file except in compliance | |
| * with the License. You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, | |
| * software distributed under the License is distributed on an | |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| * KIND, either express or implied. See the License for the | |
| * specific language governing permissions and limitations | |
| * under the License. | |
| */ | |
| package org.elasticsearch.search.aggregations.calc; | |
| import org.elasticsearch.search.aggregations.Aggregator; | |
| import org.elasticsearch.search.aggregations.InternalAggregation; | |
| import org.elasticsearch.search.aggregations.context.AggregationContext; | |
| /** Base class for calc aggregators. These aggregators don't have children and are usually used to compute statistics about the matching documents. */ | |
| public abstract class CalcAggregator extends Aggregator { | |
| protected CalcAggregator(String name, AggregationContext context, Aggregator parent) { | |
| super(name, context, parent); | |
| } | |
| /** Create a new {@link CalcCollector} with a configured number of buckets. */ | |
| public abstract CalcCollector collector(long numBuckets); | |
| public static interface CalcCollector { | |
| /** Return the current capacity of this {@link CalcCollector}, which is the number of buckets that it can handle. */ | |
| long capacity(); | |
| /** Grow the collector so that it can handle the provided number of buckets. Data about existing buckets will be preserved. */ | |
| void grow(long numBuckets); | |
| /** Collect information about <code>doc</code> in the provided bucketId. <code>bucketId</code> must be in <code>[0, #capacity()]</code>. */ | |
| void collect(long bucketId, int doc); | |
| /** Called when collection is finished. */ | |
| void postCollection(); | |
| } | |
| /** Build aggregations */ | |
| public abstract InternalAggregation buildAggregation(long bucketId); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment