TheR1sing3un commented on code in PR #9754:
URL: https://github.com/apache/paimon/pull/9754#discussion_r3998235604
##########
paimon-python/pypaimon/table/source/vector_search_read.py:
##########
@@ -751,41 +781,31 @@ def _table_options_map(table):
return table_options.to_map() if table_options is not None else {}
-def _raw_search_metric(table, vector_column, options, index_type=None):
- candidates = []
+def _configured_vector_metric(options, vector_column, index_type=None):
field_prefix = "fields.%s." % vector_column.name
index_prefix = "%s." % index_type if index_type else None
- for key in [
- field_prefix + "distance.metric",
- field_prefix + "metric",
- *(([
- index_prefix + "distance.metric",
- index_prefix + "metric",
- ]) if index_prefix is not None else []),
- "test.vector.metric",
- "lumina.distance.metric",
- "distance.metric",
- "metric",
- ]:
+ keys = [field_prefix + "distance.metric", field_prefix + "metric"]
+ if index_prefix is not None:
+ keys.extend([index_prefix + "distance.metric", index_prefix +
"metric"])
+ keys.extend(["test.vector.metric", "lumina.distance.metric",
"distance.metric", "metric"])
+ for key in keys:
if key in options:
- candidates.append(options[key])
+ return _normalize_metric(options[key])
+ return None
+
+
+def _raw_search_metric(table, vector_column, options, index_type=None):
+ from pypaimon.globalindex.vindex.vindex_vector_global_index_reader import
VINDEX_IDENTIFIERS
+
table_map = _table_options_map(table)
- for key in [
- field_prefix + "distance.metric",
- field_prefix + "metric",
- *(([
- index_prefix + "distance.metric",
- index_prefix + "metric",
- ]) if index_prefix is not None else []),
- "test.vector.metric",
- "lumina.distance.metric",
- "distance.metric",
- "metric",
- ]:
- if key in table_map:
- candidates.append(table_map[key])
- if candidates:
- return _normalize_metric(candidates[0])
+ for source in (options, table_map):
+ configured = _configured_vector_metric(source, vector_column,
index_type)
+ if configured is not None:
+ return configured
+
+ # Before an index exists, use its writer's default, not another column's
metric.
+ if index_type in VINDEX_IDENTIFIERS:
+ return "inner_product"
Review Comment:
nice catch, fixed it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]