You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2026/09/22 20:05:44 UTC
[S] Change in asterixdb[master]: [ASTERIXDB-3817][STO] Reject an unknown metric in the quantization codec
From Hongyu Shi <le...@gmail.com>:
Hongyu Shi has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21867?usp=email )
Change subject: [ASTERIXDB-3817][STO] Reject an unknown metric in the quantization codec
......................................................................
[ASTERIXDB-3817][STO] Reject an unknown metric in the quantization codec
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
fromDistanceMetric fell back to DOT_PRODUCT for a metric it did not recognize. The fallback is removed; an unknown metric is an error that names the value.
Change-Id: Ie91a7b27265a9259e1ec6ebdb96f46a1c700bf3b
---
M asterixdb/asterix-common/src/main/java/org/apache/asterix/common/vector/OptimizedScalarQuantizationCodec.java
1 file changed, 6 insertions(+), 6 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/67/21867/1
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/vector/OptimizedScalarQuantizationCodec.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/vector/OptimizedScalarQuantizationCodec.java
index ed6b51e..661eb09 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/vector/OptimizedScalarQuantizationCodec.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/vector/OptimizedScalarQuantizationCodec.java
@@ -78,15 +78,15 @@
* Converts a distance metric string to SimilarityFunction enum.
*
* @param distanceMetric Distance metric string (e.g., "euclidean", "cosine", "dot")
- * @return Corresponding SimilarityFunction enum, or DOT_PRODUCT as default
+ * @return Corresponding SimilarityFunction enum
+ * @throws HyracksDataException if the metric is not one a vector index can be created with
*/
- public static SimilarityFunction fromDistanceMetric(String distanceMetric) {
- // Resolve the metric name through VectorSimilarityMetric, the single source of truth for vector
- // metric aliases (it handles null/blank/casing). A null (unrecognized or blank) metric falls back
- // to DOT_PRODUCT, preserving the previous default for unknown metrics.
+ public static SimilarityFunction fromDistanceMetric(String distanceMetric) throws HyracksDataException {
VectorSimilarityMetric metric = VectorSimilarityMetric.fromAlias(distanceMetric);
if (metric == null) {
- return SimilarityFunction.DOT_PRODUCT;
+ // The codes must be built under the metric the index's distance function ranks by.
+ throw new RuntimeDataException(ErrorCode.ILLEGAL_STATE,
+ "Unknown vector distance metric '" + distanceMetric + "' reached the quantizer");
}
return switch (metric) {
case EUCLIDEAN -> SimilarityFunction.EUCLIDEAN;
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21867?usp=email
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Ie91a7b27265a9259e1ec6ebdb96f46a1c700bf3b
Gerrit-Change-Number: 21867
Gerrit-PatchSet: 1
Gerrit-Owner: Hongyu Shi <le...@gmail.com>