Skip to content

Commit

Permalink
Aggregations Refactor: Refactor Global Aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
colings86 committed Nov 16, 2015
1 parent 7e316ba commit 43d96d4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package org.elasticsearch.search.aggregations.bucket.global;

import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.aggregations.AggregationExecutionException;
import org.elasticsearch.search.aggregations.Aggregator;
import org.elasticsearch.search.aggregations.AggregatorFactories;
Expand Down Expand Up @@ -87,5 +90,32 @@ public Aggregator createInternal(AggregationContext context, Aggregator parent,
return new GlobalAggregator(name, factories, context, pipelineAggregators, metaData);
}

@Override
protected AggregatorFactory doReadFrom(String name, StreamInput in) throws IOException {
return new Factory(name);
}

@Override
protected void doWriteTo(StreamOutput out) throws IOException {
// Nothing to write
}

@Override
protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.endObject();
return builder;
}

@Override
protected boolean doEquals(Object obj) {
return true;
}

@Override
protected int doHashCode() {
return 0;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se
return new GlobalAggregator.Factory(aggregationName);
}

// NORELEASE implement this method when refactoring this aggregation
@Override
public AggregatorFactory getFactoryPrototype() {
return null;
return new GlobalAggregator.Factory(null);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Elasticsearch 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.bucket;

import org.elasticsearch.search.aggregations.BaseAggregationTestCase;
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregator;
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregator.Factory;

public class GlobalTests extends BaseAggregationTestCase<GlobalAggregator.Factory> {

@Override
protected Factory createTestAggregatorFactory() {
return new GlobalAggregator.Factory(randomAsciiOfLengthBetween(3, 20));
}

}

0 comments on commit 43d96d4

Please sign in to comment.