Skip to content

Remove generic on AggregatorFactory #43664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public MultiValueMode multiValueMode() {

@Override
protected MatrixStatsAggregatorFactory innerBuild(SearchContext context, Map<String, ValuesSourceConfig<Numeric>> configs,
AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
return new MatrixStatsAggregatorFactory(name, configs, multiValueMode, context, parent, subFactoriesBuilder, metaData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
import java.util.List;
import java.util.Map;

final class MatrixStatsAggregatorFactory
extends ArrayValuesSourceAggregatorFactory<ValuesSource.Numeric, MatrixStatsAggregatorFactory> {
final class MatrixStatsAggregatorFactory extends ArrayValuesSourceAggregatorFactory<ValuesSource.Numeric> {

private final MultiValueMode multiValueMode;

MatrixStatsAggregatorFactory(String name,
Map<String, ValuesSourceConfig<ValuesSource.Numeric>> configs, MultiValueMode multiValueMode,
SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder,
SearchContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder,
Map<String, Object> metaData) throws IOException {
super(name, configs, context, parent, subFactoriesBuilder, metaData);
this.multiValueMode = multiValueMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ public Map<String, Object> missingMap() {
}

@Override
protected final ArrayValuesSourceAggregatorFactory<VS, ?> doBuild(SearchContext context, AggregatorFactory<?> parent,
protected final ArrayValuesSourceAggregatorFactory<VS> doBuild(SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
Map<String, ValuesSourceConfig<VS>> configs = resolveConfig(context);
ArrayValuesSourceAggregatorFactory<VS, ?> factory = innerBuild(context, configs, parent, subFactoriesBuilder);
ArrayValuesSourceAggregatorFactory<VS> factory = innerBuild(context, configs, parent, subFactoriesBuilder);
return factory;
}

Expand All @@ -255,9 +255,9 @@ protected Map<String, ValuesSourceConfig<VS>> resolveConfig(SearchContext contex
return configs;
}

protected abstract ArrayValuesSourceAggregatorFactory<VS, ?> innerBuild(SearchContext context,
protected abstract ArrayValuesSourceAggregatorFactory<VS> innerBuild(SearchContext context,
Map<String, ValuesSourceConfig<VS>> configs,
AggregatorFactory<?> parent,
AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder) throws IOException;

public ValuesSourceConfig<VS> config(SearchContext context, String field, Script script) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import java.util.List;
import java.util.Map;

public abstract class ArrayValuesSourceAggregatorFactory<VS extends ValuesSource, AF extends ArrayValuesSourceAggregatorFactory<VS, AF>>
extends AggregatorFactory<AF> {
public abstract class ArrayValuesSourceAggregatorFactory<VS extends ValuesSource>
extends AggregatorFactory {

protected Map<String, ValuesSourceConfig<VS>> configs;

public ArrayValuesSourceAggregatorFactory(String name, Map<String, ValuesSourceConfig<VS>> configs,
SearchContext context, AggregatorFactory<?> parent,
SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder,
Map<String, Object> metaData) throws IOException {
super(name, context, parent, subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ protected void innerWriteTo(StreamOutput out) throws IOException {
}

@Override
protected ValuesSourceAggregatorFactory<WithOrdinals, ?> innerBuild(SearchContext context,
protected ValuesSourceAggregatorFactory<WithOrdinals> innerBuild(SearchContext context,
ValuesSourceConfig<WithOrdinals> config,
AggregatorFactory<?> parent,
AggregatorFactory parent,
Builder subFactoriesBuilder) throws IOException {
return new ChildrenAggregatorFactory(name, config, childFilter, parentFilter, context, parent,
subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.List;
import java.util.Map;

public class ChildrenAggregatorFactory extends ValuesSourceAggregatorFactory<WithOrdinals, ChildrenAggregatorFactory> {
public class ChildrenAggregatorFactory extends ValuesSourceAggregatorFactory<WithOrdinals> {

private final Query parentFilter;
private final Query childFilter;
Expand All @@ -45,7 +45,7 @@ public ChildrenAggregatorFactory(String name,
Query childFilter,
Query parentFilter,
SearchContext context,
AggregatorFactory<?> parent,
AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder,
Map<String, Object> metaData) throws IOException {
super(name, config, context, parent, subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ protected void innerWriteTo(StreamOutput out) throws IOException {
}

@Override
protected ValuesSourceAggregatorFactory<WithOrdinals, ?> innerBuild(SearchContext context,
protected ValuesSourceAggregatorFactory<WithOrdinals> innerBuild(SearchContext context,
ValuesSourceConfig<WithOrdinals> config,
AggregatorFactory<?> parent,
AggregatorFactory parent,
Builder subFactoriesBuilder) throws IOException {
return new ParentAggregatorFactory(name, config, childFilter, parentFilter, context, parent,
subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.List;
import java.util.Map;

public class ParentAggregatorFactory extends ValuesSourceAggregatorFactory<WithOrdinals, ParentAggregatorFactory> {
public class ParentAggregatorFactory extends ValuesSourceAggregatorFactory<WithOrdinals> {

private final Query parentFilter;
private final Query childFilter;
Expand All @@ -45,7 +45,7 @@ public ParentAggregatorFactory(String name,
Query childFilter,
Query parentFilter,
SearchContext context,
AggregatorFactory<?> parent,
AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder,
Map<String, Object> metaData) throws IOException {
super(name, config, context, parent, subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ public final String getWriteableName() {
}

@Override
public final AggregatorFactory<?> build(SearchContext context, AggregatorFactory<?> parent) throws IOException {
AggregatorFactory<?> factory = doBuild(context, parent, factoriesBuilder);
public final AggregatorFactory build(SearchContext context, AggregatorFactory parent) throws IOException {
AggregatorFactory factory = doBuild(context, parent, factoriesBuilder);
return factory;
}

protected abstract AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent,
protected abstract AggregatorFactory doBuild(SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subfactoriesBuilder) throws IOException;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public String getName() {
}

/** Internal: build an {@link AggregatorFactory} based on the configuration of this builder. */
protected abstract AggregatorFactory<?> build(SearchContext context, AggregatorFactory<?> parent) throws IOException;
protected abstract AggregatorFactory build(SearchContext context, AggregatorFactory parent) throws IOException;

/** Associate metadata with this {@link AggregationBuilder}. */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ public AggParseContext(String name) {
}
}

public static final AggregatorFactories EMPTY = new AggregatorFactories(new AggregatorFactory<?>[0], new ArrayList<>());
public static final AggregatorFactories EMPTY = new AggregatorFactories(new AggregatorFactory[0], new ArrayList<>());

private AggregatorFactory<?>[] factories;
private AggregatorFactory[] factories;
private List<PipelineAggregationBuilder> pipelineAggregatorFactories;

public static Builder builder() {
return new Builder();
}

private AggregatorFactories(AggregatorFactory<?>[] factories, List<PipelineAggregationBuilder> pipelineAggregators) {
private AggregatorFactories(AggregatorFactory[] factories, List<PipelineAggregationBuilder> pipelineAggregators) {
this.factories = factories;
this.pipelineAggregatorFactories = pipelineAggregators;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ Builder skipResolveOrder() {
return this;
}

public AggregatorFactories build(SearchContext context, AggregatorFactory<?> parent) throws IOException {
public AggregatorFactories build(SearchContext context, AggregatorFactory parent) throws IOException {
if (aggregationBuilders.isEmpty() && pipelineAggregatorBuilders.isEmpty()) {
return EMPTY;
}
Expand All @@ -325,7 +325,7 @@ public AggregatorFactories build(SearchContext context, AggregatorFactory<?> par
orderedpipelineAggregators = resolvePipelineAggregatorOrder(this.pipelineAggregatorBuilders, this.aggregationBuilders,
parent);
}
AggregatorFactory<?>[] aggFactories = new AggregatorFactory<?>[aggregationBuilders.size()];
AggregatorFactory[] aggFactories = new AggregatorFactory[aggregationBuilders.size()];

int i = 0;
for (AggregationBuilder agg : aggregationBuilders) {
Expand All @@ -337,7 +337,7 @@ public AggregatorFactories build(SearchContext context, AggregatorFactory<?> par

private List<PipelineAggregationBuilder> resolvePipelineAggregatorOrder(
Collection<PipelineAggregationBuilder> pipelineAggregatorBuilders, Collection<AggregationBuilder> aggregationBuilders,
AggregatorFactory<?> parent) {
AggregatorFactory parent) {
Map<String, PipelineAggregationBuilder> pipelineAggregatorBuildersMap = new HashMap<>();
for (PipelineAggregationBuilder builder : pipelineAggregatorBuilders) {
pipelineAggregatorBuildersMap.put(builder.getName(), builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
import java.util.List;
import java.util.Map;

public abstract class AggregatorFactory<AF extends AggregatorFactory<AF>> {
public abstract class AggregatorFactory {

public static final class MultiBucketAggregatorWrapper extends Aggregator {
private final BigArrays bigArrays;
private final Aggregator parent;
private final AggregatorFactory<?> factory;
private final AggregatorFactory factory;
private final Aggregator first;
ObjectArray<Aggregator> aggregators;
ObjectArray<LeafBucketCollector> collectors;

MultiBucketAggregatorWrapper(BigArrays bigArrays, SearchContext context, Aggregator parent, AggregatorFactory<?> factory,
MultiBucketAggregatorWrapper(BigArrays bigArrays, SearchContext context, Aggregator parent, AggregatorFactory factory,
Aggregator first) {
this.bigArrays = bigArrays;
this.parent = parent;
Expand Down Expand Up @@ -167,7 +167,7 @@ public void close() {
}

protected final String name;
protected final AggregatorFactory<?> parent;
protected final AggregatorFactory parent;
protected final AggregatorFactories factories;
protected final Map<String, Object> metaData;
protected final SearchContext context;
Expand All @@ -180,7 +180,7 @@ public void close() {
* @throws IOException
* if an error occurs creating the factory
*/
public AggregatorFactory(String name, SearchContext context, AggregatorFactory<?> parent,
public AggregatorFactory(String name, SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
this.name = name;
this.context = context;
Expand Down Expand Up @@ -217,7 +217,7 @@ public final Aggregator create(Aggregator parent, boolean collectsFromSingleBuck
return createInternal(parent, collectsFromSingleBucket, this.factories.createPipelineAggregators(), this.metaData);
}

public AggregatorFactory<?> getParent() {
public AggregatorFactory getParent() {
return parent;
}

Expand All @@ -226,7 +226,7 @@ public AggregatorFactory<?> getParent() {
* {@link Aggregator}s that only know how to collect bucket {@code 0}, this
* returns an aggregator that can collect any bucket.
*/
protected static Aggregator asMultiBucketAggregator(final AggregatorFactory<?> factory, final SearchContext context,
protected static Aggregator asMultiBucketAggregator(final AggregatorFactory factory, final SearchContext context,
final Aggregator parent) throws IOException {
final Aggregator first = factory.create(parent, true);
final BigArrays bigArrays = context.bigArrays();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final String[] getBucketsPaths() {
* Internal: Validates the state of this factory (makes sure the factory is properly
* configured)
*/
protected abstract void validate(AggregatorFactory<?> parent, Collection<AggregationBuilder> aggregationBuilders,
protected abstract void validate(AggregatorFactory parent, Collection<AggregationBuilder> aggregationBuilders,
Collection<PipelineAggregationBuilder> pipelineAggregatorBuilders);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public Map<String, QueryBuilder> filters() {


@Override
protected AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent, Builder subFactoriesBuilder)
protected AggregatorFactory doBuild(SearchContext context, AggregatorFactory parent, Builder subFactoriesBuilder)
throws IOException {
int maxFilters = context.indexShard().indexSettings().getMaxAdjacencyMatrixFilters();
if (filters.size() > maxFilters){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
import java.util.List;
import java.util.Map;

public class AdjacencyMatrixAggregatorFactory extends AggregatorFactory<AdjacencyMatrixAggregatorFactory> {
public class AdjacencyMatrixAggregatorFactory extends AggregatorFactory {

private final String[] keys;
private final Weight[] weights;
private final String separator;

public AdjacencyMatrixAggregatorFactory(String name, List<KeyedFilter> filters, String separator,
SearchContext context, AggregatorFactory<?> parent, AggregatorFactories.Builder subFactories,
SearchContext context, AggregatorFactory parent, AggregatorFactories.Builder subFactories,
Map<String, Object> metaData) throws IOException {
super(name, context, parent, subFactories, metaData);
IndexSearcher contextSearcher = context.searcher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public int size() {
* this aggregator or the instance of the parent's factory that is incompatible with
* the composite aggregation.
*/
private AggregatorFactory<?> checkParentIsNullOrNested(AggregatorFactory<?> factory) {
private AggregatorFactory checkParentIsNullOrNested(AggregatorFactory factory) {
if (factory == null) {
return null;
} else if (factory instanceof NestedAggregatorFactory) {
Expand Down Expand Up @@ -195,9 +195,9 @@ private static void validateSources(List<CompositeValuesSourceBuilder<?>> source
}

@Override
protected AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent,
protected AggregatorFactory doBuild(SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subfactoriesBuilder) throws IOException {
AggregatorFactory<?> invalid = checkParentIsNullOrNested(parent);
AggregatorFactory invalid = checkParentIsNullOrNested(parent);
if (invalid != null) {
throw new IllegalArgumentException("[composite] aggregation cannot be used with a parent aggregation of" +
" type: [" + invalid.getClass().getSimpleName() + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import java.util.List;
import java.util.Map;

class CompositeAggregationFactory extends AggregatorFactory<CompositeAggregationFactory> {
class CompositeAggregationFactory extends AggregatorFactory {
private final int size;
private final CompositeValuesSourceConfig[] sources;
private final CompositeKey afterKey;

CompositeAggregationFactory(String name, SearchContext context, AggregatorFactory<?> parent,
CompositeAggregationFactory(String name, SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData,
int size, CompositeValuesSourceConfig[] sources, CompositeKey afterKey) throws IOException {
super(name, context, parent, subFactoriesBuilder, metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected AggregationBuilder doRewrite(QueryRewriteContext queryShardContext) th
}

@Override
protected AggregatorFactory<?> doBuild(SearchContext context, AggregatorFactory<?> parent,
protected AggregatorFactory doBuild(SearchContext context, AggregatorFactory parent,
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
return new FilterAggregatorFactory(name, filter, context, parent, subFactoriesBuilder, metaData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
import java.util.List;
import java.util.Map;

public class FilterAggregatorFactory extends AggregatorFactory<FilterAggregatorFactory> {
public class FilterAggregatorFactory extends AggregatorFactory {

private Weight weight;
private Query filter;

public FilterAggregatorFactory(String name, QueryBuilder filterBuilder, SearchContext context,
AggregatorFactory<?> parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder, Map<String, Object> metaData) throws IOException {
super(name, context, parent, subFactoriesBuilder, metaData);
filter = filterBuilder.toQuery(context.getQueryShardContext());
}
Expand Down
Loading