From 32db920fd9569626444d5d80f2ef6b0acba0b8e6 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Mon, 11 Nov 2024 17:45:29 +0100 Subject: [PATCH] HSEARCH-4577 Rename to ProjectionCollector --- .../elasticsearch/logging/impl/Log.java | 6 +- .../impl/ElasticsearchSearchHighlighter.java | 4 +- .../ElasticsearchSearchHighlighterImpl.java | 8 +-- .../impl/AccumulatingSourceExtractor.java | 16 ++--- .../ElasticsearchCompositeProjection.java | 28 ++++----- ...lasticsearchDistanceToFieldProjection.java | 30 +++++----- ...ElasticsearchFieldHighlightProjection.java | 32 +++++----- .../impl/ElasticsearchFieldProjection.java | 35 +++++------ .../impl/ElasticsearchObjectProjection.java | 34 +++++------ .../impl/ProjectionRequestRootContext.java | 4 +- ...lasticsearchSearchQuerySelectStepImpl.java | 4 +- ...lasticsearchSearchQueryRequestContext.java | 12 ++-- .../backend/lucene/logging/impl/Log.java | 6 +- .../impl/LuceneAbstractSearchHighlighter.java | 6 +- .../LuceneFastVectorSearchHighlighter.java | 11 ++-- .../impl/LucenePlainSearchHighlighter.java | 10 ++-- .../impl/LuceneUnifiedSearchHighlighter.java | 10 ++-- ...bstractNestingAwareAccumulatingValues.java | 10 ++-- .../impl/LuceneCompositeProjection.java | 28 ++++----- .../impl/LuceneDistanceToFieldProjection.java | 36 +++++------ .../impl/LuceneFieldHighlightProjection.java | 36 +++++------ .../impl/LuceneFieldProjection.java | 44 +++++++------- .../impl/LuceneObjectProjection.java | 40 ++++++------- .../impl/LuceneSearchQuerySelectStepImpl.java | 4 +- .../src/main/asciidoc/migration/index.adoc | 4 +- .../public/reference/_binding-projection.adoc | 16 ++--- .../public/reference/_mapping-projection.adoc | 12 ++-- .../reference/_search-dsl-projection.adoc | 8 +-- .../multi/MyFieldProjectionBinder.java | 4 +- .../ProjectionConstructorMappingJava17IT.java | 4 +- .../search/projection/ProjectionDslIT.java | 16 ++--- .../projection/ProjectionDslJava17IT.java | 4 +- ...umulator.java => ProjectionCollector.java} | 50 ++++++++-------- ...> ProjectionCollectorProviderFactory.java} | 14 ++--- .../spi/ConstantProjectionDefinition.java | 16 ++--- .../spi/DistanceProjectionDefinition.java | 14 ++--- .../spi/FieldProjectionDefinition.java | 14 ++--- .../spi/ObjectProjectionDefinition.java | 14 ++--- .../dsl/CompositeProjectionValueStep.java | 33 +++++----- .../DistanceToFieldProjectionValueStep.java | 33 +++++----- .../dsl/FieldProjectionValueStep.java | 33 +++++----- .../dsl/HighlightProjectionOptionsStep.java | 25 ++++---- .../dsl/SearchProjectionFactory.java | 6 +- .../CompositeProjectionOptionsStepImpl.java | 10 ++-- .../CompositeProjectionValueStepImpl.java | 8 +-- ...tanceToFieldProjectionOptionsStepImpl.java | 10 ++-- ...istanceToFieldProjectionValueStepImpl.java | 9 +-- .../impl/FieldProjectionOptionsStepImpl.java | 10 ++-- .../impl/FieldProjectionValueStepImpl.java | 8 +-- .../HighlightProjectionOptionsStepImpl.java | 24 ++++---- .../dsl/spi/HighlightProjectionBuilder.java | 4 +- ...tor.java => ArrayProjectionCollector.java} | 16 ++--- ... BaseSingleValuedProjectionCollector.java} | 9 +-- .../spi/BuiltInProjectionAccumulators.java | 58 ------------------ .../spi/BuiltInProjectionCollectors.java | 60 +++++++++++++++++++ .../spi/CompositeProjectionBuilder.java | 4 +- .../spi/DistanceToFieldProjectionBuilder.java | 6 +- .../spi/FieldProjectionBuilder.java | 6 +- ...java => ListBasedProjectionCollector.java} | 10 ++-- .../spi/ListProjectionAccumulator.java | 6 +- ....java => OptionalProjectionCollector.java} | 12 ++-- .../projection/spi/ProjectionAccumulator.java | 16 ++++- ...lator.java => SetProjectionCollector.java} | 12 ++-- ...or.java => SimpleProjectionCollector.java} | 14 ++--- .../SingleValuedProjectionAccumulator.java | 5 +- ...rtedSetComparatorProjectionCollector.java} | 16 ++--- ...java => SortedSetProjectionCollector.java} | 16 ++--- .../impl/DefaultSearchQuerySelectStep.java | 4 +- .../ElasticsearchExtensionIT.java | 8 +-- .../util/ElasticsearchTckBackendFeatures.java | 10 ++-- .../backend/lucene/LuceneExtensionIT.java | 12 ++-- .../predicate/KnnPredicateSpecificsIT.java | 4 +- .../AbstractCompositeProjectionFromAsIT.java | 10 ++-- ...bstractProjectionInObjectProjectionIT.java | 26 ++++---- .../projection/DistanceProjectionBaseIT.java | 4 +- ...rojectionMultiValuedAccumulatorBaseIT.java | 6 +- ...eProjectionParameterMultiValuedBaseIT.java | 6 +- ...ProjectionParameterSingleValuedBaseIT.java | 4 +- .../DistanceProjectionSingleValuedBaseIT.java | 8 +-- ...ProjectionTypeCheckingAndConversionIT.java | 6 +- .../search/projection/EntityProjectionIT.java | 4 +- .../projection/FieldProjectionBaseIT.java | 4 +- ...ProjectionTypeCheckingAndConversionIT.java | 6 +- .../ObjectProjectionSpecificsIT.java | 12 ++-- .../UnsupportedNestingProjectionBaseIT.java | 12 ++-- .../testsupport/util/TckBackendFeatures.java | 6 +- ...rojectionConstructorFieldProjectionIT.java | 18 +++--- ...ctionConstructorHighlightProjectionIT.java | 4 +- .../ProjectionConstructorInnerInferredIT.java | 26 ++++---- ...ojectionConstructorObjectProjectionIT.java | 10 ++-- .../search/mapper/pojo/logging/impl/Log.java | 2 +- .../binding/ProjectionBindingContext.java | 16 ++--- .../builtin/DistanceProjectionBinder.java | 14 ++--- .../builtin/FieldProjectionBinder.java | 8 +-- .../builtin/HighlightProjectionBinder.java | 18 +++--- .../builtin/ObjectProjectionBinder.java | 8 +-- .../impl/ProjectionBindingContextImpl.java | 38 ++++++------ .../impl/StubCompositeProjection.java | 30 +++++----- .../impl/StubDistanceToFieldProjection.java | 4 +- .../impl/StubFieldHighlightProjection.java | 14 ++--- .../projection/impl/StubFieldProjection.java | 22 +++---- .../projection/impl/StubObjectProjection.java | 10 ++-- 102 files changed, 776 insertions(+), 741 deletions(-) rename engine/src/main/java/org/hibernate/search/engine/search/projection/{ProjectionAccumulator.java => ProjectionCollector.java} (81%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/{ProjectionAccumulatorProviderFactory.java => ProjectionCollectorProviderFactory.java} (51%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{ArrayProjectionAccumulator.java => ArrayProjectionCollector.java} (65%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{BaseSingleValuedProjectionAccumulator.java => BaseSingleValuedProjectionCollector.java} (83%) delete mode 100644 engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionAccumulators.java create mode 100644 engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionCollectors.java rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{ListBasedProjectionAccumulator.java => ListBasedProjectionCollector.java} (85%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{OptionalProjectionAccumulator.java => OptionalProjectionCollector.java} (60%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{SetProjectionAccumulator.java => SetProjectionCollector.java} (63%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{SimpleProjectionAccumulator.java => SimpleProjectionCollector.java} (64%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{SortedSetComparatorProjectionAccumulator.java => SortedSetComparatorProjectionCollector.java} (61%) rename engine/src/main/java/org/hibernate/search/engine/search/projection/spi/{SortedSetProjectionAccumulator.java => SortedSetProjectionCollector.java} (50%) diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/logging/impl/Log.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/logging/impl/Log.java index 36420c4cf0d..a8bd51d8861 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/logging/impl/Log.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/logging/impl/Log.java @@ -602,7 +602,7 @@ SearchException invalidFieldValueType(@FormatWith(ClassFormatter.class) Class @Message(id = ID_OFFSET + 113, value = "Invalid cardinality for projection on field '%1$s': the projection is single-valued," + " but this field is multi-valued." - + " Make sure to call '.accumulator(...)' when you create the projection.") + + " Make sure to call '.collector(...)' when you create the projection.") SearchException invalidSingleValuedProjectionOnMultiValuedField(String absolutePath, @Param EventContext context); @Message(id = ID_OFFSET + 117, @@ -732,9 +732,9 @@ SearchException invalidContextForProjectionOnField(String absolutePath, value = "Invalid cardinality for projection on field '%1$s': the projection is single-valued," + " but this field is effectively multi-valued in this context," + " because parent object field '%2$s' is multi-valued." - + " Either call '.accumulator(...)' when you create the projection on field '%1$s'," + + " Either call '.collector(...)' when you create the projection on field '%1$s'," + " or wrap that projection in an object projection like this:" - + " 'f.object(\"%2$s\").from().as(...).accumulator(...)'.") + + " 'f.object(\"%2$s\").from().as(...).collector(...)'.") SearchException invalidSingleValuedProjectionOnValueFieldInMultiValuedObjectField(String absolutePath, String objectFieldAbsolutePath); diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighter.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighter.java index 6d59e61d999..76b46c8ce91 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighter.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighter.java @@ -14,7 +14,7 @@ import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexScope; import org.hibernate.search.engine.search.highlighter.SearchHighlighter; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.logging.impl.LoggerFactory; import com.google.gson.JsonObject; @@ -31,7 +31,7 @@ public interface ElasticsearchSearchHighlighter extends SearchHighlighter { SearchHighlighterType type(); - boolean isCompatible(ProjectionAccumulator.Provider accumulatorProvider); + boolean isCompatible(ProjectionCollector.Provider collectorProvider); static ElasticsearchSearchHighlighter from(ElasticsearchSearchIndexScope scope, SearchHighlighter highlighter) { if ( !( highlighter instanceof ElasticsearchSearchHighlighter ) ) { diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighterImpl.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighterImpl.java index 3185f200549..edf56f0a129 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighterImpl.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/highlighter/impl/ElasticsearchSearchHighlighterImpl.java @@ -21,7 +21,7 @@ import org.hibernate.search.engine.search.highlighter.spi.BoundaryScannerType; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterBuilder; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -143,9 +143,9 @@ public SearchHighlighterType type() { } @Override - public boolean isCompatible(ProjectionAccumulator.Provider provider) { - return !provider.isSingleValued() - || ( provider.isSingleValued() && ( numberOfFragments != null && numberOfFragments.equals( 1 ) ) ); + public boolean isCompatible(ProjectionCollector.Provider collectorProvider) { + return !collectorProvider.isSingleValued() + || ( collectorProvider.isSingleValued() && ( numberOfFragments != null && numberOfFragments.equals( 1 ) ) ); } private JsonObject toJson(JsonObject result) { diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/AccumulatingSourceExtractor.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/AccumulatingSourceExtractor.java index c5c0bc7db4e..471d2432dea 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/AccumulatingSourceExtractor.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/AccumulatingSourceExtractor.java @@ -12,7 +12,7 @@ import org.hibernate.search.backend.elasticsearch.gson.impl.JsonElementTypes; import org.hibernate.search.backend.elasticsearch.gson.impl.UnexpectedJsonElementTypeException; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -24,18 +24,18 @@ abstract class AccumulatingSourceExtractor JsonAccessor.root().property( "_source" ).asArray(); private final String[] fieldPathComponents; - final ProjectionAccumulator accumulator; + final ProjectionCollector collector; public AccumulatingSourceExtractor(String[] fieldPathComponents, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { this.fieldPathComponents = fieldPathComponents; - this.accumulator = accumulator; + this.collector = collector; } @Override public final A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, JsonObject source, ProjectionExtractContext context) { - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); accumulated = collect( projectionHitMapper, hit, source, context, accumulated, 0 ); return accumulated; } @@ -83,17 +83,17 @@ private A collectTargetField(ProjectionHitMapper projectionHitMapper, JsonObj } else if ( fieldValue.isJsonNull() ) { // Present, but null - return accumulator.accumulate( accumulated, extract( projectionHitMapper, hit, fieldValue, context ) ); + return collector.accumulate( accumulated, extract( projectionHitMapper, hit, fieldValue, context ) ); } else if ( !canDecodeArrays() && fieldValue.isJsonArray() ) { for ( JsonElement childElement : fieldValue.getAsJsonArray() ) { - accumulated = accumulator.accumulate( accumulated, + accumulated = collector.accumulate( accumulated, extract( projectionHitMapper, hit, childElement, context ) ); } return accumulated; } else { - return accumulator.accumulate( accumulated, extract( projectionHitMapper, hit, fieldValue, context ) ); + return collector.accumulate( accumulated, extract( projectionHitMapper, hit, fieldValue, context ) ); } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchCompositeProjection.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchCompositeProjection.java index fd46b5b1967..065c138a5d2 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchCompositeProjection.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchCompositeProjection.java @@ -9,7 +9,7 @@ import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexScope; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -31,14 +31,14 @@ class ElasticsearchCompositeProjection private final ElasticsearchSearchProjection[] inners; private final ProjectionCompositor compositor; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; public ElasticsearchCompositeProjection(Builder builder, ElasticsearchSearchProjection[] inners, - ProjectionCompositor compositor, ProjectionAccumulator accumulator) { + ProjectionCompositor compositor, ProjectionCollector collector) { super( builder.scope ); this.inners = inners; this.compositor = compositor; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -46,7 +46,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -71,21 +71,21 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @Override public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, JsonObject source, ProjectionExtractContext context) { - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); E components = compositor.createInitial(); for ( int i = 0; i < inners.length; i++ ) { Object extractedDataForInner = inners[i].extract( projectionHitMapper, hit, source, context ); components = compositor.set( components, i, extractedDataForInner ); } - accumulated = accumulator.accumulate( accumulated, components ); + accumulated = collector.accumulate( accumulated, components ); return accumulated; } @@ -93,8 +93,8 @@ public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, @Override public final P transform(LoadingResult loadingResult, A accumulated, ProjectionTransformContext context) { - for ( int i = 0; i < accumulator.size( accumulated ); i++ ) { - E transformedData = accumulator.get( accumulated, i ); + for ( int i = 0; i < collector.size( accumulated ); i++ ) { + E transformedData = collector.get( accumulated, i ); // Transform in-place for ( int j = 0; j < inners.length; j++ ) { Object extractedDataForInner = compositor.get( transformedData, j ); @@ -103,9 +103,9 @@ public final P transform(LoadingResult loadingResult, A accumulated, transformedData = compositor.set( transformedData, j, transformedDataForInner ); } - accumulated = accumulator.transform( accumulated, i, compositor.finish( transformedData ) ); + accumulated = collector.transform( accumulated, i, compositor.finish( transformedData ) ); } - return accumulator.finish( accumulated ); + return collector.finish( accumulated ); } } @@ -119,14 +119,14 @@ static class Builder implements CompositeProjectionBuilder { @Override public SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { ElasticsearchSearchProjection[] typedInners = new ElasticsearchSearchProjection[inners.length]; for ( int i = 0; i < inners.length; i++ ) { typedInners[i] = ElasticsearchSearchProjection.from( scope, inners[i] ); } return new ElasticsearchCompositeProjection<>( this, typedInners, - compositor, accumulatorProvider.get() ); + compositor, collectorProvider.get() ); } } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchDistanceToFieldProjection.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchDistanceToFieldProjection.java index 0287b9c4aa4..79a9920256e 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchDistanceToFieldProjection.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchDistanceToFieldProjection.java @@ -18,7 +18,7 @@ import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.DistanceToFieldProjectionBuilder; import org.hibernate.search.engine.spatial.DistanceUnit; @@ -62,14 +62,14 @@ public class ElasticsearchDistanceToFieldProjection extends AbstractElasti private final GeoPoint center; private final DistanceUnit unit; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private final String scriptFieldName; private final ElasticsearchFieldProjection sourceProjection; private ElasticsearchDistanceToFieldProjection(Builder builder, - ProjectionAccumulator.Provider accumulatorProvider, - ProjectionAccumulator accumulator) { + ProjectionCollector.Provider collectorProvider, + ProjectionCollector collector) { super( builder ); this.codec = builder.field.type().codec(); @@ -77,7 +77,7 @@ private ElasticsearchDistanceToFieldProjection(Builder builder, this.singleValuedInRoot = !builder.field.multiValuedInRoot(); this.center = builder.center; this.unit = builder.unit; - this.accumulator = accumulator; + this.collector = collector; if ( singleValuedInRoot && builder.field.nestedPathHierarchy().isEmpty() ) { // Rely on docValues when there is no sort to extract the distance from. scriptFieldName = createScriptFieldName( absoluteFieldPath, center ); @@ -88,7 +88,7 @@ private ElasticsearchDistanceToFieldProjection(Builder builder, scriptFieldName = null; this.sourceProjection = new ElasticsearchFieldProjection<>( builder.scope, builder.field, - this::computeDistanceWithUnit, false, NO_OP_DOUBLE_CONVERTER, accumulatorProvider + this::computeDistanceWithUnit, false, NO_OP_DOUBLE_CONVERTER, collectorProvider ); } } @@ -99,7 +99,7 @@ public String toString() { + "absoluteFieldPath=" + absoluteFieldPath + ", center=" + center + ", unit=" + unit - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -130,13 +130,13 @@ public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, Integer distanceSortIndex = singleValuedInRoot ? context.getDistanceSortIndex( absoluteFieldPath, center ) : null; if ( distanceSortIndex != null ) { - A accumulated = accumulator.createInitial(); - accumulated = accumulator.accumulate( accumulated, extractDistanceFromSortKey( hit, distanceSortIndex ) ); + A accumulated = collector.createInitial(); + accumulated = collector.accumulate( accumulated, extractDistanceFromSortKey( hit, distanceSortIndex ) ); return accumulated; } else { - A accumulated = accumulator.createInitial(); - accumulated = accumulator.accumulate( accumulated, extractDistanceFromScriptField( hit ) ); + A accumulated = collector.createInitial(); + accumulated = collector.accumulate( accumulated, extractDistanceFromScriptField( hit ) ); return accumulated; } } @@ -145,7 +145,7 @@ public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, public P transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { // Nothing to transform: we take the values as they are. - return accumulator.finish( extractedData ); + return collector.finish( extractedData ); } private Double extractDistanceFromScriptField(JsonObject hit) { @@ -255,9 +255,9 @@ public void unit(DistanceUnit unit) { } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { - return new ElasticsearchDistanceToFieldProjection<>( this, accumulatorProvider, - accumulatorProvider.get() ); + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { + return new ElasticsearchDistanceToFieldProjection<>( this, collectorProvider, + collectorProvider.get() ); } } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldHighlightProjection.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldHighlightProjection.java index 2fa82bb1892..b748dee288b 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldHighlightProjection.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldHighlightProjection.java @@ -19,7 +19,7 @@ import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.spi.HighlightProjectionBuilder; @@ -38,23 +38,23 @@ public class ElasticsearchFieldHighlightProjection implements ElasticsearchSe private final String highlighterName; private final ElasticsearchSearchIndexValueFieldTypeContext typeContext; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; private ElasticsearchFieldHighlightProjection(Builder builder, - ProjectionAccumulator.Provider accumulatorProvider) { - this( builder.scope, builder.field, builder.highlighterName(), accumulatorProvider ); + ProjectionCollector.Provider collectorProvider) { + this( builder.scope, builder.field, builder.highlighterName(), collectorProvider ); } private ElasticsearchFieldHighlightProjection(ElasticsearchSearchIndexScope scope, ElasticsearchSearchIndexValueFieldContext field, String highlighterName, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { this.indexNames = scope.hibernateSearchIndexNames(); this.absoluteFieldPath = field.absolutePath(); this.absoluteFieldPathComponents = field.absolutePathComponents(); this.highlighterName = highlighterName; this.typeContext = field.type(); - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override @@ -93,7 +93,7 @@ public Extractor request(JsonObject requestBody, ProjectionRequestContext if ( !typeContext.highlighterTypeSupported( highlighterType ) ) { throw log.highlighterTypeNotSupported( highlighterType, absoluteFieldPath ); } - if ( !context.root().isCompatibleHighlighter( highlighterName, accumulatorProvider ) ) { + if ( !context.root().isCompatibleHighlighter( highlighterName, collectorProvider ) ) { throw log.highlighterIncompatibleCardinality(); } @@ -102,26 +102,26 @@ public Extractor request(JsonObject requestBody, ProjectionRequestContext REQUEST_HIGHLIGHT_FIELDS_ACCESSOR.getOrCreate( requestBody, JsonObject::new ) ); - return new FieldHighlightExtractor<>( innerContext.absoluteCurrentFieldPath(), accumulatorProvider.get() ); + return new FieldHighlightExtractor<>( innerContext.absoluteCurrentFieldPath(), collectorProvider.get() ); } private class FieldHighlightExtractor implements Extractor { private final JsonArrayAccessor highlightAccessor; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; - private FieldHighlightExtractor(String fieldPath, ProjectionAccumulator accumulator) { + private FieldHighlightExtractor(String fieldPath, ProjectionCollector collector) { this.highlightAccessor = JsonAccessor.root().property( "highlight" ).property( fieldPath ).asArray(); - this.accumulator = accumulator; + this.collector = collector; } @Override public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, JsonObject source, ProjectionExtractContext context) { - A initial = accumulator.createInitial(); + A initial = collector.createInitial(); Optional highlights = highlightAccessor.get( hit ); if ( highlights.isPresent() ) { for ( JsonElement element : highlights.get() ) { - initial = accumulator.accumulate( initial, element.getAsString() ); + initial = collector.accumulate( initial, element.getAsString() ); } } return initial; @@ -129,7 +129,7 @@ public A extract(ProjectionHitMapper projectionHitMapper, JsonObject hit, Jso @Override public T transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { - return accumulator.finish( extractedData ); + return collector.finish( extractedData ); } } @@ -164,8 +164,8 @@ protected String highlighterName() { } @Override - public SearchProjection build(ProjectionAccumulator.Provider accumulatorProvider) { - return new ElasticsearchFieldHighlightProjection<>( this, accumulatorProvider ); + public SearchProjection build(ProjectionCollector.Provider collectorProvider) { + return new ElasticsearchFieldHighlightProjection<>( this, collectorProvider ); } } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldProjection.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldProjection.java index dfc04ab3abf..891d8aec867 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldProjection.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchFieldProjection.java @@ -17,7 +17,7 @@ import org.hibernate.search.engine.search.common.ValueModel; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.FieldProjectionBuilder; import org.hibernate.search.util.common.logging.impl.LoggerFactory; @@ -44,36 +44,37 @@ public class ElasticsearchFieldProjection extends AbstractElasticsea private final Function decodeFunction; private final boolean canDecodeArrays; private final ProjectionConverter converter; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; private ElasticsearchFieldProjection(Builder builder, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { this( builder.scope, builder.field, builder.decodeFunction, builder.canDecodeArrays, builder.converter, - accumulatorProvider ); + collectorProvider + ); } ElasticsearchFieldProjection(ElasticsearchSearchIndexScope scope, ElasticsearchSearchIndexValueFieldContext field, Function decodeFunction, boolean canDecodeArrays, ProjectionConverter converter, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { super( scope ); this.absoluteFieldPath = field.absolutePath(); this.absoluteFieldPathComponents = field.absolutePathComponents(); - this.requiredContextAbsoluteFieldPath = accumulatorProvider.isSingleValued() + this.requiredContextAbsoluteFieldPath = collectorProvider.isSingleValued() ? field.closestMultiValuedParentAbsolutePath() : null; this.decodeFunction = decodeFunction; this.canDecodeArrays = canDecodeArrays; this.converter = converter; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath - + ", accumulatorProvider=" + accumulatorProvider + + ", collectorProvider=" + collectorProvider + "]"; } @@ -87,22 +88,22 @@ public ValueFieldExtractor request(JsonObject requestBody, ProjectionRequestC } JsonPrimitive fieldPathJson = new JsonPrimitive( absoluteFieldPath ); AccumulatingSourceExtractor.REQUEST_SOURCE_ACCESSOR.addElementIfAbsent( requestBody, fieldPathJson ); - return new ValueFieldExtractor<>( innerContext.relativeCurrentFieldPathComponents(), accumulatorProvider.get() ); + return new ValueFieldExtractor<>( innerContext.relativeCurrentFieldPathComponents(), collectorProvider.get() ); } /** * @param The type of the temporary storage for accumulated values, before and after being transformed. */ private class ValueFieldExtractor extends AccumulatingSourceExtractor { - public ValueFieldExtractor(String[] fieldPathComponents, ProjectionAccumulator accumulator) { - super( fieldPathComponents, accumulator ); + public ValueFieldExtractor(String[] fieldPathComponents, ProjectionCollector collector) { + super( fieldPathComponents, collector ); } @Override public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -121,8 +122,8 @@ protected boolean canDecodeArrays() { public P transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { FromDocumentValueConvertContext convertContext = context.fromDocumentValueConvertContext(); - A transformedData = accumulator.transformAll( extractedData, converter.delegate(), convertContext ); - return accumulator.finish( transformedData ); + A transformedData = collector.transformAll( extractedData, converter.delegate(), convertContext ); + return collector.finish( transformedData ); } } @@ -193,11 +194,11 @@ private Builder(Function decodeFunction, boolean canDecodeArrays } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { - if ( accumulatorProvider.isSingleValued() && field.multiValued() ) { + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { + if ( collectorProvider.isSingleValued() && field.multiValued() ) { throw log.invalidSingleValuedProjectionOnMultiValuedField( field.absolutePath(), field.eventContext() ); } - return new ElasticsearchFieldProjection<>( this, accumulatorProvider ); + return new ElasticsearchFieldProjection<>( this, collectorProvider ); } } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchObjectProjection.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchObjectProjection.java index 3ba24c32024..50f4e99642a 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchObjectProjection.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ElasticsearchObjectProjection.java @@ -11,7 +11,7 @@ import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexScope; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -37,19 +37,19 @@ public class ElasticsearchObjectProjection private final String requiredContextAbsoluteFieldPath; private final ElasticsearchSearchProjection[] inners; private final ProjectionCompositor compositor; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; public ElasticsearchObjectProjection(Builder builder, ElasticsearchSearchProjection[] inners, - ProjectionCompositor compositor, ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCompositor compositor, ProjectionCollector.Provider collectorProvider) { super( builder.scope ); this.absoluteFieldPath = builder.objectField.absolutePath(); this.absoluteFieldPathComponents = builder.objectField.absolutePathComponents(); - this.requiredContextAbsoluteFieldPath = accumulatorProvider.isSingleValued() + this.requiredContextAbsoluteFieldPath = collectorProvider.isSingleValued() ? builder.objectField.closestMultiValuedParentAbsolutePath() : null; this.inners = inners; this.compositor = compositor; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override @@ -57,7 +57,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulatorProvider=" + accumulatorProvider + + ", collectorProvider=" + collectorProvider + "]"; } @@ -76,7 +76,7 @@ public Extractor request(JsonObject requestBody, ProjectionRequestContext for ( int i = 0; i < inners.length; i++ ) { innerExtractors[i] = inners[i].request( requestBody, innerContext ); } - return new ObjectFieldExtractor<>( extractorFieldPathComponents, accumulatorProvider.get(), innerExtractors ); + return new ObjectFieldExtractor<>( extractorFieldPathComponents, collectorProvider.get(), innerExtractors ); } /** @@ -85,9 +85,9 @@ public Extractor request(JsonObject requestBody, ProjectionRequestContext private class ObjectFieldExtractor extends AccumulatingSourceExtractor { private final Extractor[] inners; - private ObjectFieldExtractor(String[] fieldPathComponents, ProjectionAccumulator accumulator, + private ObjectFieldExtractor(String[] fieldPathComponents, ProjectionCollector collector, Extractor[] inners) { - super( fieldPathComponents, accumulator ); + super( fieldPathComponents, collector ); this.inners = inners; } @@ -96,7 +96,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -123,8 +123,8 @@ protected boolean canDecodeArrays() { @Override public final P transform(LoadingResult loadingResult, A accumulated, ProjectionTransformContext context) { - for ( int i = 0; i < accumulator.size( accumulated ); i++ ) { - E transformedData = accumulator.get( accumulated, i ); + for ( int i = 0; i < collector.size( accumulated ); i++ ) { + E transformedData = collector.get( accumulated, i ); if ( transformedData == null ) { continue; } @@ -136,9 +136,9 @@ public final P transform(LoadingResult loadingResult, A accumulated, transformedData = compositor.set( transformedData, j, transformedDataForInner ); } - accumulated = accumulator.transform( accumulated, i, compositor.finish( transformedData ) ); + accumulated = collector.transform( accumulated, i, compositor.finish( transformedData ) ); } - return accumulator.finish( accumulated ); + return collector.finish( accumulated ); } } @@ -163,8 +163,8 @@ static class Builder implements CompositeProjectionBuilder { @Override public SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { - if ( accumulatorProvider.isSingleValued() && objectField.multiValued() ) { + ProjectionCollector.Provider collectorProvider) { + if ( collectorProvider.isSingleValued() && objectField.multiValued() ) { throw log.invalidSingleValuedProjectionOnMultiValuedField( objectField.absolutePath(), objectField.eventContext() ); } @@ -174,7 +174,7 @@ public SearchProjection

build(SearchProjection[] inners, Project typedInners[i] = ElasticsearchSearchProjection.from( scope, inners[i] ); } return new ElasticsearchObjectProjection<>( this, typedInners, - compositor, accumulatorProvider ); + compositor, collectorProvider ); } } } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ProjectionRequestRootContext.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ProjectionRequestRootContext.java index 1a24e4b6b66..e0b82dc52bb 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ProjectionRequestRootContext.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/projection/impl/ProjectionRequestRootContext.java @@ -6,7 +6,7 @@ import org.hibernate.search.backend.elasticsearch.lowlevel.syntax.search.impl.ElasticsearchSearchSyntax; import org.hibernate.search.backend.elasticsearch.search.highlighter.impl.ElasticsearchSearchHighlighter; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.spatial.GeoPoint; public interface ProjectionRequestRootContext extends ProjectionRequestContext { @@ -19,5 +19,5 @@ public interface ProjectionRequestRootContext extends ProjectionRequestContext { ElasticsearchSearchHighlighter queryHighlighter(); - boolean isCompatibleHighlighter(String highlighterName, ProjectionAccumulator.Provider accumulatorProvider); + boolean isCompatibleHighlighter(String highlighterName, ProjectionCollector.Provider collectorProvider); } diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/dsl/impl/ElasticsearchSearchQuerySelectStepImpl.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/dsl/impl/ElasticsearchSearchQuerySelectStepImpl.java index a685e656f18..af452ffb0d2 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/dsl/impl/ElasticsearchSearchQuerySelectStepImpl.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/dsl/impl/ElasticsearchSearchQuerySelectStepImpl.java @@ -20,7 +20,7 @@ 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.SimpleBooleanPredicateClausesCollector; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -83,7 +83,7 @@ public

ElasticsearchSearchQueryWhereStep select(SearchProjection

public ElasticsearchSearchQueryWhereStep, LOS> select(SearchProjection... projections) { return select( scope.projectionBuilders().composite() .build( projections, ProjectionCompositor.fromList( projections.length ), - ProjectionAccumulator.nullable() ) ); + ProjectionCollector.nullable() ) ); } @Override diff --git a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/impl/ElasticsearchSearchQueryRequestContext.java b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/impl/ElasticsearchSearchQueryRequestContext.java index f8b31df69ed..80a2efb6e90 100644 --- a/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/impl/ElasticsearchSearchQueryRequestContext.java +++ b/backend/elasticsearch/src/main/java/org/hibernate/search/backend/elasticsearch/search/query/impl/ElasticsearchSearchQueryRequestContext.java @@ -23,7 +23,7 @@ import org.hibernate.search.engine.search.common.NamedValues; import org.hibernate.search.engine.search.common.spi.SearchQueryElementTypeKey; import org.hibernate.search.engine.search.loading.spi.SearchLoadingContext; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.query.spi.QueryParameters; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.util.common.logging.impl.LoggerFactory; @@ -144,17 +144,17 @@ public ElasticsearchSearchHighlighter queryHighlighter() { } @Override - public boolean isCompatibleHighlighter(String highlighterName, ProjectionAccumulator.Provider accumulatorProvider) { + public boolean isCompatibleHighlighter(String highlighterName, ProjectionCollector.Provider collectorProvider) { ElasticsearchSearchHighlighter highlighter = highlighter( highlighterName ); if ( ElasticsearchSearchHighlighterImpl.NO_OPTIONS_CONFIGURATION == highlighter ) { // if there was no highlighter configured at all it means that the settings are default, - // and we assume that they are incompatible with the single-valued accumulator: + // and we assume that they are incompatible with the single-valued collector: return queryHighlighter != null - ? queryHighlighter.isCompatible( accumulatorProvider ) - : !accumulatorProvider.isSingleValued(); + ? queryHighlighter.isCompatible( collectorProvider ) + : !collectorProvider.isSingleValued(); } else { - return highlighter.isCompatible( accumulatorProvider ); + return highlighter.isCompatible( collectorProvider ); } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/logging/impl/Log.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/logging/impl/Log.java index 5706bf2e0e4..7473ee29b58 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/logging/impl/Log.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/logging/impl/Log.java @@ -537,7 +537,7 @@ SearchException invalidFieldValueType(@FormatWith(ClassFormatter.class) Class @Message(id = ID_OFFSET + 131, value = "Invalid cardinality for projection on field '%1$s': the projection is single-valued," + " but this field is multi-valued." - + " Make sure to call '.accumulator(...)' when you create the projection.") + + " Make sure to call '.collector(...)' when you create the projection.") SearchException invalidSingleValuedProjectionOnMultiValuedField(String absolutePath, @Param EventContext context); @Message(id = ID_OFFSET + 135, @@ -600,9 +600,9 @@ SearchException invalidContextForProjectionOnField(String absolutePath, value = "Invalid cardinality for projection on field '%1$s': the projection is single-valued," + " but this field is effectively multi-valued in this context," + " because parent object field '%2$s' is multi-valued." - + " Either call '.accumulator(...)' when you create the projection on field '%1$s'," + + " Either call '.collector(...)' when you create the projection on field '%1$s'," + " or wrap that projection in an object projection like this:" - + " 'f.object(\"%2$s\").from().as(...).accumulator(...)'.") + + " 'f.object(\"%2$s\").from().as(...).collector(...)'.") SearchException invalidSingleValuedProjectionOnValueFieldInMultiValuedObjectField(String absolutePath, String objectFieldAbsolutePath); diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneAbstractSearchHighlighter.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneAbstractSearchHighlighter.java index b7051e6fd68..a9bbaa0332c 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneAbstractSearchHighlighter.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneAbstractSearchHighlighter.java @@ -26,7 +26,7 @@ import org.hibernate.search.engine.search.highlighter.spi.BoundaryScannerType; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterBuilder; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.impl.Contracts; import org.hibernate.search.util.common.logging.impl.LoggerFactory; @@ -193,9 +193,9 @@ public Set indexNames() { public abstract Values createValues(String parentDocumentPath, String nestedDocumentPath, String absoluteFieldPath, Analyzer analyzer, ProjectionExtractContext context, - ProjectionAccumulator accumulator); + ProjectionCollector collector); - public boolean isCompatible(ProjectionAccumulator.Provider provider) { + public boolean isCompatible(ProjectionCollector.Provider provider) { return !provider.isSingleValued() || ( provider.isSingleValued() && ( numberOfFragments != null && numberOfFragments.equals( 1 ) ) ); } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneFastVectorSearchHighlighter.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneFastVectorSearchHighlighter.java index 5dfd5a426fa..d425c33fc87 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneFastVectorSearchHighlighter.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneFastVectorSearchHighlighter.java @@ -20,7 +20,7 @@ import org.hibernate.search.engine.search.highlighter.dsl.HighlighterFragmenter; import org.hibernate.search.engine.search.highlighter.spi.BoundaryScannerType; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Field; @@ -86,9 +86,10 @@ public LuceneAbstractSearchHighlighter withFallbackDefaults() { @Override public Values createValues(String parentDocumentPath, String nestedDocumentPath, String absoluteFieldPath, Analyzer analyzer, ProjectionExtractContext context, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { return new FastVectorHighlighterValues<>( parentDocumentPath, nestedDocumentPath, absoluteFieldPath, context, - accumulator ); + collector + ); } @Override @@ -108,8 +109,8 @@ private final class FastVectorHighlighterValues extends HighlighterValues< private final Integer maxNumFragments; FastVectorHighlighterValues(String parentDocumentPath, String nestedDocumentPath, String field, - ProjectionExtractContext context, ProjectionAccumulator accumulator) { - super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), accumulator ); + ProjectionExtractContext context, ProjectionCollector collector) { + super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), collector ); this.field = field; this.highlighter = new FastVectorHighlighter(); diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LucenePlainSearchHighlighter.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LucenePlainSearchHighlighter.java index e88ec488f03..6596291e568 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LucenePlainSearchHighlighter.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LucenePlainSearchHighlighter.java @@ -21,7 +21,7 @@ import org.hibernate.search.engine.search.highlighter.dsl.HighlighterFragmenter; import org.hibernate.search.engine.search.highlighter.spi.BoundaryScannerType; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.index.IndexableField; @@ -87,9 +87,9 @@ public LuceneAbstractSearchHighlighter withFallbackDefaults() { @Override public Values createValues(String parentDocumentPath, String nestedDocumentPath, String absoluteFieldPath, Analyzer analyzer, ProjectionExtractContext context, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { return new PlainHighlighterValues<>( - parentDocumentPath, nestedDocumentPath, absoluteFieldPath, analyzer, context, accumulator ); + parentDocumentPath, nestedDocumentPath, absoluteFieldPath, analyzer, context, collector ); } @Override @@ -109,8 +109,8 @@ private final class PlainHighlighterValues extends HighlighterValues private final String field; PlainHighlighterValues(String parentDocumentPath, String nestedDocumentPath, String field, Analyzer analyzer, - ProjectionExtractContext context, ProjectionAccumulator accumulator) { - super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), accumulator ); + ProjectionExtractContext context, ProjectionCollector collector) { + super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), collector ); this.storedFieldsValuesDelegate = context.collectorExecutionContext().storedFieldsValuesDelegate(); this.field = field; this.analyzer = analyzer; diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighter.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighter.java index a3fdcb0c928..385f2d563a4 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighter.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighter.java @@ -21,7 +21,7 @@ import org.hibernate.search.engine.search.highlighter.dsl.HighlighterFragmenter; import org.hibernate.search.engine.search.highlighter.spi.BoundaryScannerType; import org.hibernate.search.engine.search.highlighter.spi.SearchHighlighterType; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.search.IndexSearcher; @@ -90,9 +90,9 @@ public LuceneAbstractSearchHighlighter withFallbackDefaults() { @Override public Values createValues(String parentDocumentPath, String nestedDocumentPath, String absoluteFieldPath, Analyzer analyzer, ProjectionExtractContext context, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { return new UnifiedHighlighterValues<>( - parentDocumentPath, nestedDocumentPath, absoluteFieldPath, analyzer, context, accumulator ); + parentDocumentPath, nestedDocumentPath, absoluteFieldPath, analyzer, context, collector ); } @Override @@ -109,8 +109,8 @@ private final class UnifiedHighlighterValues extends HighlighterValues accumulator) { - super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), accumulator ); + ProjectionExtractContext context, ProjectionCollector collector) { + super( parentDocumentPath, nestedDocumentPath, context.collectorExecutionContext(), collector ); this.fieldsIn = new String[] { field }; this.maxPassagesIn = new int[] { LuceneUnifiedSearchHighlighter.this.numberOfFragments }; this.query = context.collectorExecutionContext().originalQuery(); diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/AbstractNestingAwareAccumulatingValues.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/AbstractNestingAwareAccumulatingValues.java index 311bb77b417..c5cb96b82dc 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/AbstractNestingAwareAccumulatingValues.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/AbstractNestingAwareAccumulatingValues.java @@ -10,23 +10,23 @@ import org.hibernate.search.backend.lucene.lowlevel.collector.impl.Values; import org.hibernate.search.backend.lucene.lowlevel.join.impl.ChildDocIds; import org.hibernate.search.backend.lucene.lowlevel.join.impl.NestedDocsProvider; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.DocIdSetIterator; abstract class AbstractNestingAwareAccumulatingValues implements Values { private final NestedDocsProvider nestedDocsProvider; - protected final ProjectionAccumulator accumulator; + protected final ProjectionCollector collector; protected ChildDocIds currentLeafChildDocIds; AbstractNestingAwareAccumulatingValues(String parentDocumentPath, String nestedDocumentPath, - ProjectionAccumulator accumulator, TopDocsDataCollectorExecutionContext context) { + ProjectionCollector collector, TopDocsDataCollectorExecutionContext context) { this.nestedDocsProvider = nestedDocumentPath == null || nestedDocumentPath.equals( parentDocumentPath ) ? null : context.createNestedDocsProvider( parentDocumentPath, nestedDocumentPath ); - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -44,7 +44,7 @@ protected DocIdSetIterator doContext(LeafReaderContext context) throws IOExcepti @Override public final A get(int parentDocId) throws IOException { - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); if ( nestedDocsProvider == null ) { // No nesting: we work directly on the parent doc. diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneCompositeProjection.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneCompositeProjection.java index 23108b30895..c61fd1c8803 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneCompositeProjection.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneCompositeProjection.java @@ -10,7 +10,7 @@ import org.hibernate.search.backend.lucene.lowlevel.collector.impl.Values; import org.hibernate.search.backend.lucene.search.common.impl.LuceneSearchIndexScope; import org.hibernate.search.engine.search.loading.spi.LoadingResult; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -32,14 +32,14 @@ class LuceneCompositeProjection private final LuceneSearchProjection[] inners; private final ProjectionCompositor compositor; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; public LuceneCompositeProjection(Builder builder, LuceneSearchProjection[] inners, - ProjectionCompositor compositor, ProjectionAccumulator accumulator) { + ProjectionCompositor compositor, ProjectionCollector collector) { super( builder.scope ); this.inners = inners; this.compositor = compositor; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -47,7 +47,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -72,7 +72,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -101,14 +101,14 @@ public void context(LeafReaderContext context) throws IOException { @Override public A get(int doc) throws IOException { - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); E components = compositor.createInitial(); for ( int i = 0; i < inners.length; i++ ) { Object extractedDataForInner = inners[i].get( doc ); components = compositor.set( components, i, extractedDataForInner ); } - accumulated = accumulator.accumulate( accumulated, components ); + accumulated = collector.accumulate( accumulated, components ); return accumulated; } @@ -117,8 +117,8 @@ public A get(int doc) throws IOException { @Override public final P transform(LoadingResult loadingResult, A accumulated, ProjectionTransformContext context) { - for ( int i = 0; i < accumulator.size( accumulated ); i++ ) { - E transformedData = accumulator.get( accumulated, i ); + for ( int i = 0; i < collector.size( accumulated ); i++ ) { + E transformedData = collector.get( accumulated, i ); // Transform in-place for ( int j = 0; j < inners.length; j++ ) { Object extractedDataForInner = compositor.get( transformedData, j ); @@ -126,9 +126,9 @@ public final P transform(LoadingResult loadingResult, A accumulated, extractedDataForInner, context ); transformedData = compositor.set( transformedData, j, transformedDataForInner ); } - accumulated = accumulator.transform( accumulated, i, compositor.finish( transformedData ) ); + accumulated = collector.transform( accumulated, i, compositor.finish( transformedData ) ); } - return accumulator.finish( accumulated ); + return collector.finish( accumulated ); } } @@ -142,14 +142,14 @@ static class Builder implements CompositeProjectionBuilder { @Override public SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { LuceneSearchProjection[] typedInners = new LuceneSearchProjection[inners.length]; for ( int i = 0; i < inners.length; i++ ) { typedInners[i] = LuceneSearchProjection.from( scope, inners[i] ); } return new LuceneCompositeProjection<>( this, typedInners, - compositor, accumulatorProvider.get() ); + compositor, collectorProvider.get() ); } } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneDistanceToFieldProjection.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneDistanceToFieldProjection.java index a36e0289faa..5ffad286d11 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneDistanceToFieldProjection.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneDistanceToFieldProjection.java @@ -17,7 +17,7 @@ import org.hibernate.search.backend.lucene.types.codec.impl.LuceneFieldCodec; import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter; import org.hibernate.search.engine.search.loading.spi.LoadingResult; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.DistanceToFieldProjectionBuilder; import org.hibernate.search.engine.spatial.DistanceUnit; @@ -49,27 +49,27 @@ public class LuceneDistanceToFieldProjection

extends AbstractLuceneProjection private final GeoPoint center; private final DistanceUnit unit; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; private final LuceneFieldProjection fieldProjection; private LuceneDistanceToFieldProjection(Builder builder, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { super( builder ); this.absoluteFieldPath = builder.field.absolutePath(); this.nestedDocumentPath = builder.field.nestedDocumentPath(); - this.requiredContextAbsoluteFieldPath = accumulatorProvider.isSingleValued() + this.requiredContextAbsoluteFieldPath = collectorProvider.isSingleValued() ? builder.field.closestMultiValuedParentAbsolutePath() : null; this.codec = builder.codec; this.center = builder.center; this.unit = builder.unit; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; if ( builder.field.multiValued() ) { // For multi-valued fields, use a field projection, because we need order to be preserved. this.fieldProjection = new LuceneFieldProjection<>( builder.scope, builder.field, - this::computeDistanceWithUnit, NO_OP_DOUBLE_CONVERTER, accumulatorProvider + this::computeDistanceWithUnit, NO_OP_DOUBLE_CONVERTER, collectorProvider ); } else { @@ -83,7 +83,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath + ", center=" + center - + ", accumulatorProvider=" + accumulatorProvider + + ", collectorProvider=" + collectorProvider + "]"; } @@ -99,7 +99,7 @@ public Extractor request(ProjectionRequestContext context) { throw log.invalidSingleValuedProjectionOnValueFieldInMultiValuedObjectField( absoluteFieldPath, requiredContextAbsoluteFieldPath ); } - return new DocValuesBasedDistanceExtractor<>( accumulatorProvider.get(), + return new DocValuesBasedDistanceExtractor<>( collectorProvider.get(), context.absoluteCurrentNestedFieldPath() ); } } @@ -108,12 +108,12 @@ public Extractor request(ProjectionRequestContext context) { * @param The type of the temporary storage for accumulated values, before and after being transformed. */ private class DocValuesBasedDistanceExtractor implements Extractor { - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private final String contextAbsoluteFieldPath; - private DocValuesBasedDistanceExtractor(ProjectionAccumulator accumulator, + private DocValuesBasedDistanceExtractor(ProjectionCollector collector, String contextAbsoluteFieldPath) { - this.accumulator = accumulator; + this.collector = collector; this.contextAbsoluteFieldPath = contextAbsoluteFieldPath; } @@ -122,7 +122,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath + ", center=" + center - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -140,7 +140,7 @@ private class DocValuesBasedDistanceValues public DocValuesBasedDistanceValues(TopDocsDataCollectorExecutionContext context) { super( contextAbsoluteFieldPath, nestedDocumentPath, - DocValuesBasedDistanceExtractor.this.accumulator, context ); + DocValuesBasedDistanceExtractor.this.collector, context ); } @Override @@ -155,7 +155,7 @@ protected A accumulate(A accumulated, int docId) throws IOException { if ( currentLeafValues.advanceExact( docId ) ) { for ( int i = 0; i < currentLeafValues.docValueCount(); i++ ) { Double distanceOrNull = currentLeafValues.nextValue(); - accumulated = accumulator.accumulate( accumulated, unit.fromMeters( distanceOrNull ) ); + accumulated = collector.accumulate( accumulated, unit.fromMeters( distanceOrNull ) ); } } return accumulated; @@ -166,7 +166,7 @@ protected A accumulate(A accumulated, int docId) throws IOException { public P transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { // Nothing to transform: we take the values as they are. - return accumulator.finish( extractedData ); + return collector.finish( extractedData ); } } @@ -229,11 +229,11 @@ public void unit(DistanceUnit unit) { } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { - if ( accumulatorProvider.isSingleValued() && field.multiValued() ) { + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { + if ( collectorProvider.isSingleValued() && field.multiValued() ) { throw log.invalidSingleValuedProjectionOnMultiValuedField( field.absolutePath(), field.eventContext() ); } - return new LuceneDistanceToFieldProjection<>( this, accumulatorProvider ); + return new LuceneDistanceToFieldProjection<>( this, collectorProvider ); } } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldHighlightProjection.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldHighlightProjection.java index c723bb4ecc1..cf753c3e500 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldHighlightProjection.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldHighlightProjection.java @@ -17,7 +17,7 @@ import org.hibernate.search.backend.lucene.search.highlighter.impl.LuceneAbstractSearchHighlighter; import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.engine.search.loading.spi.LoadingResult; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.spi.HighlightProjectionBuilder; @@ -32,22 +32,22 @@ public class LuceneFieldHighlightProjection implements LuceneSearchProjection private final String highlighterName; private final String nestedDocumentPath; private final LuceneSearchIndexValueFieldTypeContext typeContext; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; - private LuceneFieldHighlightProjection(Builder builder, ProjectionAccumulator.Provider accumulatorProvider) { - this( builder.scope, builder.field, builder.highlighterName(), accumulatorProvider ); + private LuceneFieldHighlightProjection(Builder builder, ProjectionCollector.Provider collectorProvider) { + this( builder.scope, builder.field, builder.highlighterName(), collectorProvider ); } LuceneFieldHighlightProjection(LuceneSearchIndexScope scope, LuceneSearchIndexValueFieldContext field, - String highlighterName, ProjectionAccumulator.Provider accumulatorProvider) { + String highlighterName, ProjectionCollector.Provider collectorProvider) { this.indexNames = scope.hibernateSearchIndexNames(); this.analyzer = field.type().searchAnalyzerOrNormalizer(); this.absoluteFieldPath = field.absolutePath(); this.highlighterName = highlighterName; this.nestedDocumentPath = field.nestedDocumentPath(); this.typeContext = field.type(); - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override @@ -77,12 +77,12 @@ public Extractor request(ProjectionRequestContext context) { throw log.highlighterTypeNotSupported( highlighter.type(), absoluteFieldPath ); } highlighter.request( context, absoluteFieldPath ); - if ( !highlighter.isCompatible( accumulatorProvider ) ) { + if ( !highlighter.isCompatible( collectorProvider ) ) { throw log.highlighterIncompatibleCardinality(); } return new FieldHighlightExtractor<>( context.absoluteCurrentNestedFieldPath(), highlighter, - accumulatorProvider.get() + collectorProvider.get() ); } @@ -90,13 +90,13 @@ public Extractor request(ProjectionRequestContext context) { private class FieldHighlightExtractor implements Extractor { private final String parentDocumentPath; private final LuceneAbstractSearchHighlighter highlighter; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private FieldHighlightExtractor(String parentDocumentPath, LuceneAbstractSearchHighlighter highlighter, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { this.parentDocumentPath = parentDocumentPath; this.highlighter = highlighter; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -107,14 +107,14 @@ public Values values(ProjectionExtractContext context) { absoluteFieldPath, analyzer, context, - accumulator + collector ); } @Override public T transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { - return accumulator.finish( extractedData ); + return collector.finish( extractedData ); } } @@ -124,8 +124,8 @@ public abstract static class HighlighterValues extends AbstractNestingAwar protected HighlighterValues(String parentDocumentPath, String nestedDocumentPath, TopDocsDataCollectorExecutionContext context, - ProjectionAccumulator accumulator) { - super( parentDocumentPath, nestedDocumentPath, accumulator, context ); + ProjectionCollector collector) { + super( parentDocumentPath, nestedDocumentPath, collector, context ); } @Override @@ -139,7 +139,7 @@ public void context(LeafReaderContext context) throws IOException { @Override protected A accumulate(A accumulated, int docId) throws IOException { - return accumulator.accumulateAll( accumulated, highlight( docId ) ); + return collector.accumulateAll( accumulated, highlight( docId ) ); } protected abstract List highlight(int doc) throws IOException; @@ -175,8 +175,8 @@ protected String highlighterName() { } @Override - public SearchProjection build(ProjectionAccumulator.Provider accumulatorProvider) { - return new LuceneFieldHighlightProjection<>( this, accumulatorProvider ); + public SearchProjection build(ProjectionCollector.Provider collectorProvider) { + return new LuceneFieldHighlightProjection<>( this, collectorProvider ); } } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldProjection.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldProjection.java index ef7feca3c4f..541a5522055 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldProjection.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneFieldProjection.java @@ -19,7 +19,7 @@ import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter; import org.hibernate.search.engine.search.common.ValueModel; import org.hibernate.search.engine.search.loading.spi.LoadingResult; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.FieldProjectionBuilder; import org.hibernate.search.util.common.logging.impl.LoggerFactory; @@ -44,33 +44,33 @@ public class LuceneFieldProjection extends AbstractLuceneProjection< private final Function decodeFunction; private final ProjectionConverter converter; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; - private LuceneFieldProjection(Builder builder, ProjectionAccumulator.Provider accumulatorProvider) { - this( builder.scope, builder.field, builder.decodeFunction, builder.converter, accumulatorProvider ); + private LuceneFieldProjection(Builder builder, ProjectionCollector.Provider collectorProvider) { + this( builder.scope, builder.field, builder.decodeFunction, builder.converter, collectorProvider ); } LuceneFieldProjection(LuceneSearchIndexScope scope, LuceneSearchIndexValueFieldContext field, Function decodeFunction, ProjectionConverter converter, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { super( scope ); this.absoluteFieldPath = field.absolutePath(); this.nestedDocumentPath = field.nestedDocumentPath(); - this.requiredContextAbsoluteFieldPath = accumulatorProvider.isSingleValued() + this.requiredContextAbsoluteFieldPath = collectorProvider.isSingleValued() ? field.closestMultiValuedParentAbsolutePath() : null; this.decodeFunction = decodeFunction; this.converter = converter; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath - + ", accumulatorProvider=" + accumulatorProvider + + ", collectorProvider=" + collectorProvider + "]"; } @@ -83,7 +83,7 @@ public ValueFieldExtractor request(ProjectionRequestContext context) { absoluteFieldPath, requiredContextAbsoluteFieldPath ); } context.requireStoredField( absoluteFieldPath, nestedDocumentPath ); - return new ValueFieldExtractor<>( context.absoluteCurrentNestedFieldPath(), accumulatorProvider.get() ); + return new ValueFieldExtractor<>( context.absoluteCurrentNestedFieldPath(), collectorProvider.get() ); } /** @@ -92,10 +92,10 @@ public ValueFieldExtractor request(ProjectionRequestContext context) { private class ValueFieldExtractor implements LuceneSearchProjection.Extractor { private final String contextAbsoluteFieldPath; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; - public ValueFieldExtractor(String contextAbsoluteFieldPath, ProjectionAccumulator accumulator) { - this.accumulator = accumulator; + public ValueFieldExtractor(String contextAbsoluteFieldPath, ProjectionCollector collector) { + this.collector = collector; this.contextAbsoluteFieldPath = contextAbsoluteFieldPath; } @@ -103,21 +103,21 @@ public ValueFieldExtractor(String contextAbsoluteFieldPath, ProjectionAccumulato public String toString() { return getClass().getSimpleName() + "[" + "absoluteFieldPath=" + absoluteFieldPath - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @Override public Values values(ProjectionExtractContext context) { - return new StoredFieldValues( accumulator, context.collectorExecutionContext() ); + return new StoredFieldValues( collector, context.collectorExecutionContext() ); } private class StoredFieldValues extends AbstractNestingAwareAccumulatingValues { private final StoredFieldsValuesDelegate delegate; - public StoredFieldValues(ProjectionAccumulator accumulator, + public StoredFieldValues(ProjectionCollector collector, TopDocsDataCollectorExecutionContext context) { - super( contextAbsoluteFieldPath, nestedDocumentPath, accumulator, context ); + super( contextAbsoluteFieldPath, nestedDocumentPath, collector, context ); this.delegate = context.storedFieldsValuesDelegate(); } @@ -133,7 +133,7 @@ protected A accumulate(A accumulated, int docId) { for ( IndexableField field : document.getFields() ) { if ( field.name().equals( absoluteFieldPath ) ) { T decoded = decodeFunction.apply( field ); - accumulated = accumulator.accumulate( accumulated, decoded ); + accumulated = collector.accumulate( accumulated, decoded ); } } return accumulated; @@ -143,8 +143,8 @@ protected A accumulate(A accumulated, int docId) { @Override public P transform(LoadingResult loadingResult, A extractedData, ProjectionTransformContext context) { FromDocumentValueConvertContext convertContext = context.fromDocumentValueConvertContext(); - A transformedData = accumulator.transformAll( extractedData, converter.delegate(), convertContext ); - return accumulator.finish( transformedData ); + A transformedData = collector.transformAll( extractedData, converter.delegate(), convertContext ); + return collector.finish( transformedData ); } } @@ -216,11 +216,11 @@ private Builder(LuceneSearchIndexScope scope, LuceneSearchIndexValueFieldCont } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { - if ( accumulatorProvider.isSingleValued() && field.multiValued() ) { + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { + if ( collectorProvider.isSingleValued() && field.multiValued() ) { throw log.invalidSingleValuedProjectionOnMultiValuedField( field.absolutePath(), field.eventContext() ); } - return new LuceneFieldProjection<>( this, accumulatorProvider ); + return new LuceneFieldProjection<>( this, collectorProvider ); } } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneObjectProjection.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneObjectProjection.java index 20b2e06f968..de1c02b82c2 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneObjectProjection.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/projection/impl/LuceneObjectProjection.java @@ -16,7 +16,7 @@ import org.hibernate.search.backend.lucene.search.predicate.impl.PredicateRequestContext; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.predicate.spi.PredicateTypeKeys; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -47,21 +47,21 @@ public class LuceneObjectProjection private final String requiredContextAbsoluteFieldPath; private final LuceneSearchProjection[] inners; private final ProjectionCompositor compositor; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; public LuceneObjectProjection(Builder builder, LuceneSearchProjection[] inners, - ProjectionCompositor compositor, ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCompositor compositor, ProjectionCollector.Provider collectorProvider) { super( builder.scope ); this.absoluteFieldPath = builder.objectField.absolutePath(); this.nested = builder.objectField.type().nested(); this.filter = builder.filter; this.nestedDocumentPath = builder.objectField.nestedDocumentPath(); - this.requiredContextAbsoluteFieldPath = accumulatorProvider.isSingleValued() + this.requiredContextAbsoluteFieldPath = collectorProvider.isSingleValued() ? builder.objectField.closestMultiValuedParentAbsolutePath() : null; this.inners = inners; this.compositor = compositor; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override @@ -69,7 +69,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulatorProvider=" + accumulatorProvider + + ", collectorProvider=" + collectorProvider + "]"; } @@ -86,7 +86,7 @@ public Extractor request(ProjectionRequestContext context) { innerExtractors[i] = inners[i].request( innerContext ); } return new ObjectFieldExtractor<>( context.absoluteCurrentNestedFieldPath(), innerExtractors, - accumulatorProvider.get() ); + collectorProvider.get() ); } /** @@ -95,13 +95,13 @@ public Extractor request(ProjectionRequestContext context) { private class ObjectFieldExtractor implements Extractor { private final String contextAbsoluteFieldPath; private final Extractor[] inners; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private ObjectFieldExtractor(String contextAbsoluteFieldPath, - Extractor[] inners, ProjectionAccumulator accumulator) { + Extractor[] inners, ProjectionCollector collector) { this.contextAbsoluteFieldPath = contextAbsoluteFieldPath; this.inners = inners; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -109,7 +109,7 @@ public String toString() { return getClass().getSimpleName() + "[" + "inners=" + Arrays.toString( inners ) + ", compositor=" + compositor - + ", accumulator=" + accumulator + + ", collector=" + collector + "]"; } @@ -129,7 +129,7 @@ private class ObjectFieldValues extends AbstractNestingAwareAccumulatingValues[] inners) { - super( contextAbsoluteFieldPath, nestedDocumentPath, ObjectFieldExtractor.this.accumulator, context ); + super( contextAbsoluteFieldPath, nestedDocumentPath, ObjectFieldExtractor.this.collector, context ); this.inners = inners; this.filterBitSetProducer = filter == null ? null : new QueryBitSetProducer( filter ); @@ -158,15 +158,15 @@ protected A accumulate(A accumulated, int docId) throws IOException { Object extractedDataForInner = inners[i].get( docId ); components = compositor.set( components, i, extractedDataForInner ); } - return accumulator.accumulate( accumulated, components ); + return collector.accumulate( accumulated, components ); } } @Override public final P transform(LoadingResult loadingResult, A accumulated, ProjectionTransformContext context) { - for ( int i = 0; i < accumulator.size( accumulated ); i++ ) { - E transformedData = accumulator.get( accumulated, i ); + for ( int i = 0; i < collector.size( accumulated ); i++ ) { + E transformedData = collector.get( accumulated, i ); // Transform in-place for ( int j = 0; j < inners.length; j++ ) { Object extractedDataForInner = compositor.get( transformedData, j ); @@ -174,9 +174,9 @@ public final P transform(LoadingResult loadingResult, A accumulated, extractedDataForInner, context ); transformedData = compositor.set( transformedData, j, transformedDataForInner ); } - accumulated = accumulator.transform( accumulated, i, compositor.finish( transformedData ) ); + accumulated = collector.transform( accumulated, i, compositor.finish( transformedData ) ); } - return accumulator.finish( accumulated ); + return collector.finish( accumulated ); } } @@ -222,8 +222,8 @@ static class Builder implements CompositeProjectionBuilder { @Override public SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { - if ( accumulatorProvider.isSingleValued() && objectField.multiValued() ) { + ProjectionCollector.Provider collectorProvider) { + if ( collectorProvider.isSingleValued() && objectField.multiValued() ) { throw log.invalidSingleValuedProjectionOnMultiValuedField( objectField.absolutePath(), objectField.eventContext() ); } @@ -233,7 +233,7 @@ public SearchProjection

build(SearchProjection[] inners, Project typedInners[i] = LuceneSearchProjection.from( scope, inners[i] ); } return new LuceneObjectProjection<>( this, typedInners, - compositor, accumulatorProvider ); + compositor, collectorProvider ); } } } diff --git a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java index b6a60167000..4ed9a537a84 100644 --- a/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java +++ b/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/search/query/dsl/impl/LuceneSearchQuerySelectStepImpl.java @@ -20,7 +20,7 @@ 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.SimpleBooleanPredicateClausesCollector; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -81,7 +81,7 @@ public

LuceneSearchQueryWhereStep select(SearchProjection

project public LuceneSearchQueryWhereStep, LOS> select(SearchProjection... projections) { return select( scope.projectionBuilders().composite() .build( projections, ProjectionCompositor.fromList( projections.length ), - ProjectionAccumulator.nullable() ) ); + ProjectionCollector.nullable() ) ); } @Override diff --git a/documentation/src/main/asciidoc/migration/index.adoc b/documentation/src/main/asciidoc/migration/index.adoc index 7849d45e948..a577f290d5c 100644 --- a/documentation/src/main/asciidoc/migration/index.adoc +++ b/documentation/src/main/asciidoc/migration/index.adoc @@ -103,9 +103,9 @@ interfaces are removed in this version. They have their alternatives in a `org.h Instead, we are introducing the `org.hibernate.search.mapper.pojo.massindexing.MassIndexingTypeGroupMonitor` that can be obtained through `org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor#typeGroupMonitor(..)`. This new type group monitor has more flexibility and also allows implementors to skip total count computations if needed. -- `multi()` methods exposed in various projection DSL steps are deprecated in favour of an `accumulator(ProjectionAccumulator.Provider)`, +- `multi()` methods exposed in various projection DSL steps are deprecated in favour of a `collector(ProjectionCollector.Provider)`, or one of the "shortcut-methods": `.list()`/`.set()`/`.sortedSet()`... -Check the `ProjectionAccumulator` factory methods to see the list of built-in accumulators that provide support for nullable/optional single-valued projections +Check the `ProjectionCollector` factory methods to see the list of built-in collectors that provide support for nullable/optional single-valued projections and for multivalued ones such as lists, sets arrays and more. [[spi]] diff --git a/documentation/src/main/asciidoc/public/reference/_binding-projection.adoc b/documentation/src/main/asciidoc/public/reference/_binding-projection.adoc index 9993c492004..3d0b956163c 100644 --- a/documentation/src/main/asciidoc/public/reference/_binding-projection.adoc +++ b/documentation/src/main/asciidoc/public/reference/_binding-projection.adoc @@ -91,9 +91,9 @@ You can call `.containerElement()` on the context passed to the projection binde in order to discover whether the constructor parameter being bound is some sort of container wrapping the value/values (according to the same rules as <>). If the returned value is a non-empty optional, then the `.constructorParameter()` will provide access to the container type in use. -Additionally, the same context has access to a factory (`.projectionAccumulatorProviderFactory()`) -from which a projection accumulator can be obtained based on a container and element types -(if the container type is `null` then the factory will return the `nullable()` single-valued accumulator). +Additionally, the same context has access to a factory (`.projectionCollectorProviderFactory()`) +from which a projection collector can be obtained based on a container and element types +(if the container type is `null` then the factory will return the `nullable()` single-valued collector). .Implementing and using a `ProjectionBinder` supporting multi-valued projections ==== @@ -105,14 +105,14 @@ include::{sourcedir}/org/hibernate/search/documentation/mapper/orm/binding/proje if and only if the constructor parameter is considered as such that is wrapped in a container, e.g. a multivalued collection. <2> Call `context.definition(...)` to define the projection to use. <3> Here we're failing for single-valued (nullable) constructor parameters, -but we could theoretically fall back to a single-valued projection using the `ProjectionAccumulator.nullable()`. +but we could theoretically fall back to a single-valued projection using the `ProjectionCollector.nullable()`. <4> The projection definition, being multivalued, must implement `ProjectionDefinition>`, where `T` is the expected type of projected values, -`SomeCollection` is one of the supported collection types available in `ProjectionAccumulator`, +`SomeCollection` is one of the supported collection types available in `ProjectionCollector`, and must configure returned projections accordingly. -If the required collection type is not present in the `ProjectionAccumulator`, -then a custom projection accumulator provider can be supplied. +If the required collection type is not present in the `ProjectionCollector`, +then a custom projection collector provider can be supplied. [source, JAVA, indent=0, subs="+callouts"] ---- @@ -144,7 +144,7 @@ or by delegating to it in a custom projection definition. Other methods exposed on the binding context work similarly: -* `.createObjectDefinition(..., ProjectionAccumulator.Provider)` returns an object projection definition with the provided accumulator applied +* `.createObjectDefinition(..., ProjectionCollector.Provider)` returns an object projection definition with the provided collector applied and can be used for <> object projections or object projections wrapped in some other containers. * `.createCompositeDefinition(...)` returns a (single-valued) <> definition diff --git a/documentation/src/main/asciidoc/public/reference/_mapping-projection.adoc b/documentation/src/main/asciidoc/public/reference/_mapping-projection.adoc index f8f13519b99..9eb26dfd6a1 100644 --- a/documentation/src/main/asciidoc/public/reference/_mapping-projection.adoc +++ b/documentation/src/main/asciidoc/public/reference/_mapping-projection.adoc @@ -39,7 +39,7 @@ See <> for more information on how construct + Alternatively, the field projection can be configured explicitly with <>. <4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type. -Multivalued projections <> or their supertype. +Multivalued projections <> or their supertype. + Alternatively, the object projection can be configured explicitly with <>. <5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well. @@ -106,10 +106,10 @@ for the target field, which in general is the type of the property annotated wit (generally mapped using <>), set the parameter type to another custom type annotated with `@ProjectionConstructor`, whose constructor will define which fields to extract from that object field. -* For projections where values are wrapped in some container, be it a multivalued projection represented by some collection or array, +* For projections where values are wrapped in a container, be it a multivalued projection represented by some collection or array, or a single-valued projection wrapped in an optional, follow the rules above for the elements inside the container and then wrap the type with one of the containers -available in `ProjectionAccumulator` (`Iterable`, `Collection`, `List`, etc.), +available in `ProjectionCollector` (`Iterable`, `Collection`, `List`, etc.), e.g. `Iterable`, `Collection`, `List`, etc. [IMPORTANT] @@ -120,13 +120,11 @@ Constructor parameters meant to represent a multivalued projection [NOTE] ==== -In case the `ProjectionAccumulator` does not provide a suitable accumulator for a container/collection +In case the `ProjectionCollector` does not provide a suitable collector for a container/collection needed for a constructor parameter mapping, <> can be implemented -and a user-implemented projection accumulator applied. +and a user-implemented projection collector applied. ==== - - [[mapping-projection-inner-inference-fieldpath]] === [[mapper-orm-mapping-projection-inner-inference-fieldpath]] Inner projection and field path diff --git a/documentation/src/main/asciidoc/public/reference/_search-dsl-projection.adoc b/documentation/src/main/asciidoc/public/reference/_search-dsl-projection.adoc index a18e9d4c093..af45e8c5870 100644 --- a/documentation/src/main/asciidoc/public/reference/_search-dsl-projection.adoc +++ b/documentation/src/main/asciidoc/public/reference/_search-dsl-projection.adoc @@ -72,7 +72,7 @@ See <> for more information on how construct + Alternatively, the field projection can be configured explicitly with <>. <4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type. -Multivalued projections <> or their supertype. +Multivalued projections <> or their supertype. + Alternatively, the object projection can be configured explicitly with <>. <5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well. @@ -403,7 +403,7 @@ include::{sourcedir}/org/hibernate/search/documentation/search/projection/Projec [[search-dsl-projection-field-multivalued]] === Multivalued fields -To return multiple values, and thus allow projection on multivalued fields, use `.accumulator(..)`. +To return multiple values, and thus allow projection on multivalued fields, use `.collector(..)`. This will change the return type of the projection to `SomeContainer` where `T` is what the single-valued projection would have returned. @@ -610,7 +610,7 @@ include::{sourcedir}/org/hibernate/search/documentation/search/projection/Projec [[search-dsl-projection-distance-multivalued]] === Multivalued fields -To return multiple values, and thus allow projection on multivalued fields, use `.accumulator(..)`. +To return multiple values, and thus allow projection on multivalued fields, use `.collector(..)`. This will change the return type of the projection to `SomeContainer`. .Returning the distance to a point, for multivalued fields @@ -834,7 +834,7 @@ See <> for more information on how construct + Alternatively, the field projection can be configured explicitly with <>. <4> To project on an object field, add a constructor parameter named after that field and with its own custom projection type. -Multivalued projections <> or their supertype. +Multivalued projections <> or their supertype. + Alternatively, the object projection can be configured explicitly with <>. <5> Annotate any custom projection type used for object fields with `@ProjectionConstructor` as well. diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/MyFieldProjectionBinder.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/MyFieldProjectionBinder.java index 7fea2356e42..c11f9ebfe24 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/MyFieldProjectionBinder.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/MyFieldProjectionBinder.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Optional; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinition; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; @@ -35,7 +35,7 @@ private static class MyProjectionDefinition public SearchProjection> create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return factory.field( "tags", String.class ) - .accumulator( ProjectionAccumulator.list() ) // <4> + .collector( ProjectionCollector.list() ) // <4> .toProjection(); } } diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java index 27e9cacff1b..5488dc5a9cd 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java @@ -16,7 +16,7 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; @@ -145,7 +145,7 @@ void simple(DocumentationSetupHelper.SetupVariant variant) { f.field( "authors.lastName", String.class ) ) .as( MyBookProjection.Author::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( MyBookProjection::new ) ) .where( f -> f.matchAll() ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java index 2ae2a52eb99..2801f65fc0f 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java @@ -27,7 +27,7 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.query.SearchResult; import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.engine.spatial.GeoPoint; @@ -241,7 +241,7 @@ void field() { withinSearchSession( searchSession -> { // tag::field-multiValued[] List> hits = searchSession.search( Book.class ) - .select( f -> f.field( "authors.lastName", String.class ).accumulator( ProjectionAccumulator.list() ) ) + .select( f -> f.field( "authors.lastName", String.class ).collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .fetchHits( 20 ); // end::field-multiValued[] @@ -334,7 +334,7 @@ void distance() { // tag::distance-multiValued[] GeoPoint center = GeoPoint.of( 47.506060, 2.473916 ); SearchResult> result = searchSession.search( Book.class ) - .select( f -> f.distance( "authors.placeOfBirth", center ).accumulator( ProjectionAccumulator.list() ) ) + .select( f -> f.distance( "authors.placeOfBirth", center ).collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .fetch( 20 ); // end::distance-multiValued[] @@ -581,7 +581,7 @@ void object() { .from( f.field( "authors.firstName", String.class ), // <2> f.field( "authors.lastName", String.class ) ) // <3> .as( MyAuthorName::new ) // <4> - .accumulator( ProjectionAccumulator.list() ) ) // <5> + .collector( ProjectionCollector.list() ) ) // <5> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <6> // end::object-customObject[] @@ -631,7 +631,7 @@ void object() { new MyAuthorNameAndBirthDateAndPlaceOfBirthDistance( (String) list.get( 0 ), (String) list.get( 1 ), (LocalDate) list.get( 2 ), (Double) list.get( 3 ) ) ) - .accumulator( ProjectionAccumulator.list() ) ) // <7> + .collector( ProjectionCollector.list() ) ) // <7> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <8> // end::object-customObject-asList[] @@ -693,7 +693,7 @@ void object() { new MyAuthorNameAndBirthDateAndPlaceOfBirthDistance( (String) array[0], (String) array[1], (LocalDate) array[2], (Double) array[3] ) ) - .accumulator( ProjectionAccumulator.list() ) ) // <7> + .collector( ProjectionCollector.list() ) ) // <7> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <8> // end::object-customObject-asArray[] @@ -746,7 +746,7 @@ void object() { .from( f.field( "authors.firstName", String.class ), // <2> f.field( "authors.lastName", String.class ) ) // <3> .asList() // <4> - .accumulator( ProjectionAccumulator.list() ) ) // <5> + .collector( ProjectionCollector.list() ) ) // <5> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <6> // end::object-list[] @@ -786,7 +786,7 @@ void object() { .from( f.field( "authors.firstName", String.class ), // <2> f.field( "authors.lastName", String.class ) ) // <3> .asArray() // <4> - .accumulator( ProjectionAccumulator.list() ) ) // <5> + .collector( ProjectionCollector.list() ) ) // <5> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <6> // end::object-array[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java index 7451a727c85..634b18115b5 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java @@ -20,7 +20,7 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; @@ -308,7 +308,7 @@ void object_mapped_record(DocumentationSetupHelper.SetupVariant variant) { List> hits = searchSession.search( Book.class ) .select( f -> f.object( "authors" ) // <1> .as( MyAuthorProjection.class ) // <2> - .accumulator( ProjectionAccumulator.list() ) ) // <3> + .collector( ProjectionCollector.list() ) ) // <3> .where( f -> f.matchAll() ) .fetchHits( 20 ); // <4> // end::object-mapped-record[] diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollector.java similarity index 81% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollector.java index 4f1cb54264e..60b091cf715 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollector.java @@ -14,7 +14,8 @@ import org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter; import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext; -import org.hibernate.search.engine.search.projection.spi.BuiltInProjectionAccumulators; +import org.hibernate.search.engine.search.projection.spi.BuiltInProjectionCollectors; +import org.hibernate.search.util.common.annotation.Incubating; /** * A variation on {@link java.util.stream.Collector} suitable for projections on field values. @@ -37,76 +38,77 @@ * before and after being transformed. * @param The type of the final result containing values of type {@code V}. */ -public interface ProjectionAccumulator { +@Incubating +public interface ProjectionCollector { /** - * @return The projection accumulator capable of accumulating single-valued projections in an as-is form, + * @return The projection collector capable of accumulating single-valued projections in an as-is form, * i.e. the value is returned without any extra transformations. * @param The type of values to accumulate. */ - static ProjectionAccumulator.Provider nullable() { - return BuiltInProjectionAccumulators.nullable(); + static ProjectionCollector.Provider nullable() { + return BuiltInProjectionCollectors.nullable(); } /** - * @return The projection accumulator capable of accumulating single-valued projections and wrapping the values in an {@link Optional}. + * @return The projection collector capable of accumulating single-valued projections and wrapping the values in an {@link Optional}. * @param The type of values to accumulate. */ static Provider> optional() { - return BuiltInProjectionAccumulators.optional(); + return BuiltInProjectionCollectors.optional(); } /** * @param converter The function that defines how to convert a list of collected values to the final collection. - * @return An accumulator based on a list as a temporary storage. + * @return An collector based on a list as a temporary storage. * @param The type of values to accumulate. * @param The type of the resulting collection. */ static Provider simple(Function, C> converter) { - return BuiltInProjectionAccumulators.simple( converter ); + return BuiltInProjectionCollectors.simple( converter ); } /** - * @return The projection accumulator capable of accumulating multivalued projections as a {@link List}. + * @return The projection collector capable of accumulating multivalued projections as a {@link List}. * @param The type of values to accumulate. */ static Provider> list() { - return BuiltInProjectionAccumulators.list(); + return BuiltInProjectionCollectors.list(); } /** - * @return The projection accumulator capable of accumulating multivalued projections as a {@link Set}. + * @return The projection collector capable of accumulating multivalued projections as a {@link Set}. * @param The type of values to accumulate. */ static Provider> set() { - return BuiltInProjectionAccumulators.set(); + return BuiltInProjectionCollectors.set(); } /** - * @return The projection accumulator capable of accumulating multivalued projections as a {@link SortedSet}. + * @return The projection collector capable of accumulating multivalued projections as a {@link SortedSet}. * @param The type of values to accumulate. */ static Provider> sortedSet() { - return BuiltInProjectionAccumulators.sortedSet(); + return BuiltInProjectionCollectors.sortedSet(); } /** - * @return The projection accumulator capable of accumulating multivalued projections as a {@link SortedSet} + * @return The projection collector capable of accumulating multivalued projections as a {@link SortedSet} * using a custom comparator. * @param comparator The comparator which should be used by the sorted set. * @param The type of values to accumulate. */ static Provider> sortedSet(Comparator comparator) { - return BuiltInProjectionAccumulators.sortedSet( comparator ); + return BuiltInProjectionCollectors.sortedSet( comparator ); } /** - * @return The projection accumulator capable of accumulating multivalued projections as an array. + * @return The projection collector capable of accumulating multivalued projections as an array. * @param componentType The type of the array elements. * @param The type of values to accumulate. */ static Provider array(Class componentType) { - return BuiltInProjectionAccumulators.array( componentType ); + return BuiltInProjectionCollectors.array( componentType ); } /** @@ -226,9 +228,9 @@ default R empty() { } /** - * Provides an accumulator for a given type of values to accumulate ({@code T}). + * Provides a collector for a given type of values to accumulate ({@code T}). *

- * The provider may always return the same accumulator, + * The provider may always return the same collector, * if generics are irrelevant and it's safe to do so. * * @param The type of values to accumulate after being transformed. @@ -237,12 +239,12 @@ default R empty() { interface Provider { /** * @param The type of values to accumulate before being transformed. - * @return An accumulator for the given type. + * @return A collector for the given type. */ - ProjectionAccumulator get(); + ProjectionCollector get(); /** - * @return {@code true} if accumulators returned by {@link #get()} can only accept a single value, + * @return {@code true} if collectors returned by {@link #get()} can only accept a single value, * and will fail beyond that. */ boolean isSingleValued(); diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulatorProviderFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollectorProviderFactory.java similarity index 51% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulatorProviderFactory.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollectorProviderFactory.java index 89ccebc8439..821d8021342 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionAccumulatorProviderFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/ProjectionCollectorProviderFactory.java @@ -7,21 +7,21 @@ import org.hibernate.search.util.common.annotation.Incubating; /** - * Defines the factory that can create {@link ProjectionAccumulator.Provider projection accumulator providers} based + * Defines the factory that can create {@link ProjectionCollector.Provider projection collector providers} based * on a container type {@code R} and container element type {@code U}. */ @Incubating -public interface ProjectionAccumulatorProviderFactory { +public interface ProjectionCollectorProviderFactory { /** * * @param containerType The type of the expected container. - * Passing a {@code null} value as a container type will result in {@link ProjectionAccumulator#nullable() a nullable accumulator} - * being returned, i.e. an accumulator that does not wrap the value in any sort of container. + * Passing a {@code null} value as a container type will result in {@link ProjectionCollector#nullable() a nullable collector} + * being returned, i.e. a collector that does not wrap the value in any sort of container. * @param containerElementType The type of the container elements - * @return The projection accumulator provider for a requested container/element types. - * @param The type of values to accumulate after being transformed. + * @return The projection collector provider for a requested container/element types. + * @param The type of values to collector after being transformed. * @param The type of the final result containing values of type {@code V}. */ - ProjectionAccumulator.Provider projectionAccumulatorProvider(Class containerType, + ProjectionCollector.Provider projectionCollectorProvider(Class containerType, Class containerElementType); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ConstantProjectionDefinition.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ConstantProjectionDefinition.java index 727a23df000..a931329c1a4 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ConstantProjectionDefinition.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ConstantProjectionDefinition.java @@ -11,7 +11,7 @@ import java.util.SortedSet; import org.hibernate.search.engine.environment.bean.BeanHolder; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; @@ -42,7 +42,7 @@ public static BeanHolder> nullValue() { } /** - * @deprecated Use {@link #empty(ProjectionAccumulator.Provider)} instead. + * @deprecated Use {@link #empty(ProjectionCollector.Provider)} instead. */ @Deprecated(since = "8.0") @SuppressWarnings("unchecked") // EMPTY_LIST_INSTANCE works for any T @@ -51,19 +51,19 @@ public static BeanHolder>> emptyList() } @SuppressWarnings("unchecked") // empty collections works for any T - public static BeanHolder> empty(ProjectionAccumulator.Provider accumulator) { - T empty = accumulator.get().empty(); + public static BeanHolder> empty(ProjectionCollector.Provider collector) { + T empty = collector.get().empty(); - if ( ProjectionAccumulator.nullable().equals( accumulator ) ) { + if ( ProjectionCollector.nullable().equals( collector ) ) { return nullValue(); } - if ( ProjectionAccumulator.optional().equals( accumulator ) ) { + if ( ProjectionCollector.optional().equals( collector ) ) { return (BeanHolder>) OPTIONAL_EMPTY_INSTANCE; } - if ( ProjectionAccumulator.list().equals( accumulator ) ) { + if ( ProjectionCollector.list().equals( collector ) ) { return (BeanHolder>) EMPTY_LIST_INSTANCE; } - if ( ProjectionAccumulator.set().equals( accumulator ) ) { + if ( ProjectionCollector.set().equals( collector ) ) { return (BeanHolder>) EMPTY_SET_INSTANCE; } if ( empty instanceof SortedSet ) { diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/DistanceProjectionDefinition.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/DistanceProjectionDefinition.java index c3f8f4c5d68..e1d2b39442b 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/DistanceProjectionDefinition.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/DistanceProjectionDefinition.java @@ -6,7 +6,7 @@ import java.util.List; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; @@ -82,7 +82,7 @@ public SearchProjection> create(SearchProjectionFactory facto ProjectionDefinitionContext context) { return factory.withParameters( params -> factory .distance( fieldPath, params.get( parameterName, GeoPoint.class ) ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) .unit( unit ) ).toProjection(); } @@ -90,17 +90,17 @@ public SearchProjection> create(SearchProjectionFactory facto @Incubating public static final class WrappedValued extends DistanceProjectionDefinition { - private final ProjectionAccumulator.Provider accumulator; + private final ProjectionCollector.Provider collector; public WrappedValued(String fieldPath, String parameterName, DistanceUnit unit, - ProjectionAccumulator.Provider accumulator) { + ProjectionCollector.Provider collector) { super( fieldPath, parameterName, unit ); - this.accumulator = accumulator; + this.collector = collector; } @Override protected boolean multi() { - return !accumulator.isSingleValued(); + return !collector.isSingleValued(); } @Override @@ -108,7 +108,7 @@ public SearchProjection create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return factory.withParameters( params -> factory .distance( fieldPath, params.get( parameterName, GeoPoint.class ) ) - .accumulator( accumulator ) + .collector( collector ) .unit( unit ) ).toProjection(); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/FieldProjectionDefinition.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/FieldProjectionDefinition.java index 3b8c6dd59b4..b19befe9fc6 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/FieldProjectionDefinition.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/FieldProjectionDefinition.java @@ -7,7 +7,7 @@ import java.util.List; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; @@ -78,30 +78,30 @@ protected boolean multi() { @Override public SearchProjection> create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return factory.field( fieldPath, fieldType, valueModel ) - .accumulator( ProjectionAccumulator.list() ).toProjection(); + .collector( ProjectionCollector.list() ).toProjection(); } } @Incubating public static final class AccumulatedValued extends FieldProjectionDefinition { - private final ProjectionAccumulator.Provider accumulator; + private final ProjectionCollector.Provider collector; - public AccumulatedValued(String fieldPath, Class fieldType, ProjectionAccumulator.Provider accumulator, + public AccumulatedValued(String fieldPath, Class fieldType, ProjectionCollector.Provider collector, ValueModel valueModel) { super( fieldPath, fieldType, valueModel ); - this.accumulator = accumulator; + this.collector = collector; } @Override protected boolean multi() { - return !accumulator.isSingleValued(); + return !collector.isSingleValued(); } @Override public SearchProjection create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return factory.field( fieldPath, fieldType, valueModel ) - .accumulator( accumulator ).toProjection(); + .collector( collector ).toProjection(); } } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ObjectProjectionDefinition.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ObjectProjectionDefinition.java index 2b7cb9b106e..05c57bf3de4 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ObjectProjectionDefinition.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/definition/spi/ObjectProjectionDefinition.java @@ -6,7 +6,7 @@ import java.util.List; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; @@ -83,30 +83,30 @@ protected boolean multi() { public SearchProjection> create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return delegate.apply( factory.withRoot( fieldPath ), factory.object( fieldPath ), context ) - .accumulator( ProjectionAccumulator.list() ).toProjection(); + .collector( ProjectionCollector.list() ).toProjection(); } } @Incubating public static final class WrappedValued extends ObjectProjectionDefinition { - private final ProjectionAccumulator.Provider accumulator; + private final ProjectionCollector.Provider collector; public WrappedValued(String fieldPath, CompositeProjectionDefinition delegate, - ProjectionAccumulator.Provider accumulator) { + ProjectionCollector.Provider collector) { super( fieldPath, delegate ); - this.accumulator = accumulator; + this.collector = collector; } @Override protected boolean multi() { - return !accumulator.isSingleValued(); + return !collector.isSingleValued(); } @Override public SearchProjection create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return delegate.apply( factory.withRoot( fieldPath ), factory.object( fieldPath ), context ) - .accumulator( accumulator ).toProjection(); + .collector( collector ).toProjection(); } } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/CompositeProjectionValueStep.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/CompositeProjectionValueStep.java index bd7d732b5a2..8f5898246e6 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/CompositeProjectionValueStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/CompositeProjectionValueStep.java @@ -10,18 +10,18 @@ import java.util.Set; import java.util.SortedSet; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.annotation.Incubating; /** * The step in a composite projection definition - * where (optionally) the projection accumulator can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) + * where (optionally) the projection collector can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) * or wrapped in some other container (e.g. {@code Optional<..>}), * and where optional parameters can be set. *

- * By default (if {@link #accumulator(ProjectionAccumulator.Provider)} is not called), the projection is single-valued. + * By default (if {@link #collector(ProjectionCollector.Provider)} is not called), the projection is single-valued. * - * @param The next step if a method other than {@link #accumulator(ProjectionAccumulator.Provider)} is called, + * @param The next step if a method other than {@link #collector(ProjectionCollector.Provider)} is called, * i.e. the return type of methods defined in {@link CompositeProjectionOptionsStep} * when called directly on this object. * @param The type of composed projections. @@ -40,25 +40,26 @@ public interface CompositeProjectionValueStep> multi() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** * Defines how to accumulate composite projection values. *

- * Calling {@code .accumulator(someMultiValuedAccumulatorProvider) } is mandatory for multi-valued fields, - * e.g. {@code .accumulator(ProjectionAccumulator.list())}, + * Calling {@code .collector(someMultiValuedCollectorProvider) } is mandatory for multi-valued fields, + * e.g. {@code .collector(ProjectionCollector.list())}, * otherwise the projection will throw an exception upon creating the query. * - * @param accumulator The accumulator provider to apply to this projection. + * @param collector The collector provider to apply to this projection. * @return A new step to define optional parameters for the accumulated projections. * @param The type of the final result. */ - CompositeProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator); + @Incubating + CompositeProjectionOptionsStep collector(ProjectionCollector.Provider collector); /** * Defines the projection as single-valued wrapped in an {@link Optional}, i.e. returning {@code Optional} instead of {@code T}. @@ -67,7 +68,7 @@ default CompositeProjectionOptionsStep> multi() { */ @Incubating default CompositeProjectionOptionsStep> optional() { - return accumulator( ProjectionAccumulator.optional() ); + return collector( ProjectionCollector.optional() ); } /** @@ -76,7 +77,7 @@ default CompositeProjectionOptionsStep> optional() { */ @Incubating default CompositeProjectionOptionsStep> list() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** @@ -85,7 +86,7 @@ default CompositeProjectionOptionsStep> list() { */ @Incubating default CompositeProjectionOptionsStep> set() { - return accumulator( ProjectionAccumulator.set() ); + return collector( ProjectionCollector.set() ); } /** @@ -94,7 +95,7 @@ default CompositeProjectionOptionsStep> set() { */ @Incubating default CompositeProjectionOptionsStep> sortedSet() { - return accumulator( ProjectionAccumulator.sortedSet() ); + return collector( ProjectionCollector.sortedSet() ); } /** @@ -104,7 +105,7 @@ default CompositeProjectionOptionsStep> sortedSet() { */ @Incubating default CompositeProjectionOptionsStep> sortedSet(Comparator comparator) { - return accumulator( ProjectionAccumulator.sortedSet( comparator ) ); + return collector( ProjectionCollector.sortedSet( comparator ) ); } /** @@ -114,7 +115,7 @@ default CompositeProjectionOptionsStep> sortedSet(Comparator */ @Incubating default CompositeProjectionOptionsStep array(Class type) { - return accumulator( ProjectionAccumulator.array( type ) ); + return collector( ProjectionCollector.array( type ) ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/DistanceToFieldProjectionValueStep.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/DistanceToFieldProjectionValueStep.java index e4862e487e5..34ba0f5adae 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/DistanceToFieldProjectionValueStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/DistanceToFieldProjectionValueStep.java @@ -10,19 +10,19 @@ import java.util.Set; import java.util.SortedSet; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.annotation.Incubating; /** * The initial step in a "distance to field" projection definition, - * where (optionally) the projection accumulator can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) + * where (optionally) the projection collector can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) * or wrapped in some other container (e.g. {@code Optional<..>}), * and where optional parameters can be set. *

- * By default (if {@link #accumulator(ProjectionAccumulator.Provider)} is not called), the projection is considered single-valued, + * By default (if {@link #collector(ProjectionCollector.Provider)} is not called), the projection is considered single-valued, * and its creation will fail if the field is multi-valued. * - * @param The next step if a method other than {@link #accumulator(ProjectionAccumulator.Provider)} is called, + * @param The next step if a method other than {@link #collector(ProjectionCollector.Provider)} is called, * i.e. the return type of methods defined in {@link FieldProjectionOptionsStep} * when called directly on this object. * @param The type of projected distances. @@ -37,25 +37,26 @@ public interface DistanceToFieldProjectionValueStep> multi() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** * Defines how to accumulate distance projection values. *

- * Calling {@code .accumulator(someMultiValuedAccumulatorProvider) } is mandatory for multi-valued fields, - * e.g. {@code .accumulator(ProjectionAccumulator.list())}, + * Calling {@code .collector(someMultiValuedCollectorProvider) } is mandatory for multi-valued fields, + * e.g. {@code .collector(ProjectionCollector.list())}, * otherwise the projection will throw an exception upon creating the query. * - * @param accumulator The accumulator provider to apply to this projection. + * @param collector The collector provider to apply to this projection. * @return A new step to define optional parameters for the accumulated projections. * @param The type of the final result. */ - DistanceToFieldProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator); + @Incubating + DistanceToFieldProjectionOptionsStep collector(ProjectionCollector.Provider collector); /** * Defines the projection as single-valued wrapped in an {@link Optional}, i.e. returning {@code Optional} instead of {@code T}. @@ -64,7 +65,7 @@ default DistanceToFieldProjectionOptionsStep> multi() { */ @Incubating default DistanceToFieldProjectionOptionsStep> optional() { - return accumulator( ProjectionAccumulator.optional() ); + return collector( ProjectionCollector.optional() ); } /** @@ -73,7 +74,7 @@ default DistanceToFieldProjectionOptionsStep> optional() { */ @Incubating default DistanceToFieldProjectionOptionsStep> list() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** @@ -82,7 +83,7 @@ default DistanceToFieldProjectionOptionsStep> list() { */ @Incubating default DistanceToFieldProjectionOptionsStep> set() { - return accumulator( ProjectionAccumulator.set() ); + return collector( ProjectionCollector.set() ); } /** @@ -91,7 +92,7 @@ default DistanceToFieldProjectionOptionsStep> set() { */ @Incubating default DistanceToFieldProjectionOptionsStep> sortedSet() { - return accumulator( ProjectionAccumulator.sortedSet() ); + return collector( ProjectionCollector.sortedSet() ); } /** @@ -101,7 +102,7 @@ default DistanceToFieldProjectionOptionsStep> sortedSet() { */ @Incubating default DistanceToFieldProjectionOptionsStep> sortedSet(Comparator comparator) { - return accumulator( ProjectionAccumulator.sortedSet( comparator ) ); + return collector( ProjectionCollector.sortedSet( comparator ) ); } /** @@ -111,6 +112,6 @@ default DistanceToFieldProjectionOptionsStep> sortedSet(Comparat */ @Incubating default DistanceToFieldProjectionOptionsStep array(Class type) { - return accumulator( ProjectionAccumulator.array( type ) ); + return collector( ProjectionCollector.array( type ) ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/FieldProjectionValueStep.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/FieldProjectionValueStep.java index 68ecbde5306..3b84e67c205 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/FieldProjectionValueStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/FieldProjectionValueStep.java @@ -10,19 +10,19 @@ import java.util.Set; import java.util.SortedSet; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.annotation.Incubating; /** * The initial step in a "field" projection definition, - * where (optionally) the projection accumulator can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) + * where (optionally) the projection collector can be provided, e.g. to mark a projection as multi-valued (returning {@code List}/{@code Set} etc.) * or wrapped in some other container (e.g. {@code Optional<..>}), * and where optional parameters can be set. *

- * By default (if {@link #accumulator(ProjectionAccumulator.Provider)} is not called), the projection is considered single-valued, + * By default (if {@link #collector(ProjectionCollector.Provider)} is not called), the projection is considered single-valued, * and its creation will fail if the field is multi-valued. * - * @param The next step if a method other than {@link #accumulator(ProjectionAccumulator.Provider)} is called, + * @param The next step if a method other than {@link #collector(ProjectionCollector.Provider)} is called, * i.e. the return type of methods defined in {@link FieldProjectionOptionsStep} * when called directly on this object. * @param The type of projected field values. @@ -37,25 +37,26 @@ public interface FieldProjectionValueStep> multi() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** * Defines how to accumulate field projection values. *

- * Calling {@code .accumulator(someMultiValuedAccumulatorProvider) } is mandatory for multivalued fields, - * e.g. {@code .accumulator(ProjectionAccumulator.list())}, + * Calling {@code .collector(someMultiValuedCollectorProvider) } is mandatory for multivalued fields, + * e.g. {@code .collector(ProjectionCollector.list())}, * otherwise the projection will throw an exception upon creating the query. * - * @param accumulator The accumulator provider to apply to this projection. + * @param collector The collector provider to apply to this projection. * @return A new step to define optional parameters for the accumulated projections. * @param The type of the final result. */ - FieldProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator); + @Incubating + FieldProjectionOptionsStep collector(ProjectionCollector.Provider collector); /** * Defines the projection as single-valued wrapped in an {@link Optional}, i.e. returning {@code Optional} instead of {@code T}. @@ -64,7 +65,7 @@ default FieldProjectionOptionsStep> multi() { */ @Incubating default FieldProjectionOptionsStep> optional() { - return accumulator( ProjectionAccumulator.optional() ); + return collector( ProjectionCollector.optional() ); } /** @@ -73,7 +74,7 @@ default FieldProjectionOptionsStep> optional() { */ @Incubating default FieldProjectionOptionsStep> list() { - return accumulator( ProjectionAccumulator.list() ); + return collector( ProjectionCollector.list() ); } /** @@ -82,7 +83,7 @@ default FieldProjectionOptionsStep> list() { */ @Incubating default FieldProjectionOptionsStep> set() { - return accumulator( ProjectionAccumulator.set() ); + return collector( ProjectionCollector.set() ); } /** @@ -91,7 +92,7 @@ default FieldProjectionOptionsStep> set() { */ @Incubating default FieldProjectionOptionsStep> sortedSet() { - return accumulator( ProjectionAccumulator.sortedSet() ); + return collector( ProjectionCollector.sortedSet() ); } /** @@ -101,7 +102,7 @@ default FieldProjectionOptionsStep> sortedSet() { */ @Incubating default FieldProjectionOptionsStep> sortedSet(Comparator comparator) { - return accumulator( ProjectionAccumulator.sortedSet( comparator ) ); + return collector( ProjectionCollector.sortedSet( comparator ) ); } /** @@ -111,6 +112,6 @@ default FieldProjectionOptionsStep> sortedSet(Comparator comp */ @Incubating default FieldProjectionOptionsStep array(Class type) { - return accumulator( ProjectionAccumulator.array( type ) ); + return collector( ProjectionCollector.array( type ) ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/HighlightProjectionOptionsStep.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/HighlightProjectionOptionsStep.java index 7dfb5c656f2..8e0a25f22a5 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/HighlightProjectionOptionsStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/HighlightProjectionOptionsStep.java @@ -11,7 +11,7 @@ import java.util.function.Function; import org.hibernate.search.engine.search.highlighter.dsl.HighlighterOptionsStep; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.annotation.Incubating; /** @@ -41,17 +41,17 @@ public interface HighlightProjectionOptionsStep extends HighlightProjectionFinal * * @return A final step in the highlight projection definition. * @see HighlighterOptionsStep#numberOfFragments(int) - * @deprecated Use the {@link #accumulator(ProjectionAccumulator.Provider)} instead, e.g. {@code .accumulator(ProjectionAccumulator.single())} + * @deprecated Use the {@link #collector(ProjectionCollector.Provider)} instead, e.g. {@code .collector(ProjectionCollector.single())} */ @Deprecated(since = "8.0") SingleHighlightProjectionFinalStep single(); /** - * Defines the accumulator to apply to the highlighted strings. + * Defines the collector to apply to the highlighted strings. *

* By default, highlighting results in a list {@code List} of highlighted strings. * This method allows changing the returned type to a different collection of strings, e.g. {@code Set}/{@code String[]} - * or obtaining a single-valued projection (i.e. {@code projectionAccumulatorProvider.isSingleValued () == true}). + * or obtaining a single-valued projection (i.e. {@code projectionCollectorProvider.isSingleValued () == true}). *

* Note: single-valued projections can only be used when the highlighter * that creates highlighted fragments for this projection is configured @@ -59,11 +59,12 @@ public interface HighlightProjectionOptionsStep extends HighlightProjectionFinal * is applied to the highlighter. * Otherwise, it will lead to an exception being thrown when the query is created. * - * @param accumulator The accumulator provider to apply to this projection. + * @param collector The collector provider to apply to this projection. * @return A final step in the highlight projection definition. * @param The type of the final result. */ - ProjectionFinalStep accumulator(ProjectionAccumulator.Provider accumulator); + @Incubating + ProjectionFinalStep collector(ProjectionCollector.Provider collector); /** * Defines the projection as single-valued, i.e. returning {@code String} instead of {@code List}. @@ -78,7 +79,7 @@ public interface HighlightProjectionOptionsStep extends HighlightProjectionFinal */ @Incubating default ProjectionFinalStep nullable() { - return accumulator( ProjectionAccumulator.nullable() ); + return collector( ProjectionCollector.nullable() ); } /** @@ -94,7 +95,7 @@ default ProjectionFinalStep nullable() { */ @Incubating default ProjectionFinalStep> optional() { - return accumulator( ProjectionAccumulator.optional() ); + return collector( ProjectionCollector.optional() ); } /** @@ -103,7 +104,7 @@ default ProjectionFinalStep> optional() { */ @Incubating default ProjectionFinalStep> set() { - return accumulator( ProjectionAccumulator.set() ); + return collector( ProjectionCollector.set() ); } /** @@ -112,7 +113,7 @@ default ProjectionFinalStep> set() { */ @Incubating default ProjectionFinalStep> sortedSet() { - return accumulator( ProjectionAccumulator.sortedSet() ); + return collector( ProjectionCollector.sortedSet() ); } /** @@ -122,7 +123,7 @@ default ProjectionFinalStep> sortedSet() { */ @Incubating default ProjectionFinalStep> sortedSet(Comparator comparator) { - return accumulator( ProjectionAccumulator.sortedSet( comparator ) ); + return collector( ProjectionCollector.sortedSet( comparator ) ); } /** @@ -131,6 +132,6 @@ default ProjectionFinalStep> sortedSet(Comparator comp */ @Incubating default ProjectionFinalStep array() { - return accumulator( ProjectionAccumulator.array( String.class ) ); + return collector( ProjectionCollector.array( String.class ) ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java index 2b5f6785e2c..1fef0644846 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/SearchProjectionFactory.java @@ -12,7 +12,7 @@ import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.engine.search.common.NamedValues; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.util.common.SearchException; @@ -218,7 +218,7 @@ default FieldProjectionValueStep field(String fieldPath, * Compared to the basic {@link #composite() composite projection}, * an object projection is bound to a specific object field, * and thus it yields zero, one or many values, as many as there are objects in the targeted object field. - * Therefore, you must take care of calling {@link CompositeProjectionValueStep#accumulator(ProjectionAccumulator.Provider)} + * Therefore, you must take care of calling {@link CompositeProjectionValueStep#collector(ProjectionCollector.Provider)} * if the object field is multi-valued. * * @param objectFieldPath The path to the object field whose object(s) will be extracted. @@ -233,7 +233,7 @@ default FieldProjectionValueStep field(String fieldPath, * On contrary to the {@link #object(String) object projection}, * a composite projection is not bound to a specific object field, * and thus it will always yield one and only one value, - * regardless of whether {@link CompositeProjectionValueStep#accumulator(ProjectionAccumulator.Provider)} is called. + * regardless of whether {@link CompositeProjectionValueStep#collector(ProjectionCollector.Provider)} is called. * * @return A DSL step where the "composite" projection can be defined in more details. */ diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionOptionsStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionOptionsStepImpl.java index c5583bf4152..764bba1dcee 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionOptionsStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionOptionsStepImpl.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionOptionsStep; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; @@ -16,19 +16,19 @@ public class CompositeProjectionOptionsStepImpl final CompositeProjectionBuilder builder; final SearchProjection[] inners; final ProjectionCompositor compositor; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; public CompositeProjectionOptionsStepImpl(CompositeProjectionBuilder builder, SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { this.builder = builder; this.inners = inners; this.compositor = compositor; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override public SearchProjection

toProjection() { - return builder.build( inners, compositor, accumulatorProvider ); + return builder.build( inners, compositor, collectorProvider ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionValueStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionValueStepImpl.java index c37ebb29e2c..3be534ad2fb 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionValueStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/CompositeProjectionValueStepImpl.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionOptionsStep; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionValueStep; @@ -17,11 +17,11 @@ public class CompositeProjectionValueStepImpl public CompositeProjectionValueStepImpl(CompositeProjectionBuilder builder, SearchProjection[] inners, ProjectionCompositor compositor) { - super( builder, inners, compositor, ProjectionAccumulator.nullable() ); + super( builder, inners, compositor, ProjectionCollector.nullable() ); } @Override - public CompositeProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator) { - return new CompositeProjectionOptionsStepImpl<>( builder, inners, compositor, accumulator ); + public CompositeProjectionOptionsStep collector(ProjectionCollector.Provider collector) { + return new CompositeProjectionOptionsStepImpl<>( builder, inners, compositor, collector ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionOptionsStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionOptionsStepImpl.java index b276b7a6b27..3cea9dd1e75 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionOptionsStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionOptionsStepImpl.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionOptionsStep; import org.hibernate.search.engine.search.projection.spi.DistanceToFieldProjectionBuilder; @@ -15,12 +15,12 @@ public class DistanceToFieldProjectionOptionsStepImpl

implements DistanceToFieldProjectionOptionsStep, P> { protected final DistanceToFieldProjectionBuilder distanceFieldProjectionBuilder; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; DistanceToFieldProjectionOptionsStepImpl(DistanceToFieldProjectionBuilder distanceFieldProjectionBuilder, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { this.distanceFieldProjectionBuilder = distanceFieldProjectionBuilder; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override @@ -33,7 +33,7 @@ public DistanceToFieldProjectionOptionsStepImpl

unit(DistanceUnit unit) { @Override public SearchProjection

toProjection() { - return distanceFieldProjectionBuilder.build( accumulatorProvider ); + return distanceFieldProjectionBuilder.build( collectorProvider ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionValueStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionValueStepImpl.java index a77c4c6d033..26e1a5e4d11 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionValueStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/DistanceToFieldProjectionValueStepImpl.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionOptionsStep; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionValueStep; import org.hibernate.search.engine.search.projection.dsl.spi.SearchProjectionDslContext; @@ -18,14 +18,15 @@ public final class DistanceToFieldProjectionValueStepImpl public DistanceToFieldProjectionValueStepImpl(SearchProjectionDslContext dslContext, String fieldPath, GeoPoint center) { super( dslContext.scope().fieldQueryElement( fieldPath, ProjectionTypeKeys.DISTANCE ), - ProjectionAccumulator.nullable() ); + ProjectionCollector.nullable() ); distanceFieldProjectionBuilder.center( center ); } @Override - public DistanceToFieldProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator) { + public DistanceToFieldProjectionOptionsStep collector(ProjectionCollector.Provider collector) { return new DistanceToFieldProjectionOptionsStepImpl<>( distanceFieldProjectionBuilder, - accumulator ); + collector + ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionOptionsStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionOptionsStepImpl.java index c18eb5e32dd..95b020b8dd3 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionOptionsStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionOptionsStepImpl.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.FieldProjectionOptionsStep; import org.hibernate.search.engine.search.projection.spi.FieldProjectionBuilder; @@ -13,17 +13,17 @@ public class FieldProjectionOptionsStepImpl implements FieldProjectionOptionsStep, P> { protected final FieldProjectionBuilder fieldProjectionBuilder; - private final ProjectionAccumulator.Provider accumulatorProvider; + private final ProjectionCollector.Provider collectorProvider; FieldProjectionOptionsStepImpl(FieldProjectionBuilder fieldProjectionBuilder, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { this.fieldProjectionBuilder = fieldProjectionBuilder; - this.accumulatorProvider = accumulatorProvider; + this.collectorProvider = collectorProvider; } @Override public SearchProjection

toProjection() { - return fieldProjectionBuilder.build( accumulatorProvider ); + return fieldProjectionBuilder.build( collectorProvider ); } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionValueStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionValueStepImpl.java index 8fed1af6215..24605d0d583 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionValueStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/FieldProjectionValueStepImpl.java @@ -5,7 +5,7 @@ package org.hibernate.search.engine.search.projection.dsl.impl; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.FieldProjectionOptionsStep; import org.hibernate.search.engine.search.projection.dsl.FieldProjectionValueStep; @@ -20,12 +20,12 @@ public FieldProjectionValueStepImpl(SearchProjectionDslContext dslContext, St Class clazz, ValueModel valueModel) { super( dslContext.scope().fieldQueryElement( fieldPath, ProjectionTypeKeys.FIELD ) .type( clazz, valueModel ), - ProjectionAccumulator.nullable() ); + ProjectionCollector.nullable() ); } @Override - public FieldProjectionOptionsStep accumulator(ProjectionAccumulator.Provider accumulator) { - return new FieldProjectionOptionsStepImpl<>( fieldProjectionBuilder, accumulator ); + public FieldProjectionOptionsStep collector(ProjectionCollector.Provider collector) { + return new FieldProjectionOptionsStepImpl<>( fieldProjectionBuilder, collector ); } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/HighlightProjectionOptionsStepImpl.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/HighlightProjectionOptionsStepImpl.java index e46ce52702b..0122d728a1e 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/HighlightProjectionOptionsStepImpl.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/impl/HighlightProjectionOptionsStepImpl.java @@ -6,7 +6,7 @@ import java.util.List; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.HighlightProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.HighlightProjectionOptionsStep; @@ -39,33 +39,33 @@ public SingleHighlightProjectionFinalStep single() { } @Override - public ProjectionFinalStep accumulator( - org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider accumulator) { - return new AccumulatorHighlightProjectionFinalStepImpl<>( accumulator ); + public ProjectionFinalStep collector( + ProjectionCollector.Provider collector) { + return new CollectorHighlightProjectionFinalStepImpl<>( collector ); } @Override public SearchProjection> toProjection() { - return highlight.build( ProjectionAccumulator.list() ); + return highlight.build( ProjectionCollector.list() ); } - private class SingleHighlightProjectionFinalStepImpl extends AccumulatorHighlightProjectionFinalStepImpl + private class SingleHighlightProjectionFinalStepImpl extends CollectorHighlightProjectionFinalStepImpl implements SingleHighlightProjectionFinalStep { public SingleHighlightProjectionFinalStepImpl() { - super( ProjectionAccumulator.nullable() ); + super( ProjectionCollector.nullable() ); } } - private class AccumulatorHighlightProjectionFinalStepImpl implements ProjectionFinalStep { - private final ProjectionAccumulator.Provider accumulatorProvider; + private class CollectorHighlightProjectionFinalStepImpl implements ProjectionFinalStep { + private final ProjectionCollector.Provider collectorProvider; - private AccumulatorHighlightProjectionFinalStepImpl(ProjectionAccumulator.Provider accumulatorProvider) { - this.accumulatorProvider = accumulatorProvider; + private CollectorHighlightProjectionFinalStepImpl(ProjectionCollector.Provider collectorProvider) { + this.collectorProvider = collectorProvider; } @Override public SearchProjection toProjection() { - return highlight.build( accumulatorProvider ); + return highlight.build( collectorProvider ); } } } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/spi/HighlightProjectionBuilder.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/spi/HighlightProjectionBuilder.java index 0cb7e31647c..2d0c9b0d905 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/spi/HighlightProjectionBuilder.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/dsl/spi/HighlightProjectionBuilder.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.dsl.spi; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; public abstract class HighlightProjectionBuilder { @@ -20,5 +20,5 @@ public HighlightProjectionBuilder highlighter(String highlighterName) { return this; } - public abstract SearchProjection build(ProjectionAccumulator.Provider accumulatorProvider); + public abstract SearchProjection build(ProjectionCollector.Provider collectorProvider); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionCollector.java similarity index 65% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionCollector.java index 0fe97fed863..17de6a669c3 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ArrayProjectionCollector.java @@ -7,19 +7,21 @@ import java.lang.reflect.Array; import java.util.List; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link ProjectionAccumulator} that can accumulate any number of values into a {@code V[]}. + * A {@link ProjectionCollector} that can accumulate any number of values into a {@code V[]}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -final class ArrayProjectionAccumulator extends ListBasedProjectionAccumulator { +final class ArrayProjectionCollector extends ListBasedProjectionCollector { static Provider provider(Class elementType) { return new ArrayProvider<>( elementType ); } - private ArrayProjectionAccumulator(Class elementType) { + private ArrayProjectionCollector(Class elementType) { this.elementType = elementType; } @@ -38,15 +40,15 @@ public V[] doFinish(List accumulated) { @SuppressWarnings("unchecked") private static class ArrayProvider implements Provider { - private final ArrayProjectionAccumulator instance; + private final ArrayProjectionCollector instance; private ArrayProvider(Class elementType) { - instance = new ArrayProjectionAccumulator<>( elementType ); + instance = new ArrayProjectionCollector<>( elementType ); } @Override - public org.hibernate.search.engine.search.projection.ProjectionAccumulator get() { - return (org.hibernate.search.engine.search.projection.ProjectionAccumulator) instance; + public ProjectionCollector get() { + return (ProjectionCollector) instance; } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionCollector.java similarity index 83% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionCollector.java index 492c8c86139..684e8c272f3 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BaseSingleValuedProjectionCollector.java @@ -9,20 +9,21 @@ import org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter; import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext; import org.hibernate.search.engine.logging.impl.Log; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.util.common.logging.impl.LoggerFactory; /** - * A {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} that can accumulate up to one value, and will throw an exception beyond that. + * A {@link ProjectionCollector} that can accumulate up to one value, and will throw an exception beyond that. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -abstract class BaseSingleValuedProjectionAccumulator - implements org.hibernate.search.engine.search.projection.ProjectionAccumulator { +abstract class BaseSingleValuedProjectionCollector + implements ProjectionCollector { private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); - protected BaseSingleValuedProjectionAccumulator() { + protected BaseSingleValuedProjectionCollector() { } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionAccumulators.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionAccumulators.java deleted file mode 100644 index f35cd5757ba..00000000000 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionAccumulators.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.search.engine.search.projection.spi; - -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.SortedSet; -import java.util.function.Function; - -/** - * Provides access to built-in projection accumulators. - */ -public interface BuiltInProjectionAccumulators { - - @SuppressWarnings("unchecked") // PROVIDER works for any V. - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider nullable() { - return SingleValuedProjectionAccumulator.PROVIDER; - } - - @SuppressWarnings("unchecked") // PROVIDER works for any V. - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider> list() { - return ListProjectionAccumulator.PROVIDER; - } - - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider simple( - Function, C> converter) { - return new SimpleProjectionAccumulator.Provider<>( converter ); - } - - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider array( - Class componentType) { - return ArrayProjectionAccumulator.provider( componentType ); - } - - @SuppressWarnings("unchecked") // PROVIDER works for any V. - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider> set() { - return SetProjectionAccumulator.PROVIDER; - } - - @SuppressWarnings("unchecked") // PROVIDER works for any V. - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider> sortedSet() { - return SortedSetProjectionAccumulator.PROVIDER; - } - - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider> sortedSet( - Comparator comparator) { - return SortedSetComparatorProjectionAccumulator.provider( comparator ); - } - - @SuppressWarnings("unchecked") // PROVIDER works for any V. - static org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider> optional() { - return OptionalProjectionAccumulator.PROVIDER; - } -} diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionCollectors.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionCollectors.java new file mode 100644 index 00000000000..24af64dbdb3 --- /dev/null +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/BuiltInProjectionCollectors.java @@ -0,0 +1,60 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.search.engine.search.projection.spi; + +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.SortedSet; +import java.util.function.Function; + +import org.hibernate.search.engine.search.projection.ProjectionCollector; + +/** + * Provides access to built-in projection collectors. + */ +public interface BuiltInProjectionCollectors { + + @SuppressWarnings("unchecked") // PROVIDER works for any V. + static ProjectionCollector.Provider nullable() { + return SingleValuedProjectionAccumulator.PROVIDER; + } + + @SuppressWarnings("unchecked") // PROVIDER works for any V. + static ProjectionCollector.Provider> list() { + return ListProjectionAccumulator.PROVIDER; + } + + static ProjectionCollector.Provider simple( + Function, C> converter) { + return new SimpleProjectionCollector.Provider<>( converter ); + } + + static ProjectionCollector.Provider array( + Class componentType) { + return ArrayProjectionCollector.provider( componentType ); + } + + @SuppressWarnings("unchecked") // PROVIDER works for any V. + static ProjectionCollector.Provider> set() { + return SetProjectionCollector.PROVIDER; + } + + @SuppressWarnings("unchecked") // PROVIDER works for any V. + static ProjectionCollector.Provider> sortedSet() { + return SortedSetProjectionCollector.PROVIDER; + } + + static ProjectionCollector.Provider> sortedSet( + Comparator comparator) { + return SortedSetComparatorProjectionCollector.provider( comparator ); + } + + @SuppressWarnings("unchecked") // PROVIDER works for any V. + static ProjectionCollector.Provider> optional() { + return OptionalProjectionCollector.PROVIDER; + } +} diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/CompositeProjectionBuilder.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/CompositeProjectionBuilder.java index 32cfe6af228..d3d54041ca0 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/CompositeProjectionBuilder.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/CompositeProjectionBuilder.java @@ -4,12 +4,12 @@ */ package org.hibernate.search.engine.search.projection.spi; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; public interface CompositeProjectionBuilder { SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider); + ProjectionCollector.Provider collectorProvider); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/DistanceToFieldProjectionBuilder.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/DistanceToFieldProjectionBuilder.java index 8deb022920e..ed0d44009e9 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/DistanceToFieldProjectionBuilder.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/DistanceToFieldProjectionBuilder.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.engine.search.projection.spi; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.engine.spatial.GeoPoint; @@ -17,9 +17,9 @@ public interface DistanceToFieldProjectionBuilder extends SearchProjectionBuilde @Override default SearchProjection build() { - return build( ProjectionAccumulator.nullable() ); + return build( ProjectionCollector.nullable() ); } -

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider); +

SearchProjection

build(ProjectionCollector.Provider collectorProvider); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/FieldProjectionBuilder.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/FieldProjectionBuilder.java index ddc589ac230..0d18fbc1abe 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/FieldProjectionBuilder.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/FieldProjectionBuilder.java @@ -5,7 +5,7 @@ package org.hibernate.search.engine.search.projection.spi; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; public interface FieldProjectionBuilder extends SearchProjectionBuilder { @@ -16,9 +16,9 @@ interface TypeSelector { @Override default SearchProjection build() { - return build( ProjectionAccumulator.nullable() ); + return build( ProjectionCollector.nullable() ); } -

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider); +

SearchProjection

build(ProjectionCollector.Provider collectorProvider); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionCollector.java similarity index 85% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionCollector.java index 0160cd5bc91..2e9c14a1950 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListBasedProjectionCollector.java @@ -8,8 +8,10 @@ import java.util.Collection; import java.util.List; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} that can accumulate any number of values into a {@link List}, + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link List}, * and transforms that list into an arbitrary container on {@link #finish(List)}. * * @param The type of extracted values to accumulate before being transformed. @@ -17,10 +19,10 @@ * @param The type of the final result containing values of type {@code V}. */ @SuppressWarnings("deprecation") -abstract class ListBasedProjectionAccumulator - implements org.hibernate.search.engine.search.projection.ProjectionAccumulator, R> { +abstract class ListBasedProjectionCollector + implements ProjectionCollector, R> { - ListBasedProjectionAccumulator() { + ListBasedProjectionCollector() { } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListProjectionAccumulator.java index fee0dda8279..3cfc0bf6f8b 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ListProjectionAccumulator.java @@ -6,14 +6,16 @@ import java.util.List; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link ProjectionAccumulator} that can accumulate any number of values into a {@link java.util.List}. + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link java.util.List}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ @SuppressWarnings("deprecation") -final class ListProjectionAccumulator extends ListBasedProjectionAccumulator> +final class ListProjectionAccumulator extends ListBasedProjectionCollector> implements ProjectionAccumulator, List> { @SuppressWarnings("rawtypes") diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionCollector.java similarity index 60% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionCollector.java index 3ac3c1041fd..8db24265fe8 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/OptionalProjectionCollector.java @@ -6,21 +6,23 @@ import java.util.Optional; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} that can accumulate up to one value, and will throw an exception beyond that. + * A {@link ProjectionCollector} that can accumulate up to one value, and will throw an exception beyond that. * The value is wrapped in an {@link Optional}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -final class OptionalProjectionAccumulator extends BaseSingleValuedProjectionAccumulator> { +final class OptionalProjectionCollector extends BaseSingleValuedProjectionCollector> { @SuppressWarnings("rawtypes") static final Provider PROVIDER = new Provider() { - private final OptionalProjectionAccumulator instance = new OptionalProjectionAccumulator(); + private final OptionalProjectionCollector instance = new OptionalProjectionCollector(); @Override - public org.hibernate.search.engine.search.projection.ProjectionAccumulator get() { + public ProjectionCollector get() { return instance; } @@ -30,7 +32,7 @@ public boolean isSingleValued() { } }; - private OptionalProjectionAccumulator() { + private OptionalProjectionCollector() { } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ProjectionAccumulator.java index 231e2be2192..8a380a9367a 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/ProjectionAccumulator.java @@ -9,6 +9,7 @@ import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext; import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter; +import org.hibernate.search.engine.search.projection.ProjectionCollector; /** * A variation on {@link java.util.stream.Collector} suitable for projections on field values. @@ -31,11 +32,11 @@ * before and after being transformed. * @param The type of the final result containing values of type {@code V}. * - * @deprecated Use {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} instead. + * @deprecated Use {@link ProjectionCollector} instead. */ @Deprecated(since = "8.0") public interface ProjectionAccumulator - extends org.hibernate.search.engine.search.projection.ProjectionAccumulator { + extends ProjectionCollector { @SuppressWarnings("unchecked") // PROVIDER works for any V. static Provider single() { @@ -55,6 +56,7 @@ static Provider> list() { * @return The initial accumulated container, * to pass to the first call to {@link #accumulate(Object, Object)}. */ + @Override A createInitial(); /** @@ -68,6 +70,7 @@ static Provider> list() { * @param value The value to accumulate. * @return The new accumulated value. */ + @Override A accumulate(A accumulated, E value); /** @@ -81,6 +84,7 @@ static Provider> list() { * @param values The values to accumulate. * @return The new accumulated value. */ + @Override default A accumulateAll(A accumulated, Collection values) { for ( E value : values ) { accumulated = accumulate( accumulated, value ); @@ -93,6 +97,7 @@ default A accumulateAll(A accumulated, Collection values) { * returned by the last call to {@link #accumulate(Object, Object)}. * @return The number of elements in the accumulated value. */ + @Override int size(A accumulated); /** @@ -105,6 +110,7 @@ default A accumulateAll(A accumulated, Collection values) { * @param index The index of the value to retrieve. * @return The value at the given index. */ + @Override E get(A accumulated, int index); /** @@ -119,6 +125,7 @@ default A accumulateAll(A accumulated, Collection values) { * @param transformed The transformed value. * @return The new accumulated value. */ + @Override A transform(A accumulated, int index, V transformed); /** @@ -148,6 +155,7 @@ default A transformAll(A accumulated, ProjectionConverter The type of values to accumulate after being transformed. * @param The type of the final result containing values of type {@code V}. */ - interface Provider extends org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider { + interface Provider extends ProjectionCollector.Provider { /** * @param The type of values to accumulate before being transformed. * @return An accumulator for the given type. */ + @Override ProjectionAccumulator get(); /** * @return {@code true} if accumulators returned by {@link #get()} can only accept a single value, * and will fail beyond that. */ + @Override boolean isSingleValued(); } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionCollector.java similarity index 63% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionCollector.java index 2d5ef6765a9..9ddf96ff002 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SetProjectionCollector.java @@ -8,20 +8,22 @@ import java.util.List; import java.util.Set; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link ProjectionAccumulator} that can accumulate any number of values into a {@link Set}. + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link Set}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -final class SetProjectionAccumulator extends ListBasedProjectionAccumulator> { +final class SetProjectionCollector extends ListBasedProjectionCollector> { @SuppressWarnings("rawtypes") static final Provider PROVIDER = new Provider() { - private final SetProjectionAccumulator instance = new SetProjectionAccumulator(); + private final SetProjectionCollector instance = new SetProjectionCollector(); @Override - public org.hibernate.search.engine.search.projection.ProjectionAccumulator get() { + public ProjectionCollector get() { return instance; } @@ -31,7 +33,7 @@ public boolean isSingleValued() { } }; - private SetProjectionAccumulator() { + private SetProjectionCollector() { } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionCollector.java similarity index 64% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionCollector.java index 61238ad8c77..20a6a59ab2d 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SimpleProjectionCollector.java @@ -7,19 +7,19 @@ import java.util.List; import java.util.function.Function; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; /** - * A {@link ProjectionAccumulator} that can accumulate any number of values into a {@link List}, + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link List}, * and transforms that list into an arbitrary container using a given {@link Function}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). * @param The type of the final result containing values of type {@code V}. */ -final class SimpleProjectionAccumulator extends ListBasedProjectionAccumulator { +final class SimpleProjectionCollector extends ListBasedProjectionCollector { - static final class Provider implements ProjectionAccumulator.Provider { + static final class Provider implements ProjectionCollector.Provider { private final Function, R> finisher; Provider(Function, R> finisher) { @@ -27,8 +27,8 @@ static final class Provider implements ProjectionAccumulator.Provider ProjectionAccumulator get() { - return new SimpleProjectionAccumulator<>( finisher ); + public ProjectionCollector get() { + return new SimpleProjectionCollector<>( finisher ); } @Override @@ -39,7 +39,7 @@ public boolean isSingleValued() { private final Function, R> finisher; - private SimpleProjectionAccumulator(Function, R> finisher) { + private SimpleProjectionCollector(Function, R> finisher) { this.finisher = finisher; } diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SingleValuedProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SingleValuedProjectionAccumulator.java index 65364f3189f..ed0aad0f39c 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SingleValuedProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SingleValuedProjectionAccumulator.java @@ -6,15 +6,16 @@ import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext; import org.hibernate.search.engine.backend.types.converter.spi.ProjectionConverter; +import org.hibernate.search.engine.search.projection.ProjectionCollector; /** - * A {@link ProjectionAccumulator} that can accumulate up to one value, and will throw an exception beyond that. + * A {@link ProjectionCollector} that can accumulate up to one value, and will throw an exception beyond that. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ @SuppressWarnings("deprecation") -final class SingleValuedProjectionAccumulator extends BaseSingleValuedProjectionAccumulator +final class SingleValuedProjectionAccumulator extends BaseSingleValuedProjectionCollector implements ProjectionAccumulator { @SuppressWarnings("rawtypes") diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionCollector.java similarity index 61% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionCollector.java index 5c26a444c14..af8e1b2f151 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetComparatorProjectionCollector.java @@ -9,19 +9,21 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} that can accumulate any number of values into a {@link SortedSet}. + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link SortedSet}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -final class SortedSetComparatorProjectionAccumulator extends ListBasedProjectionAccumulator> { +final class SortedSetComparatorProjectionCollector extends ListBasedProjectionCollector> { static Provider provider(Comparator comparator) { return new ComparatorBasedSortedSetProvider<>( comparator ); } - private SortedSetComparatorProjectionAccumulator(Comparator comparator) { + private SortedSetComparatorProjectionCollector(Comparator comparator) { this.comparator = comparator; } @@ -36,15 +38,15 @@ public SortedSet doFinish(List accumulated) { @SuppressWarnings("unchecked") private static class ComparatorBasedSortedSetProvider implements Provider { - private final SortedSetComparatorProjectionAccumulator instance; + private final SortedSetComparatorProjectionCollector instance; private ComparatorBasedSortedSetProvider(Comparator comparator) { - instance = new SortedSetComparatorProjectionAccumulator<>( comparator ); + instance = new SortedSetComparatorProjectionCollector<>( comparator ); } @Override - public org.hibernate.search.engine.search.projection.ProjectionAccumulator get() { - return (org.hibernate.search.engine.search.projection.ProjectionAccumulator) instance; + public ProjectionCollector get() { + return (ProjectionCollector) instance; } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionAccumulator.java b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionCollector.java similarity index 50% rename from engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionAccumulator.java rename to engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionCollector.java index bb31060d4e0..418152c2e1e 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionAccumulator.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/projection/spi/SortedSetProjectionCollector.java @@ -8,21 +8,23 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.hibernate.search.engine.search.projection.ProjectionCollector; + /** - * A {@link org.hibernate.search.engine.search.projection.ProjectionAccumulator} that can accumulate any number of values into a {@link SortedSet}. + * A {@link ProjectionCollector} that can accumulate any number of values into a {@link SortedSet}. * * @param The type of extracted values to accumulate before being transformed. * @param The type of values to accumulate obtained by transforming extracted values ({@code E}). */ -final class SortedSetProjectionAccumulator extends ListBasedProjectionAccumulator> { +final class SortedSetProjectionCollector extends ListBasedProjectionCollector> { @SuppressWarnings("rawtypes") - static final org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider PROVIDER = - new org.hibernate.search.engine.search.projection.ProjectionAccumulator.Provider() { - private final SortedSetProjectionAccumulator instance = new SortedSetProjectionAccumulator(); + static final ProjectionCollector.Provider PROVIDER = + new ProjectionCollector.Provider() { + private final SortedSetProjectionCollector instance = new SortedSetProjectionCollector(); @Override - public org.hibernate.search.engine.search.projection.ProjectionAccumulator get() { + public ProjectionCollector get() { return instance; } @@ -32,7 +34,7 @@ public boolean isSingleValued() { } }; - private SortedSetProjectionAccumulator() { + private SortedSetProjectionCollector() { } @Override diff --git a/engine/src/main/java/org/hibernate/search/engine/search/query/dsl/impl/DefaultSearchQuerySelectStep.java b/engine/src/main/java/org/hibernate/search/engine/search/query/dsl/impl/DefaultSearchQuerySelectStep.java index b2029ef5138..37ec11663df 100644 --- a/engine/src/main/java/org/hibernate/search/engine/search/query/dsl/impl/DefaultSearchQuerySelectStep.java +++ b/engine/src/main/java/org/hibernate/search/engine/search/query/dsl/impl/DefaultSearchQuerySelectStep.java @@ -14,7 +14,7 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.engine.search.predicate.dsl.SimpleBooleanPredicateClausesCollector; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; @@ -77,7 +77,7 @@ public

DefaultSearchQueryOptionsStep select(SearchProjection

proj public DefaultSearchQueryOptionsStep, LOS> select(SearchProjection... projections) { return select( scope.projectionBuilders().composite() .build( projections, ProjectionCompositor.fromList( projections.length ), - ProjectionAccumulator.nullable() ) ); + ProjectionCollector.nullable() ) ); } @Override diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java index da54e9e5fc9..14e879b645a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java @@ -47,7 +47,7 @@ import org.hibernate.search.engine.search.common.ValueModel; import org.hibernate.search.engine.search.loading.spi.SearchLoadingContext; import org.hibernate.search.engine.search.predicate.SearchPredicate; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.sort.SearchSort; @@ -1108,7 +1108,7 @@ void jsonHitProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).jsonHit() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -1124,7 +1124,7 @@ void sourceProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).source() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -1140,7 +1140,7 @@ void explanationProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).explanation() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendFeatures.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendFeatures.java index 02862776680..70aaa2fb4e3 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendFeatures.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendFeatures.java @@ -32,7 +32,7 @@ import org.hibernate.search.backend.elasticsearch.types.format.impl.ElasticsearchDefaultFieldFormatProvider; import org.hibernate.search.engine.backend.types.VectorSimilarity; import org.hibernate.search.engine.cfg.spi.FormatUtils; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.BigDecimalFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; @@ -518,13 +518,13 @@ public boolean rawAggregationProduceSensibleDoubleValue(FieldTypeDescriptor< } @Override - public R accumulatedNullValue(ProjectionAccumulator.Provider accumulator) { - return accumulatedNullValue( accumulator.get() ); + public R accumulatedNullValue(ProjectionCollector.Provider collector) { + return accumulatedNullValue( collector.get() ); } - private R accumulatedNullValue(ProjectionAccumulator accumulator) { + private R accumulatedNullValue(ProjectionCollector collector) { ArrayList values = new ArrayList<>(); values.add( null ); - return accumulator.finish( accumulator.accumulateAll( accumulator.createInitial(), values ) ); + return collector.finish( collector.accumulateAll( collector.createInitial(), values ) ); } } diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java index f8d868917f6..006f1b671bc 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java @@ -54,7 +54,7 @@ import org.hibernate.search.engine.search.common.ValueModel; import org.hibernate.search.engine.search.loading.spi.SearchLoadingContext; import org.hibernate.search.engine.search.predicate.SearchPredicate; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.sort.SearchSort; @@ -888,7 +888,7 @@ void documentProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( LuceneExtension.get() ).document() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -904,7 +904,7 @@ void explanationProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( LuceneExtension.get() ).explanation() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -934,9 +934,9 @@ void documentTreeMultipleIndexes() { someOtherIndex.query().select( f -> f.object( "someOtherNestedObject" ).from( f .object( "someOtherNestedObject.someOtherNestedNestedObject" ) .from( f.field( "someOtherNestedObject.someOtherNestedNestedObject.nestedNestedSomeOtherInteger" ) - .accumulator( ProjectionAccumulator.list() ) ) - .asList().accumulator( ProjectionAccumulator.list() ) ).asList() - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) + .asList().collector( ProjectionCollector.list() ) ).asList() + .collector( ProjectionCollector.list() ) ) .where( f -> f.match().field( "someOtherString" ).matching( "text 2" ) ).fetchAllHits() ).containsExactly( List.of( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/KnnPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/KnnPredicateSpecificsIT.java index cd9f4103431..391e84dc74d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/KnnPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/KnnPredicateSpecificsIT.java @@ -36,7 +36,7 @@ import org.hibernate.search.engine.backend.types.dsl.SearchableProjectableIndexFieldTypeOptionsStep; import org.hibernate.search.engine.search.predicate.dsl.KnnPredicateOptionsStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; @@ -776,7 +776,7 @@ void nestedVector() { f.field( "nested.floatVector" ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ).asList() ).where( f -> f.knn( 1 ).field( "nested.byteVector" ).matching( bytes( 2, (byte) -120 ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java index fbb92aa56ba..36938735b6b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java @@ -25,7 +25,7 @@ import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Projectable; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.definition.spi.ProjectionRegistry; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionFrom1AsStep; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionFrom2AsStep; @@ -116,7 +116,7 @@ public void asList_transformer_flexibleFunctionArgumentTypes() { public void asList_multi() { assertThatQuery( index.query() .select( f -> doFromForMulti( f, startProjectionForMulti( f ) ).asList() - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) ) .hasHitsAnyOrder( expectedListsForMulti() ); } @@ -159,7 +159,7 @@ public void asArray_transformer_flexibleFunctionArgumentTypes() { public void asArray_multi() { assertThatQuery( index.query() .select( f -> doFromForMulti( f, startProjectionForMulti( f ) ).asArray() - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) ) .hits().asIs().usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrderElementsOf( expectedArraysForMulti() ); @@ -169,7 +169,7 @@ public void asArray_multi() { public void asArray_set() { assertThatQuery( index.query() .select( f -> doFromForMulti( f, startProjectionForMulti( f ) ).asArray() - .accumulator( ProjectionAccumulator.set() ) ) + .collector( ProjectionCollector.set() ) ) .where( f -> f.matchAll() ) ) .hits().asIs().usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrderElementsOf( expectedArraysForMulti() @@ -216,7 +216,7 @@ public void as_class_multi() { .asArray( ValueWrapper::new ) ); assertThatQuery( index.createScope().query() .select( f -> startProjectionForMulti( f ).as( ValueWrapper.class ) - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) ) .hits().asIs().usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrderElementsOf( expectedArraysForMulti().stream() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java index b44a3202c1f..869554a75e3 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java @@ -21,7 +21,7 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.dsl.SearchableProjectableIndexFieldTypeOptionsStep; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; @@ -91,10 +91,10 @@ void objectOnLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( Level1ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( IdAndObjectDto::new ) ) .where( f -> f.matchAll() ) @@ -257,7 +257,7 @@ void objectOnLevel1AndNoLevel2(SimpleMappedIndex mainIndex, ), dataSet ) ) .as( ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( IdAndObjectDto::new ) ) .where( f -> f.matchAll() ) @@ -363,7 +363,7 @@ void objectOnLevel1AndFlattenedLevel2(SimpleMappedIndex mainIndex, .as( FlattenedObjectDto::new ) ) .as( Level1ObjectWithFlattenedLevel2Dto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( IdAndObjectDto::new ) ) .where( f -> f.matchAll() ) @@ -563,7 +563,7 @@ void noLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, ), dataSet ) ) .as( ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( IdAndObjectDto::new ) ) .where( f -> f.matchAll() ) @@ -664,7 +664,7 @@ void flattenedLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( FlattenedLevel1ObjectDto::new ) ) @@ -790,7 +790,7 @@ void fieldOutsideObjectFieldTree(SimpleMappedIndex mainIndex, ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) .toQuery() ) @@ -837,7 +837,7 @@ void singleValuedField_effectivelyMultiValuedInContext(SimpleMappedIndex f.matchAll() ) .routing( dataSet.routingKey ) .toQuery() ) @@ -848,13 +848,13 @@ void singleValuedField_effectivelyMultiValuedInContext(SimpleMappedIndex).as(...).accumulator(...)'." + + ">).as(...).collector(...)'." ); } @@ -892,10 +892,10 @@ void missingFields(SimpleMappedIndex mainIndex, mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( Level1ObjectDto::new ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .as( IdAndObjectDto::new ) ) .where( f -> f.matchAll() ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java index bbc0b3a0a3b..cddafd71461 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java @@ -9,7 +9,7 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.dsl.SearchableProjectableIndexFieldTypeOptionsStep; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.engine.spatial.GeoPoint; @@ -155,7 +155,7 @@ protected ProjectionFinalStep singleValuedProjection(SearchProjectionFac protected ProjectionFinalStep> multiValuedProjection(SearchProjectionFactory f, String absoluteFieldPath, DataSet dataSet) { return f.distance( absoluteFieldPath, dataSet.values.projectionCenterPoint() ) - .accumulator( ProjectionAccumulator.list() ); + .collector( ProjectionCollector.list() ); } } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedAccumulatorBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedAccumulatorBaseIT.java index 22a7369c100..b1f05619d73 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedAccumulatorBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedAccumulatorBaseIT.java @@ -8,7 +8,7 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.common.EntityReference; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; @@ -28,14 +28,14 @@ protected void addParameter(SearchQueryOptionsStep query, String protected ProjectionFinalStep> distance( SearchProjectionFactory projection, String path, GeoPoint center, String parameterName) { - return projection.distance( path, center ).accumulator( ProjectionAccumulator.list() ); + return projection.distance( path, center ).collector( ProjectionCollector.list() ); } @Override protected ProjectionFinalStep> distance( SearchProjectionFactory projection, String path, GeoPoint center, DistanceUnit unit, String centerParam, String unitParam) { - return projection.distance( path, center ).accumulator( ProjectionAccumulator.list() ).unit( unit ); + return projection.distance( path, center ).collector( ProjectionCollector.list() ).unit( unit ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterMultiValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterMultiValuedBaseIT.java index 9a55b504918..a91578301d2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterMultiValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterMultiValuedBaseIT.java @@ -8,7 +8,7 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.common.EntityReference; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; @@ -32,7 +32,7 @@ protected ProjectionFinalStep> distance( String parameterName) { return projection.withParameters( params -> projection.distance( path, params.get( parameterName, GeoPoint.class ) ) - .accumulator( ProjectionAccumulator.list() ) ); + .collector( ProjectionCollector.list() ) ); } @Override @@ -41,7 +41,7 @@ protected ProjectionFinalStep> distance( DistanceUnit unit, String centerParam, String unitParam) { return projection.withParameters( params -> projection.distance( path, params.get( centerParam, GeoPoint.class ) ) - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) .unit( params.get( unitParam, DistanceUnit.class ) ) ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterSingleValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterSingleValuedBaseIT.java index bb6c6d26cc5..ed0be013f2d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterSingleValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionParameterSingleValuedBaseIT.java @@ -8,7 +8,7 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.common.EntityReference; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; @@ -39,7 +39,7 @@ protected ProjectionFinalStep> distanceMulti( String parameterName) { return projection.withParameters( params -> projection.distance( path, params.get( parameterName, GeoPoint.class ) ) - .accumulator( ProjectionAccumulator.list() ) ); + .collector( ProjectionCollector.list() ) ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java index a76509c9d47..c879f65a3fd 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java @@ -16,7 +16,7 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.common.EntityReference; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionOptionsStep; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionValueStep; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; @@ -84,7 +84,7 @@ void set(TestedFieldStructure fieldStructure, DataSet dataSet) { Set.of( dataSet.getFieldDistanceFromCenter1( 1 ) ), Set.of( dataSet.getFieldDistanceFromCenter1( 2 ) ), Set.of( dataSet.getFieldDistanceFromCenter1( 3 ) ), - TckConfiguration.get().getBackendFeatures().accumulatedNullValue( ProjectionAccumulator.set() ) // Empty document + TckConfiguration.get().getBackendFeatures().accumulatedNullValue( ProjectionCollector.set() ) // Empty document ); } @@ -113,7 +113,7 @@ void sortedSet(TestedFieldStructure fieldStructure, DataSet dataSet) { new TreeSet<>( Set.of( dataSet.getFieldDistanceFromCenter1( 2 ) ) ), new TreeSet<>( Set.of( dataSet.getFieldDistanceFromCenter1( 3 ) ) ), TckConfiguration.get().getBackendFeatures() - .accumulatedNullValue( ProjectionAccumulator.sortedSet( comparator ) ) // Empty document + .accumulatedNullValue( ProjectionCollector.sortedSet( comparator ) ) // Empty document ); } @@ -140,7 +140,7 @@ void array(TestedFieldStructure fieldStructure, DataSet dataSet) { new Double[] { dataSet.getFieldDistanceFromCenter1( 2 ) }, new Double[] { dataSet.getFieldDistanceFromCenter1( 3 ) }, TckConfiguration.get().getBackendFeatures() - .accumulatedNullValue( ProjectionAccumulator.array( Double.class ) ) // Empty document + .accumulatedNullValue( ProjectionCollector.array( Double.class ) ) // Empty document ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java index 7b68409b275..2837d2f0837 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java @@ -92,7 +92,7 @@ void multiValuedField_singleValuedProjection() { .hasMessageContainingAll( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } @@ -110,7 +110,7 @@ void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection( .hasMessageContaining( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } @@ -128,7 +128,7 @@ void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection() { .hasMessageContaining( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java index dd70dbaaba9..6d85f087109 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java @@ -21,7 +21,7 @@ import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; import org.hibernate.search.engine.search.loading.spi.SearchLoadingContext; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.definition.spi.CompositeProjectionDefinition; import org.hibernate.search.engine.search.projection.definition.spi.ProjectionRegistry; import org.hibernate.search.engine.search.query.SearchQuery; @@ -123,7 +123,7 @@ void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistryEntry_i .select( f -> f.composite().from( f.object( binding.nested.absolutePath ) .from( f.field( binding.nested.fieldPath(), String.class ) ) - .asList().accumulator( ProjectionAccumulator.list() ), + .asList().collector( ProjectionCollector.list() ), f.entity() ).asList() ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java index a08363770c9..986ad72eba9 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java @@ -11,7 +11,7 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.dsl.SearchableProjectableIndexFieldTypeOptionsStep; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.ProjectionFinalStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; @@ -144,7 +144,7 @@ protected ProjectionFinalStep singleValuedProjection(SearchProjectionFactory< @Override protected ProjectionFinalStep> multiValuedProjection(SearchProjectionFactory f, String absoluteFieldPath, DataSet> dataSet) { - return f.field( absoluteFieldPath, dataSet.fieldType.getJavaType() ).accumulator( ProjectionAccumulator.list() ); + return f.field( absoluteFieldPath, dataSet.fieldType.getJavaType() ).collector( ProjectionCollector.list() ); } } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java index eb05520ad58..dd9643d08f2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java @@ -185,7 +185,7 @@ void multiValuedField_singleValuedProjection(FieldTypeDescriptor fieldType .hasMessageContainingAll( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } @@ -204,7 +204,7 @@ void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection( .hasMessageContaining( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } @@ -223,7 +223,7 @@ void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection(Fie .hasMessageContaining( "Invalid cardinality for projection on field '" + fieldPath + "'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java index 766545f317e..ac2651743f3 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java @@ -16,7 +16,7 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; @@ -89,10 +89,10 @@ void innerObjectProjectionOnFieldOutsideOuterObjectProjectionFieldTree() { f.object( "level1" ) .from( f.field( "level1.field1" ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) ) + .collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() ) .isInstanceOf( SearchException.class ) @@ -133,7 +133,7 @@ void multiValuedObjectField_singleValuedObjectProjection() { .hasMessageContainingAll( "Invalid cardinality for projection on field 'level1'", "the projection is single-valued, but this field is multi-valued", - "Make sure to call '.accumulator(...)' when you create the projection" + "Make sure to call '.collector(...)' when you create the projection" ); } @@ -152,9 +152,9 @@ void singleValuedObjectField_effectivelyMultiValuedInContext() { "Invalid cardinality for projection on field 'level1WithSingleValuedLevel2.level2'", "the projection is single-valued, but this field is effectively multi-valued in this context", "because parent object field 'level1WithSingleValuedLevel2' is multi-valued", - "call '.accumulator(...)' when you create the projection on field 'level1WithSingleValuedLevel2.level2'", + "call '.collector(...)' when you create the projection on field 'level1WithSingleValuedLevel2.level2'", "or wrap that projection in an object projection like this:" - + " 'f.object(\"level1WithSingleValuedLevel2\").from().as(...).accumulator(...)'." + + " 'f.object(\"level1WithSingleValuedLevel2\").from().as(...).collector(...)'." ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java index 3189c22ac62..9ee02c51925 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java @@ -12,7 +12,7 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -40,7 +40,7 @@ void id() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.id() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -57,7 +57,7 @@ void entity() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.entity() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -74,7 +74,7 @@ void entityReference() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.entityReference() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -91,7 +91,7 @@ void documentReference() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.documentReference() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() @@ -108,7 +108,7 @@ void score() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.score() - ).asList().accumulator( ProjectionAccumulator.list() ) + ).asList().collector( ProjectionCollector.list() ) ) .where( f -> f.matchAll() ) .toQuery() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendFeatures.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendFeatures.java index 70182cd8e08..df62b670195 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendFeatures.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendFeatures.java @@ -10,7 +10,7 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.VectorSimilarity; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingBackendFeatures; @@ -223,7 +223,7 @@ public boolean rawAggregationProduceSensibleDoubleValue(FieldTypeDescriptor< return true; } - public R accumulatedNullValue(ProjectionAccumulator.Provider accumulator) { - return accumulator.get().empty(); + public R accumulatedNullValue(ProjectionCollector.Provider collector) { + return collector.get().empty(); } } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java index cf1b9a65239..d78f57ba1b5 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java @@ -14,7 +14,7 @@ import java.util.Set; import org.hibernate.search.engine.search.common.ValueModel; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FieldProjection; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; @@ -580,8 +580,8 @@ public MyProjection(@FieldProjection List text, @FieldProjection List f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -631,8 +631,8 @@ public MyProjection(@FieldProjection Collection text, @FieldProjection C f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -682,8 +682,8 @@ public MyProjection(@FieldProjection Iterable text, @FieldProjection Ite f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -733,8 +733,8 @@ public MyProjection(@FieldProjection Set text, @FieldProjection List f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.set() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.set() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java index ea51afc62ec..20587c4a440 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.Set; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; @@ -237,7 +237,7 @@ public MyProjection(@HighlightProjection String text) { f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.highlight( "text" ).accumulator( ProjectionAccumulator.nullable() ) + f.highlight( "text" ).collector( ProjectionCollector.nullable() ) ) .asList(), Arrays.asList( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java index 707c219caa0..626af40cd0b 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.Set; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; @@ -117,8 +117,8 @@ public MyProjection(List text, List integer) { f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -168,8 +168,8 @@ public MyProjection(Collection text, Collection integer) { f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -219,8 +219,8 @@ public MyProjection(Iterable text, Iterable integer) { f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.list() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.list() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -270,8 +270,8 @@ public MyProjection(Set text, List integer) { f -> f.composite() .from( dummyProjectionForEnclosingClassInstance( f ), - f.field( "text", String.class ).accumulator( ProjectionAccumulator.set() ), - f.field( "integer", Integer.class ).accumulator( ProjectionAccumulator.list() ) + f.field( "text", String.class ).collector( ProjectionCollector.set() ), + f.field( "integer", Integer.class ).collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -504,7 +504,7 @@ public MyProjection(String text, List contained) { f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -594,7 +594,7 @@ public MyProjection(String text, Collection contained) { f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -684,7 +684,7 @@ public MyProjection(String text, Iterable contained) { f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -774,7 +774,7 @@ public MyProjection(String text, Set contained) { f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.set() ) + .collector( ProjectionCollector.set() ) ) .asList(), Arrays.asList( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java index 285a769e470..43d7f2da1c8 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java @@ -13,7 +13,7 @@ import java.util.List; import java.util.Set; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; @@ -706,7 +706,7 @@ public MyProjection(String text, @ObjectProjection List conta f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -796,7 +796,7 @@ public MyProjection(String text, @ObjectProjection Collection f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -886,7 +886,7 @@ public MyProjection(String text, @ObjectProjection Iterable c f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.list() ) + .collector( ProjectionCollector.list() ) ) .asList(), Arrays.asList( @@ -976,7 +976,7 @@ public MyProjection(String text, @ObjectProjection Set contai f.field( "contained.integer", Integer.class ) ) .asList() - .accumulator( ProjectionAccumulator.set() ) + .collector( ProjectionCollector.set() ) ) .asList(), Arrays.asList( diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/logging/impl/Log.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/logging/impl/Log.java index 15b2f753f13..239b1915eb2 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/logging/impl/Log.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/logging/impl/Log.java @@ -1050,7 +1050,7 @@ void indexingProgressWithRemainingTime(float estimatePercentileComplete, long do @Message(id = ID_OFFSET + 170, value = "Implicit binding of a java.util.SortedSet<%1$s> constructor parameter is not possible since %1$s is not implementing java.lang.Comparable." - + " Either make %1$s implement java.lang.Comparable or create a custom @ProjectionBinding and use the ProjectionAccumulator.sortedSet(comparator) accumulator provider in it.") + + " Either make %1$s implement java.lang.Comparable or create a custom @ProjectionBinding and use the ProjectionCollector.sortedSet(comparator) collector provider in it.") SearchException cannotBindSortedSetWithNonComparableElements(@FormatWith(ClassFormatter.class) Class elementType, @Param EventContext eventContext); } diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/ProjectionBindingContext.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/ProjectionBindingContext.java index a9b12c6326a..18748bca436 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/ProjectionBindingContext.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/ProjectionBindingContext.java @@ -12,8 +12,8 @@ import org.hibernate.search.engine.environment.bean.BeanHolder; import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.engine.environment.bean.BeanResolver; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; -import org.hibernate.search.engine.search.projection.ProjectionAccumulatorProviderFactory; +import org.hibernate.search.engine.search.projection.ProjectionCollector; +import org.hibernate.search.engine.search.projection.ProjectionCollectorProviderFactory; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinition; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.PropertyBinderRef; @@ -157,7 +157,7 @@ default Optional paramOptional(String name) { @Incubating default BeanHolder> createObjectDefinition(String fieldPath, Class projectedType, TreeFilterDefinition filter) { - return createObjectDefinition( fieldPath, projectedType, filter, ProjectionAccumulator.nullable() ); + return createObjectDefinition( fieldPath, projectedType, filter, ProjectionCollector.nullable() ); } /** @@ -171,13 +171,13 @@ default BeanHolder> createObjectDefinition * @throws SearchException If mapping the given type to a projection definition fails. * @see org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory#object(String) * @see org.hibernate.search.engine.search.projection.dsl.CompositeProjectionInnerStep#as(Class) - * @deprecated Use {@link #createObjectDefinition(String, Class, TreeFilterDefinition, ProjectionAccumulator.Provider)} instead. + * @deprecated Use {@link #createObjectDefinition(String, Class, TreeFilterDefinition, ProjectionCollector.Provider)} instead. */ @Deprecated(since = "8.0") @Incubating default BeanHolder>> createObjectDefinitionMulti(String fieldPath, Class projectedType, TreeFilterDefinition filter) { - return createObjectDefinition( fieldPath, projectedType, filter, ProjectionAccumulator.list() ); + return createObjectDefinition( fieldPath, projectedType, filter, ProjectionCollector.list() ); } /** @@ -194,7 +194,7 @@ default BeanHolder>> createObjectDefi */ @Incubating BeanHolder> createObjectDefinition(String fieldPath, - Class projectedType, TreeFilterDefinition filter, ProjectionAccumulator.Provider accumulator); + Class projectedType, TreeFilterDefinition filter, ProjectionCollector.Provider collector); /** * @param projectedType A type expected to have a corresponding projection mapping @@ -220,10 +220,10 @@ BeanHolder> createObjectDefinition(Stri boolean isIncluded(String fieldPath); /** - * @return An instance of a projection accumulator provider factory capable of supplying an accumulator provider + * @return An instance of a projection collector provider factory capable of supplying a collector provider * based on a container and component types. */ @Incubating - ProjectionAccumulatorProviderFactory projectionAccumulatorProviderFactory(); + ProjectionCollectorProviderFactory projectionCollectorProviderFactory(); } diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/DistanceProjectionBinder.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/DistanceProjectionBinder.java index ae510f737c1..febbc6c3a8a 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/DistanceProjectionBinder.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/DistanceProjectionBinder.java @@ -9,7 +9,7 @@ import java.util.function.Function; import org.hibernate.search.engine.environment.bean.BeanHolder; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.definition.spi.ConstantProjectionDefinition; import org.hibernate.search.engine.search.projection.definition.spi.DistanceProjectionDefinition; import org.hibernate.search.engine.search.projection.dsl.DistanceToFieldProjectionOptionsStep; @@ -114,17 +114,17 @@ public void bind(ProjectionBindingContext context) { } containerClass = null; } - ProjectionAccumulator.Provider accumulator = context.projectionAccumulatorProviderFactory() - .projectionAccumulatorProvider( containerClass, Double.class ); - bind( context, fieldPath, accumulator ); + ProjectionCollector.Provider collector = context.projectionCollectorProviderFactory() + .projectionCollectorProvider( containerClass, Double.class ); + bind( context, fieldPath, collector ); } private void bind(ProjectionBindingContext context, String fieldPath, - ProjectionAccumulator.Provider accumulator) { + ProjectionCollector.Provider collector) { context.definition( Double.class, context.isIncluded( fieldPath ) ? BeanHolder - .of( new DistanceProjectionDefinition.WrappedValued<>( fieldPath, parameterName, unit, accumulator ) ) - : ConstantProjectionDefinition.empty( accumulator ) ); + .of( new DistanceProjectionDefinition.WrappedValued<>( fieldPath, parameterName, unit, collector ) ) + : ConstantProjectionDefinition.empty( collector ) ); } private String fieldPathOrFail(ProjectionBindingContext context) { diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/FieldProjectionBinder.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/FieldProjectionBinder.java index cf57f33db8e..18abc11d9c0 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/FieldProjectionBinder.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/FieldProjectionBinder.java @@ -107,13 +107,13 @@ public void bind(ProjectionBindingContext context) { private void bind(ProjectionBindingContext context, String fieldPath, Class containerType, Class containerElementType) { - var accumulator = context.projectionAccumulatorProviderFactory() - .projectionAccumulatorProvider( containerType, containerElementType ); + var collector = context.projectionCollectorProviderFactory() + .projectionCollectorProvider( containerType, containerElementType ); context.definition( containerElementType, context.isIncluded( fieldPath ) ? BeanHolder.of( new FieldProjectionDefinition.AccumulatedValued<>( fieldPath, containerElementType, - accumulator, valueModel ) ) - : ConstantProjectionDefinition.empty( accumulator ) ); + collector, valueModel ) ) + : ConstantProjectionDefinition.empty( collector ) ); } private String fieldPathOrFail(ProjectionBindingContext context) { diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/HighlightProjectionBinder.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/HighlightProjectionBinder.java index b276edb15a8..b32d0a6f741 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/HighlightProjectionBinder.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/HighlightProjectionBinder.java @@ -8,7 +8,7 @@ import java.util.Optional; import java.util.function.Function; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinitionContext; import org.hibernate.search.engine.search.projection.definition.spi.AbstractProjectionDefinition; @@ -85,15 +85,15 @@ public void bind(ProjectionBindingContext context) { String fieldPath = fieldPathOrFail( context ); Optional> containerElementOptional = context.containerElement(); - var accumulator = context.projectionAccumulatorProviderFactory() - .projectionAccumulatorProvider( - // if there's no container element, there's no container hence we are working with a "nullable" accumulator: + var collector = context.projectionCollectorProviderFactory() + .projectionCollectorProvider( + // if there's no container element, there's no container hence we are working with a "nullable" collector: containerElementOptional.isPresent() ? context.constructorParameter().rawType() : null, String.class ); - context.definition( String.class, new Definition<>( fieldPath, highlighterName, accumulator ) ); + context.definition( String.class, new Definition<>( fieldPath, highlighterName, collector ) ); } private String fieldPathOrFail(ProjectionBindingContext context) { @@ -110,12 +110,12 @@ private String fieldPathOrFail(ProjectionBindingContext context) { private static class Definition extends AbstractProjectionDefinition { private final String fieldPath; private final String highlighterName; - private final ProjectionAccumulator.Provider accumulator; + private final ProjectionCollector.Provider collector; - private Definition(String fieldPath, String highlighterName, ProjectionAccumulator.Provider accumulator) { + private Definition(String fieldPath, String highlighterName, ProjectionCollector.Provider collector) { this.fieldPath = fieldPath; this.highlighterName = highlighterName; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -127,7 +127,7 @@ protected String type() { public SearchProjection create(SearchProjectionFactory factory, ProjectionDefinitionContext context) { return factory.highlight( fieldPath ) .highlighter( highlighterName ) - .accumulator( accumulator ) + .collector( collector ) .toProjection(); } diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/ObjectProjectionBinder.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/ObjectProjectionBinder.java index 4e0988da169..139934dd3a2 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/ObjectProjectionBinder.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/builtin/ObjectProjectionBinder.java @@ -8,7 +8,7 @@ import java.util.Optional; import org.hibernate.search.engine.common.tree.TreeFilterDefinition; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.mapper.pojo.logging.impl.Log; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectProjection; import org.hibernate.search.mapper.pojo.model.PojoModelValue; @@ -110,12 +110,12 @@ public void bind(ProjectionBindingContext context) { private void bind(ProjectionBindingContext context, String fieldPath, Class containerType, Class containerElementType) { - ProjectionAccumulator.Provider accumulator = context.projectionAccumulatorProviderFactory() - .projectionAccumulatorProvider( containerType, containerElementType ); + ProjectionCollector.Provider collector = context.projectionCollectorProviderFactory() + .projectionCollectorProvider( containerType, containerElementType ); context.definition( containerElementType, - context.createObjectDefinition( fieldPath, containerElementType, filter, accumulator ) + context.createObjectDefinition( fieldPath, containerElementType, filter, collector ) ); } diff --git a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/impl/ProjectionBindingContextImpl.java b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/impl/ProjectionBindingContextImpl.java index f409f2e10d0..f31414446c3 100644 --- a/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/impl/ProjectionBindingContextImpl.java +++ b/mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/search/definition/binding/impl/ProjectionBindingContextImpl.java @@ -20,8 +20,8 @@ import org.hibernate.search.engine.environment.bean.BeanHolder; import org.hibernate.search.engine.environment.bean.BeanResolver; import org.hibernate.search.engine.mapper.model.spi.MappingElement; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; -import org.hibernate.search.engine.search.projection.ProjectionAccumulatorProviderFactory; +import org.hibernate.search.engine.search.projection.ProjectionCollector; +import org.hibernate.search.engine.search.projection.ProjectionCollectorProviderFactory; import org.hibernate.search.engine.search.projection.definition.ProjectionDefinition; import org.hibernate.search.engine.search.projection.definition.spi.CompositeProjectionDefinition; import org.hibernate.search.engine.search.projection.definition.spi.ConstantProjectionDefinition; @@ -85,7 +85,7 @@ public class ProjectionBindingContextImpl

implements ProjectionBindingContext private final Map params; private final PojoTypeModel parameterTypeModel; private final PojoModelConstructorParameterRootElement

parameterRootElement; - private final ProjectionAccumulatorProviderFactory projectionAccumulatorProviderFactory; + private final ProjectionCollectorProviderFactory projectionCollectorProviderFactory; private MappingElement mappingElement; private PartialBinding

partialBinding; @@ -97,7 +97,7 @@ public class ProjectionBindingContextImpl

implements ProjectionBindingContext this.params = params; this.parameterTypeModel = parameterBinder.parameter.typeModel(); this.parameterRootElement = parameterBinder.parameterRootElement; - this.projectionAccumulatorProviderFactory = new BuiltInProjectionAccumulatorProviderFactory(); + this.projectionCollectorProviderFactory = new BuiltInProjectionCollectorProviderFactory(); } @Override @@ -197,11 +197,11 @@ private Optional> containerElementModel() { @Override public BeanHolder> createObjectDefinition(String fieldPath, Class projectedType, TreeFilterDefinition filter, - ProjectionAccumulator.Provider accumulator) { + ProjectionCollector.Provider collector) { Contracts.assertNotNull( fieldPath, "fieldPath" ); Contracts.assertNotNull( projectedType, "projectedType" ); Contracts.assertNotNull( filter, "filter" ); - Contracts.assertNotNull( accumulator, "accumulator" ); + Contracts.assertNotNull( collector, "collector" ); Optional>> objectProjection = nestObjectProjection( fieldPath, filter, nestingContext -> { @@ -209,7 +209,7 @@ public BeanHolder> createObjectDefiniti createCompositeProjectionDefinition( projectedType, nestingContext ); try { return BeanHolder.ofCloseable( new ObjectProjectionDefinition.WrappedValued<>( - fieldPath, composite, accumulator ) ); + fieldPath, composite, collector ) ); } catch (RuntimeException e) { new SuppressingCloser( e ).push( composite ); @@ -217,7 +217,7 @@ public BeanHolder> createObjectDefiniti } } ); - return objectProjection.orElse( ConstantProjectionDefinition.empty( accumulator ) ); + return objectProjection.orElse( ConstantProjectionDefinition.empty( collector ) ); } private Optional nestObjectProjection(String fieldPath, TreeFilterDefinition filter, @@ -271,8 +271,8 @@ public boolean isIncluded(String fieldPath) { } @Override - public ProjectionAccumulatorProviderFactory projectionAccumulatorProviderFactory() { - return projectionAccumulatorProviderFactory; + public ProjectionCollectorProviderFactory projectionCollectorProviderFactory() { + return projectionCollectorProviderFactory; } public BeanHolder> applyBinder(ProjectionBinder binder) { @@ -389,18 +389,18 @@ public PojoModelValue containerElement() { } - private class BuiltInProjectionAccumulatorProviderFactory implements ProjectionAccumulatorProviderFactory { + private class BuiltInProjectionCollectorProviderFactory implements ProjectionCollectorProviderFactory { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public ProjectionAccumulator.Provider projectionAccumulatorProvider(Class containerType, + public ProjectionCollector.Provider projectionCollectorProvider(Class containerType, Class containerElementType) { - ProjectionAccumulator.Provider reference; + ProjectionCollector.Provider reference; if ( containerType == null ) { - reference = ProjectionAccumulator.nullable(); + reference = ProjectionCollector.nullable(); } else if ( List.class.isAssignableFrom( containerType ) ) { - reference = ProjectionAccumulator.list(); + reference = ProjectionCollector.list(); } else if ( SortedSet.class.isAssignableFrom( containerType ) ) { if ( !Comparable.class.isAssignableFrom( containerElementType ) ) { @@ -409,16 +409,16 @@ else if ( SortedSet.class.isAssignableFrom( containerType ) ) { mappingElement.eventContext() ); } - reference = ProjectionAccumulator.sortedSet(); + reference = ProjectionCollector.sortedSet(); } else if ( Set.class.isAssignableFrom( containerType ) ) { - reference = ProjectionAccumulator.set(); + reference = ProjectionCollector.set(); } else if ( containerType.isArray() ) { - reference = ProjectionAccumulator.array( containerElementType ); + reference = ProjectionCollector.array( containerElementType ); } else if ( Collection.class.isAssignableFrom( containerType ) || Iterable.class.isAssignableFrom( containerType ) ) { - reference = ProjectionAccumulator.list(); + reference = ProjectionCollector.list(); } else { throw log.invalidMultiValuedParameterTypeForProjectionConstructor( parameterTypeModel ); diff --git a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubCompositeProjection.java b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubCompositeProjection.java index 8d1a79af510..eb270e2921b 100644 --- a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubCompositeProjection.java +++ b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubCompositeProjection.java @@ -10,7 +10,7 @@ import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -19,14 +19,14 @@ class StubCompositeProjection extends StubSearchProjection

{ private final StubSearchProjection[] inners; private final ProjectionCompositor compositor; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private final boolean singleValued; protected StubCompositeProjection(StubSearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator accumulator, boolean singleValued) { + ProjectionCollector collector, boolean singleValued) { this.inners = inners; this.compositor = compositor; - this.accumulator = accumulator; + this.collector = collector; this.singleValued = singleValued; } @@ -42,7 +42,7 @@ public Object extract(ProjectionHitMapper projectionHitMapper, Iterator pr allInnerProjectionsFromIndex = (Iterable) projectionFromIndex.next(); } - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); for ( Object innerProjectionsFromIndex : allInnerProjectionsFromIndex ) { E extractedData = compositor.createInitial(); Iterator innerProjectionFromIndex = ( (Iterable) innerProjectionsFromIndex ).iterator(); @@ -50,7 +50,7 @@ public Object extract(ProjectionHitMapper projectionHitMapper, Iterator pr Object extractedDataForInner = inners[i].extract( projectionHitMapper, innerProjectionFromIndex, context ); extractedData = compositor.set( extractedData, i, extractedDataForInner ); } - accumulated = accumulator.accumulate( accumulated, extractedData ); + accumulated = collector.accumulate( accumulated, extractedData ); } return accumulated; } @@ -59,17 +59,17 @@ public Object extract(ProjectionHitMapper projectionHitMapper, Iterator pr @SuppressWarnings("unchecked") public P transform(LoadingResult loadingResult, Object extractedData, StubSearchProjectionContext context) { A accumulated = (A) extractedData; - for ( int i = 0; i < accumulator.size( accumulated ); i++ ) { - E transformedData = accumulator.get( accumulated, i ); + for ( int i = 0; i < collector.size( accumulated ); i++ ) { + E transformedData = collector.get( accumulated, i ); // Transform in-place for ( int j = 0; j < inners.length; j++ ) { Object extractedDataForInner = compositor.get( transformedData, j ); Object transformedDataForInner = inners[j].transform( loadingResult, extractedDataForInner, context ); transformedData = compositor.set( transformedData, j, transformedDataForInner ); } - accumulated = accumulator.transform( accumulated, i, compositor.finish( transformedData ) ); + accumulated = collector.transform( accumulated, i, compositor.finish( transformedData ) ); } - return accumulator.finish( accumulated ); + return collector.finish( accumulated ); } @Override @@ -81,7 +81,7 @@ protected String typeName() { protected void toNode(StubProjectionNode.Builder self) { // Not including the compositor to facilitate assertions // self.attribute( "compositor", compositor ); - self.attribute( "accumulator", accumulator ); + self.attribute( "collector", collector ); self.attribute( "singleValued", singleValued ); for ( StubSearchProjection inner : inners ) { appendInnerNode( self, "inner", inner ); @@ -95,19 +95,19 @@ static class Builder implements CompositeProjectionBuilder { @Override public final SearchProjection

build(SearchProjection[] inners, ProjectionCompositor compositor, - ProjectionAccumulator.Provider accumulatorProvider) { + ProjectionCollector.Provider collectorProvider) { StubSearchProjection[] typedInners = new StubSearchProjection[inners.length]; for ( int i = 0; i < inners.length; i++ ) { typedInners[i] = StubSearchProjection.from( inners[i] ); } - return doBuild( typedInners, compositor, accumulatorProvider.get(), accumulatorProvider.isSingleValued() ); + return doBuild( typedInners, compositor, collectorProvider.get(), collectorProvider.isSingleValued() ); } protected SearchProjection

doBuild(StubSearchProjection[] typedInners, ProjectionCompositor compositor, - ProjectionAccumulator accumulator, boolean singleValued) { - return new StubCompositeProjection<>( typedInners, compositor, accumulator, singleValued ); + ProjectionCollector collector, boolean singleValued) { + return new StubCompositeProjection<>( typedInners, compositor, collector, singleValued ); } } } diff --git a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubDistanceToFieldProjection.java b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubDistanceToFieldProjection.java index d57fd459466..82707d8ab37 100644 --- a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubDistanceToFieldProjection.java +++ b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubDistanceToFieldProjection.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.projection.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.DistanceToFieldProjectionBuilder; import org.hibernate.search.engine.spatial.DistanceUnit; @@ -39,7 +39,7 @@ public void unit(DistanceUnit unit) { } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { throw new AssertionFailure( "Distance projections are not supported in the stub backend." ); } } diff --git a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldHighlightProjection.java b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldHighlightProjection.java index dc653a97e26..ea1df494f89 100644 --- a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldHighlightProjection.java +++ b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldHighlightProjection.java @@ -8,7 +8,7 @@ import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.dsl.spi.HighlightProjectionBuilder; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.common.impl.AbstractStubSearchQueryElementFactory; @@ -18,13 +18,13 @@ public class StubFieldHighlightProjection extends StubSearchProjection { private final String fieldPath; private final String highlighterName; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; public StubFieldHighlightProjection(String fieldPath, String highlighterName, - ProjectionAccumulator accumulator) { + ProjectionCollector collector) { this.fieldPath = fieldPath; this.highlighterName = highlighterName; - this.accumulator = accumulator; + this.collector = collector; } @Override @@ -36,7 +36,7 @@ public Object extract(ProjectionHitMapper projectionHitMapper, Iterator pr @Override @SuppressWarnings("unchecked") public T transform(LoadingResult loadingResult, Object extractedData, StubSearchProjectionContext context) { - return accumulator.finish( (A) extractedData ); + return collector.finish( (A) extractedData ); } @Override @@ -64,8 +64,8 @@ static class Builder extends HighlightProjectionBuilder { } @Override - public SearchProjection build(ProjectionAccumulator.Provider accumulatorProvider) { - return new StubFieldHighlightProjection<>( path, highlighterName, accumulatorProvider.get() ); + public SearchProjection build(ProjectionCollector.Provider collectorProvider) { + return new StubFieldHighlightProjection<>( path, highlighterName, collectorProvider.get() ); } } } diff --git a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldProjection.java b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldProjection.java index 9926b435245..21688cebcaf 100644 --- a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldProjection.java +++ b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubFieldProjection.java @@ -12,7 +12,7 @@ import org.hibernate.search.engine.search.common.ValueModel; import org.hibernate.search.engine.search.loading.spi.LoadingResult; import org.hibernate.search.engine.search.loading.spi.ProjectionHitMapper; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.FieldProjectionBuilder; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.common.impl.AbstractStubSearchQueryElementFactory; @@ -25,17 +25,17 @@ public class StubFieldProjection extends StubSearchProjection

{ private final Class fieldType; private final Class expectedType; private final ProjectionConverter converter; - private final ProjectionAccumulator accumulator; + private final ProjectionCollector collector; private final boolean singleValued; public StubFieldProjection(String fieldPath, Class fieldType, Class expectedType, ProjectionConverter converter, - ProjectionAccumulator accumulator, boolean singleValued) { + ProjectionCollector collector, boolean singleValued) { this.fieldPath = fieldPath; this.fieldType = fieldType; this.expectedType = expectedType; this.converter = converter; - this.accumulator = accumulator; + this.collector = collector; this.singleValued = singleValued; } @@ -50,9 +50,9 @@ public A extract(ProjectionHitMapper projectionHitMapper, Iterator project else { fieldValues = (Iterable) projectionFromIndex.next(); } - A accumulated = accumulator.createInitial(); + A accumulated = collector.createInitial(); for ( Object fieldValue : fieldValues ) { - accumulated = accumulator.accumulate( accumulated, fieldType.cast( fieldValue ) ); + accumulated = collector.accumulate( accumulated, fieldType.cast( fieldValue ) ); } return accumulated; } @@ -62,9 +62,9 @@ public A extract(ProjectionHitMapper projectionHitMapper, Iterator project public P transform(LoadingResult loadingResult, Object extractedData, StubSearchProjectionContext context) { A accumulated = (A) extractedData; - A transformedData = accumulator.transformAll( accumulated, converter.delegate(), + A transformedData = collector.transformAll( accumulated, converter.delegate(), context.fromDocumentValueConvertContext() ); - return accumulator.finish( transformedData ); + return collector.finish( transformedData ); } @Override @@ -78,7 +78,7 @@ protected void toNode(StubProjectionNode.Builder self) { self.attribute( "fieldType", fieldType ); self.attribute( "expectedType", expectedType ); self.attribute( "converter", converter ); - self.attribute( "accumulator", accumulator ); + self.attribute( "collector", collector ); self.attribute( "singleValued", singleValued ); } @@ -120,9 +120,9 @@ static class Builder implements FieldProjectionBuilder { } @Override - public

SearchProjection

build(ProjectionAccumulator.Provider accumulatorProvider) { + public

SearchProjection

build(ProjectionCollector.Provider collectorProvider) { return new StubFieldProjection<>( fieldPath, valueClass, expectedType, converter, - accumulatorProvider.get(), accumulatorProvider.isSingleValued() ); + collectorProvider.get(), collectorProvider.isSingleValued() ); } } } diff --git a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubObjectProjection.java b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubObjectProjection.java index 28aa0dfc7be..b8e6214b032 100644 --- a/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubObjectProjection.java +++ b/util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/search/projection/impl/StubObjectProjection.java @@ -4,7 +4,7 @@ */ package org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.projection.impl; -import org.hibernate.search.engine.search.projection.ProjectionAccumulator; +import org.hibernate.search.engine.search.projection.ProjectionCollector; import org.hibernate.search.engine.search.projection.SearchProjection; import org.hibernate.search.engine.search.projection.spi.CompositeProjectionBuilder; import org.hibernate.search.engine.search.projection.spi.ProjectionCompositor; @@ -17,9 +17,9 @@ public class StubObjectProjection extends StubCompositeProjection[] inners, - ProjectionCompositor compositor, ProjectionAccumulator accumulator, + ProjectionCompositor compositor, ProjectionCollector collector, boolean singleValued) { - super( inners, compositor, accumulator, singleValued ); + super( inners, compositor, collector, singleValued ); this.objectFieldPath = objectFieldPath; } @@ -51,9 +51,9 @@ static class Builder extends StubCompositeProjection.Builder { @Override protected SearchProjection

doBuild(StubSearchProjection[] typedInners, - ProjectionCompositor compositor, ProjectionAccumulator accumulator, + ProjectionCompositor compositor, ProjectionCollector collector, boolean singleValued) { - return new StubObjectProjection<>( objectFieldPath, typedInners, compositor, accumulator, singleValued ); + return new StubObjectProjection<>( objectFieldPath, typedInners, compositor, collector, singleValued ); } } }