Skip to content

Commit

Permalink
HSEARCH-5133 Remove long/double metric aggregation builder
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever committed Jun 25, 2024
1 parent 5655213 commit 34889d6
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexValueFieldContext;
import org.hibernate.search.backend.elasticsearch.types.codec.impl.ElasticsearchDoubleFieldCodec;
import org.hibernate.search.backend.elasticsearch.types.codec.impl.ElasticsearchFieldCodec;
import org.hibernate.search.engine.search.aggregation.spi.MetricDoubleAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -42,7 +42,7 @@ protected Extractor<Double> extractor(AggregationRequestContext context) {

public static class Factory<F>
extends
AbstractElasticsearchCodecAwareSearchQueryElementFactory<MetricDoubleAggregationBuilder, F> {
AbstractElasticsearchCodecAwareSearchQueryElementFactory<SearchAggregationFilteredBuilder<Double>, F> {

private final String operation;

Expand All @@ -52,7 +52,7 @@ public Factory(ElasticsearchFieldCodec<F> codec, String operation) {
}

@Override
public MetricDoubleAggregationBuilder create(ElasticsearchSearchIndexScope<?> scope,
public SearchAggregationFilteredBuilder<Double> create(ElasticsearchSearchIndexScope<?> scope,
ElasticsearchSearchIndexValueFieldContext<F> field) {
return new Builder( scope, field, operation );
}
Expand All @@ -66,7 +66,7 @@ public Double extract(JsonObject aggregationResult, AggregationExtractContext co
}
}

private static class Builder extends AbstractBuilder<Double> implements MetricDoubleAggregationBuilder {
private static class Builder extends AbstractBuilder<Double> implements SearchAggregationFilteredBuilder<Double> {
private final String operation;

private Builder(ElasticsearchSearchIndexScope<?> scope, ElasticsearchSearchIndexValueFieldContext<?> field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexValueFieldContext;
import org.hibernate.search.backend.elasticsearch.types.codec.impl.ElasticsearchFieldCodec;
import org.hibernate.search.backend.elasticsearch.types.codec.impl.ElasticsearchLongFieldCodec;
import org.hibernate.search.engine.search.aggregation.spi.MetricLongAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -42,7 +42,7 @@ protected Extractor<Long> extractor(AggregationRequestContext context) {

public static class Factory<F>
extends
AbstractElasticsearchCodecAwareSearchQueryElementFactory<MetricLongAggregationBuilder, F> {
AbstractElasticsearchCodecAwareSearchQueryElementFactory<SearchAggregationFilteredBuilder<Long>, F> {

private final String operation;

Expand All @@ -52,7 +52,7 @@ public Factory(ElasticsearchFieldCodec<F> codec, String operation) {
}

@Override
public MetricLongAggregationBuilder create(ElasticsearchSearchIndexScope<?> scope,
public SearchAggregationFilteredBuilder<Long> create(ElasticsearchSearchIndexScope<?> scope,
ElasticsearchSearchIndexValueFieldContext<F> field) {
return new Builder( scope, field, operation );
}
Expand All @@ -66,7 +66,7 @@ public Long extract(JsonObject aggregationResult, AggregationExtractContext cont
}
}

private static class Builder extends AbstractBuilder<Long> implements MetricLongAggregationBuilder {
private static class Builder extends AbstractBuilder<Long> implements SearchAggregationFilteredBuilder<Long> {
private final String operation;

private Builder(ElasticsearchSearchIndexScope<?> scope, ElasticsearchSearchIndexValueFieldContext<?> field,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.hibernate.search.engine.search.aggregation.dsl.AvgAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.AggregationTypeKeys;
import org.hibernate.search.engine.search.aggregation.spi.MetricDoubleAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

public class AvgAggregationFieldStepImpl<PDF extends SearchPredicateFactory>
Expand All @@ -21,7 +21,7 @@ public AvgAggregationFieldStepImpl(SearchAggregationDslContext<?, ? extends PDF>

@Override
public AvgAggregationOptionsStep<?, PDF> field(String fieldPath) {
MetricDoubleAggregationBuilder builder = dslContext.scope()
SearchAggregationFilteredBuilder<Double> builder = dslContext.scope()
.fieldQueryElement( fieldPath, AggregationTypeKeys.AVG );
return new AvgAggregationOptionsStepImpl<>( builder, dslContext );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import org.hibernate.search.engine.search.aggregation.SearchAggregation;
import org.hibernate.search.engine.search.aggregation.dsl.AvgAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.MetricDoubleAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

class AvgAggregationOptionsStepImpl<PDF extends SearchPredicateFactory>
implements AvgAggregationOptionsStep<AvgAggregationOptionsStepImpl<PDF>, PDF> {
private final MetricDoubleAggregationBuilder builder;
private final SearchAggregationFilteredBuilder<Double> builder;
private final SearchAggregationDslContext<?, ? extends PDF> dslContext;

AvgAggregationOptionsStepImpl(MetricDoubleAggregationBuilder builder,
AvgAggregationOptionsStepImpl(SearchAggregationFilteredBuilder<Double> builder,
SearchAggregationDslContext<?, ? extends PDF> dslContext) {
this.builder = builder;
this.dslContext = dslContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.hibernate.search.engine.search.aggregation.dsl.CountAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.AggregationTypeKeys;
import org.hibernate.search.engine.search.aggregation.spi.MetricLongAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

public class CountAggregationFieldStepImpl<PDF extends SearchPredicateFactory>
Expand All @@ -21,7 +21,7 @@ public CountAggregationFieldStepImpl(SearchAggregationDslContext<?, ? extends PD

@Override
public CountAggregationOptionsStep<?, PDF> field(String fieldPath) {
MetricLongAggregationBuilder builder = dslContext.scope()
SearchAggregationFilteredBuilder<Long> builder = dslContext.scope()
.fieldQueryElement( fieldPath, AggregationTypeKeys.COUNT );
return new CountAggregationOptionsStepImpl<>( builder, dslContext );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import org.hibernate.search.engine.search.aggregation.SearchAggregation;
import org.hibernate.search.engine.search.aggregation.dsl.CountAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.MetricLongAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

class CountAggregationOptionsStepImpl<PDF extends SearchPredicateFactory>
implements CountAggregationOptionsStep<CountAggregationOptionsStepImpl<PDF>, PDF> {
private final MetricLongAggregationBuilder builder;
private final SearchAggregationFilteredBuilder<Long> builder;
private final SearchAggregationDslContext<?, ? extends PDF> dslContext;

CountAggregationOptionsStepImpl(MetricLongAggregationBuilder builder,
CountAggregationOptionsStepImpl(SearchAggregationFilteredBuilder<Long> builder,
SearchAggregationDslContext<?, ? extends PDF> dslContext) {
this.builder = builder;
this.dslContext = dslContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.hibernate.search.engine.search.aggregation.dsl.CountDistinctAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.AggregationTypeKeys;
import org.hibernate.search.engine.search.aggregation.spi.MetricLongAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

public class CountDistinctAggregationFieldStepImpl<PDF extends SearchPredicateFactory>
Expand All @@ -21,7 +21,7 @@ public CountDistinctAggregationFieldStepImpl(SearchAggregationDslContext<?, ? ex

@Override
public CountDistinctAggregationOptionsStep<?, PDF> field(String fieldPath) {
MetricLongAggregationBuilder builder = dslContext.scope()
SearchAggregationFilteredBuilder<Long> builder = dslContext.scope()
.fieldQueryElement( fieldPath, AggregationTypeKeys.COUNT_DISTINCT );
return new CountDistinctAggregationOptionsStepImpl<>( builder, dslContext );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import org.hibernate.search.engine.search.aggregation.SearchAggregation;
import org.hibernate.search.engine.search.aggregation.dsl.CountDistinctAggregationOptionsStep;
import org.hibernate.search.engine.search.aggregation.dsl.spi.SearchAggregationDslContext;
import org.hibernate.search.engine.search.aggregation.spi.MetricLongAggregationBuilder;
import org.hibernate.search.engine.search.aggregation.spi.SearchAggregationFilteredBuilder;
import org.hibernate.search.engine.search.predicate.SearchPredicate;
import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep;
import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory;

class CountDistinctAggregationOptionsStepImpl<PDF extends SearchPredicateFactory>
implements CountDistinctAggregationOptionsStep<CountDistinctAggregationOptionsStepImpl<PDF>, PDF> {
private final MetricLongAggregationBuilder builder;
private final SearchAggregationFilteredBuilder<Long> builder;
private final SearchAggregationDslContext<?, ? extends PDF> dslContext;

CountDistinctAggregationOptionsStepImpl(MetricLongAggregationBuilder builder,
CountDistinctAggregationOptionsStepImpl(SearchAggregationFilteredBuilder<Long> builder,
SearchAggregationDslContext<?, ? extends PDF> dslContext) {
this.builder = builder;
this.dslContext = dslContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ private AggregationTypeKeys() {
of( IndexFieldTraits.Aggregations.MIN );
public static final SearchQueryElementTypeKey<MetricFieldAggregationBuilder.TypeSelector> MAX =
of( IndexFieldTraits.Aggregations.MAX );
public static final SearchQueryElementTypeKey<MetricLongAggregationBuilder> COUNT =
public static final SearchQueryElementTypeKey<SearchAggregationFilteredBuilder<Long>> COUNT =
of( IndexFieldTraits.Aggregations.COUNT );
public static final SearchQueryElementTypeKey<MetricLongAggregationBuilder> COUNT_DISTINCT =
public static final SearchQueryElementTypeKey<SearchAggregationFilteredBuilder<Long>> COUNT_DISTINCT =
of( IndexFieldTraits.Aggregations.COUNT_DISTINCT );
public static final SearchQueryElementTypeKey<MetricDoubleAggregationBuilder> AVG =
public static final SearchQueryElementTypeKey<SearchAggregationFilteredBuilder<Double>> AVG =
of( IndexFieldTraits.Aggregations.AVG );

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.hibernate.search.engine.search.predicate.SearchPredicate;

public interface MetricDoubleAggregationBuilder extends SearchAggregationBuilder<Double> {
public interface SearchAggregationFilteredBuilder<A> extends SearchAggregationBuilder<A> {

void filter(SearchPredicate filter);

Expand Down

0 comments on commit 34889d6

Please sign in to comment.