diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/AnalyzedStringFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/AnalyzedStringFieldTypeDescriptor.java index 1075d974e5b..8dbef5af038 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/AnalyzedStringFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/AnalyzedStringFieldTypeDescriptor.java @@ -14,6 +14,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class AnalyzedStringFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -62,6 +63,11 @@ protected List> createMultiResultingInSingleAfterMedian() { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigDecimalFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigDecimalFieldTypeDescriptor.java index 2b3eb45c543..fd16592b751 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigDecimalFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigDecimalFieldTypeDescriptor.java @@ -19,6 +19,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; public class BigDecimalFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -66,6 +67,16 @@ protected BigDecimal applyDelta(BigDecimal value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected BigDecimal valueOf(int value) { + return BigDecimal.valueOf( value ).setScale( 2, RoundingMode.FLOOR ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigIntegerFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigIntegerFieldTypeDescriptor.java index 5a0856c2ed5..baa7f6bbe20 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigIntegerFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BigIntegerFieldTypeDescriptor.java @@ -14,6 +14,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class BigIntegerFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -60,6 +61,16 @@ protected BigInteger applyDelta(BigInteger value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected BigInteger valueOf(int value) { + return BigInteger.valueOf( value * 100L ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BooleanFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BooleanFieldTypeDescriptor.java index 4b2ff18bbc7..8b3f4af3556 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BooleanFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/BooleanFieldTypeDescriptor.java @@ -12,6 +12,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class BooleanFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -46,6 +47,11 @@ protected List> createMultiResultingInSingleAfterMedian() { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ByteFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ByteFieldTypeDescriptor.java index 9f0e7291d1e..7af9016c304 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ByteFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ByteFieldTypeDescriptor.java @@ -8,9 +8,11 @@ import java.util.List; import java.util.Optional; +import org.hibernate.search.engine.cfg.spi.ConvertUtils; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class ByteFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -56,6 +58,16 @@ private byte toByteExact(int value) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Byte valueOf(int value) { + return ConvertUtils.convertByte( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/DoubleFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/DoubleFieldTypeDescriptor.java index 54c62272639..fe1ed1fa3d0 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/DoubleFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/DoubleFieldTypeDescriptor.java @@ -8,9 +8,11 @@ import java.util.List; import java.util.Optional; +import org.hibernate.search.engine.cfg.spi.ConvertUtils; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class DoubleFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -49,6 +51,16 @@ protected Double applyDelta(Double value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Double valueOf(int value) { + return ConvertUtils.convertDouble( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FieldTypeDescriptor.java index 15d7026ad78..801b1b08221 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FieldTypeDescriptor.java @@ -15,6 +15,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; public abstract class FieldTypeDescriptor> { @@ -181,6 +182,8 @@ public final AscendingUniqueTermValues getAscendingUniqueTermValues() { protected abstract AscendingUniqueTermValues createAscendingUniqueTermValues(); + public abstract MetricAggregationsValues metricAggregationsValues(); + /** * @return A set of indexables values, not necessarily unique. */ diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java index 0a2e2498908..ac00a6ee8b1 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/FloatFieldTypeDescriptor.java @@ -8,9 +8,11 @@ import java.util.List; import java.util.Optional; +import org.hibernate.search.engine.cfg.spi.ConvertUtils; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class FloatFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -49,6 +51,16 @@ protected Float applyDelta(Float value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Float valueOf(int value) { + return ConvertUtils.convertFloat( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/GeoPointFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/GeoPointFieldTypeDescriptor.java index cfa5d533023..c6a1ee40853 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/GeoPointFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/GeoPointFieldTypeDescriptor.java @@ -12,6 +12,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class GeoPointFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -26,6 +27,11 @@ protected AscendingUniqueTermValues createAscendingUniqueTermValues() return null; // Value lookup is not supported } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/InstantFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/InstantFieldTypeDescriptor.java index 1fd7e227b9b..1aa67e59c22 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/InstantFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/InstantFieldTypeDescriptor.java @@ -18,6 +18,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class InstantFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -57,6 +58,16 @@ protected Instant applyDelta(Instant value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Instant valueOf(int value) { + return Instant.ofEpochSecond( value * 100_000L ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/IntegerFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/IntegerFieldTypeDescriptor.java index 0ad6d626ce7..f9b8e0c4a8d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/IntegerFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/IntegerFieldTypeDescriptor.java @@ -11,6 +11,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class IntegerFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -49,6 +50,16 @@ protected Integer applyDelta(Integer value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Integer valueOf(int value) { + return value; + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/KeywordStringFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/KeywordStringFieldTypeDescriptor.java index f6d05b0d669..54cf2e3d2ed 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/KeywordStringFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/KeywordStringFieldTypeDescriptor.java @@ -11,6 +11,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class KeywordStringFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -54,6 +55,11 @@ protected List> createMultiResultingInSingleAfterMedian() { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateFieldTypeDescriptor.java index a9376eb7b5b..ea9ae891e31 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateFieldTypeDescriptor.java @@ -13,6 +13,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class LocalDateFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -51,6 +52,16 @@ protected LocalDate applyDelta(LocalDate value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected LocalDate valueOf(int value) { + return LocalDate.ofEpochDay( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateTimeFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateTimeFieldTypeDescriptor.java index 95370a80046..77d329f579a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateTimeFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalDateTimeFieldTypeDescriptor.java @@ -5,6 +5,7 @@ package org.hibernate.search.integrationtest.backend.tck.testsupport.types; import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.List; @@ -14,6 +15,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class LocalDateTimeFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -53,6 +55,16 @@ protected LocalDateTime applyDelta(LocalDateTime value, int multiplierForDelta) }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected LocalDateTime valueOf(int value) { + return LocalDateTime.ofEpochSecond( value, 0, ZoneOffset.UTC ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalTimeFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalTimeFieldTypeDescriptor.java index aa54e643d4e..b9248957e8c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalTimeFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LocalTimeFieldTypeDescriptor.java @@ -14,6 +14,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class LocalTimeFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -53,6 +54,11 @@ protected LocalTime applyDelta(LocalTime value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LongFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LongFieldTypeDescriptor.java index 4f1e62255af..696ffc9862b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LongFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/LongFieldTypeDescriptor.java @@ -10,9 +10,11 @@ import java.util.List; import java.util.Optional; +import org.hibernate.search.engine.cfg.spi.ConvertUtils; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; public class LongFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -61,6 +63,16 @@ protected Long applyDelta(Long value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Long valueOf(int value) { + return ConvertUtils.convertLong( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/MonthDayFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/MonthDayFieldTypeDescriptor.java index f49136005d8..6ed999e6085 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/MonthDayFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/MonthDayFieldTypeDescriptor.java @@ -17,6 +17,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class MonthDayFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -56,6 +57,11 @@ protected MonthDay applyDelta(MonthDay value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/NormalizedStringFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/NormalizedStringFieldTypeDescriptor.java index 70e44dfe078..1c0715fac7a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/NormalizedStringFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/NormalizedStringFieldTypeDescriptor.java @@ -15,6 +15,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class NormalizedStringFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -68,6 +69,11 @@ protected List> createMultiResultingInSingleAfterMedian() { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetDateTimeFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetDateTimeFieldTypeDescriptor.java index 6cb6e10133b..81f8c8248c8 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetDateTimeFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetDateTimeFieldTypeDescriptor.java @@ -19,6 +19,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class OffsetDateTimeFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -64,6 +65,16 @@ protected OffsetDateTime applyDelta(OffsetDateTime value, int multiplierForDelta }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected OffsetDateTime valueOf(int value) { + return OffsetDateTime.ofInstant( Instant.ofEpochSecond( value * 100_000L ), ZoneOffset.UTC ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { @@ -84,7 +95,8 @@ protected List createSingle() { @Override protected List createUniquelyMatchableValues() { List values = new ArrayList<>(); - for ( LocalDateTime localDateTime : LocalDateTimeFieldTypeDescriptor.INSTANCE.getIndexableValues().getSingle() ) { + for ( LocalDateTime localDateTime : LocalDateTimeFieldTypeDescriptor.INSTANCE.getIndexableValues() + .getSingle() ) { for ( ZoneOffset offset : createIndexableOffsetList() ) { values.add( localDateTime.atOffset( offset ) ); } @@ -127,7 +139,8 @@ List createIndexableOffsetList() { @Override public OffsetDateTime valueFromInteger(int integer) { - return LocalDateTimeFieldTypeDescriptor.INSTANCE.valueFromInteger( integer ).atOffset( ZoneOffset.ofHours( 2 ) ); + return LocalDateTimeFieldTypeDescriptor.INSTANCE.valueFromInteger( integer ).atOffset( + ZoneOffset.ofHours( 2 ) ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetTimeFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetTimeFieldTypeDescriptor.java index e2b83ab9f90..691be141027 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetTimeFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/OffsetTimeFieldTypeDescriptor.java @@ -21,6 +21,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class OffsetTimeFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -65,6 +66,11 @@ protected OffsetTime applyDelta(OffsetTime value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ShortFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ShortFieldTypeDescriptor.java index f1125a57200..79b70d52d81 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ShortFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ShortFieldTypeDescriptor.java @@ -8,9 +8,11 @@ import java.util.List; import java.util.Optional; +import org.hibernate.search.engine.cfg.spi.ConvertUtils; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class ShortFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -56,6 +58,16 @@ private short toShortExact(int value) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected Short valueOf(int value) { + return ConvertUtils.convertShort( value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/VectorFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/VectorFieldTypeDescriptor.java index fbfed2d5670..fb1240dc2f4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/VectorFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/VectorFieldTypeDescriptor.java @@ -10,6 +10,7 @@ import org.hibernate.search.engine.backend.types.dsl.VectorFieldTypeOptionsStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public abstract class VectorFieldTypeDescriptor extends FieldTypeDescriptor> { @@ -41,6 +42,11 @@ protected AscendingUniqueTermValues createAscendingUniqueTermValues() { return null; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return null; + } + @Override public boolean isFieldSortSupported() { return false; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearFieldTypeDescriptor.java index 7f659ce7b19..8064cc234ca 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearFieldTypeDescriptor.java @@ -14,6 +14,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class YearFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -52,6 +53,22 @@ protected Year applyDelta(Year value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + + @Override + public Year expectedSum() { + return null; + } + + @Override + protected Year valueOf(int value) { + return Year.of( value + 2000 ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearMonthFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearMonthFieldTypeDescriptor.java index 3824af943a2..a13179ac957 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearMonthFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/YearMonthFieldTypeDescriptor.java @@ -8,6 +8,7 @@ import java.time.Year; import java.time.YearMonth; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; @@ -18,6 +19,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class YearMonthFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -57,6 +59,23 @@ protected YearMonth applyDelta(YearMonth value, int multiplierForDelta) { }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + + @Override + public YearMonth expectedSum() { + return null; + } + + @Override + protected YearMonth valueOf(int value) { + return YearMonth.of( 2017, Month.NOVEMBER ) + .with( ChronoField.PROLEPTIC_MONTH, value ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ZonedDateTimeFieldTypeDescriptor.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ZonedDateTimeFieldTypeDescriptor.java index 0be9bd2283f..2c8fddf4796 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ZonedDateTimeFieldTypeDescriptor.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/ZonedDateTimeFieldTypeDescriptor.java @@ -21,6 +21,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueTermValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableValues; +import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.MetricAggregationsValues; public class ZonedDateTimeFieldTypeDescriptor extends StandardFieldTypeDescriptor { @@ -72,6 +73,17 @@ protected ZonedDateTime applyDelta(ZonedDateTime value, int multiplierForDelta) }; } + @Override + public MetricAggregationsValues metricAggregationsValues() { + return new MetricAggregationsValues() { + @Override + protected ZonedDateTime valueOf(int value) { + return ZonedDateTime.of( LocalDateTime.ofEpochSecond( value, 0, ZoneOffset.UTC ), + ZoneId.of( ZoneOffset.UTC.getId() ) ); + } + }; + } + @Override protected IndexableValues createIndexableValues() { return new IndexableValues() { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/values/MetricAggregationsValues.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/values/MetricAggregationsValues.java new file mode 100644 index 00000000000..543136d1da5 --- /dev/null +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/types/values/MetricAggregationsValues.java @@ -0,0 +1,34 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.search.integrationtest.backend.tck.testsupport.types.values; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public abstract class MetricAggregationsValues { + + private static final int[] DRIVER_VALUES = new int[] { 9, 18, 3, 18, 7, -10, 3, 0, 7, 0 }; + + private final List values = Collections.unmodifiableList( createValues() ); + + public final List values() { + return values; + } + + public F expectedSum() { + return valueOf( 55 ); + } + + protected abstract F valueOf(int value); + + private List createValues() { + return Arrays.stream( driverValues() ).mapToObj( this::valueOf ).toList(); + } + + private int[] driverValues() { + return DRIVER_VALUES; + } +}