Skip to content

Commit fcb2d0c

Browse files
committed
refine cmd-line options
1 parent cbe3f17 commit fcb2d0c

File tree

2 files changed

+56
-14
lines changed

2 files changed

+56
-14
lines changed

vectordb_bench/backend/clients/doris/cli.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,28 @@
1515

1616

1717
def _parse_kv_list(_ctx, _param, values): # noqa: ANN001
18-
# values is a tuple of strings like ("k=v", "x=y")
18+
"""Parse repeatable or comma-separated key=value items into a dict.
19+
20+
Accepts any of the following forms (and mixtures thereof):
21+
--index-prop a=1 --index-prop b=2
22+
--index-prop a=1,b=2
23+
--index-prop a=1,b=2 --index-prop c=3
24+
"""
1925
parsed: dict[str, str] = {}
2026
if not values:
2127
return parsed
2228
for item in values:
23-
if "=" not in item:
24-
raise click.BadParameter(f"Expect key=value, got: {item}")
25-
k, v = item.split("=", 1)
26-
k = k.strip()
27-
v = v.strip()
28-
if not k:
29-
raise click.BadParameter(f"Empty key in: {item}")
30-
parsed[k] = v
29+
# allow comma-separated list in a single occurrence
30+
parts = [p.strip() for p in str(item).split(",") if p and p.strip()]
31+
for part in parts:
32+
if "=" not in part:
33+
raise click.BadParameter(f"Expect key=value, got: {part}")
34+
k, v = part.split("=", 1)
35+
k = k.strip()
36+
v = v.strip()
37+
if not k:
38+
raise click.BadParameter(f"Empty key in: {part}")
39+
parsed[k] = v
3140
return parsed
3241

3342

@@ -113,7 +122,7 @@ class DorisTypedDict(CommonTypedDict, HNSWBaseTypedDict):
113122
"--index-prop",
114123
type=str,
115124
multiple=True,
116-
help="Extra index PROPERTY as key=value (repeatable)",
125+
help="Extra index PROPERTY as key=value (repeatable or comma-separated, e.g. a=1,b=2)",
117126
callback=_parse_kv_list,
118127
),
119128
]
@@ -123,7 +132,7 @@ class DorisTypedDict(CommonTypedDict, HNSWBaseTypedDict):
123132
"--session-var",
124133
type=str,
125134
multiple=True,
126-
help="Session variable key=value applied to each SQL session (repeatable)",
135+
help="Session variable key=value applied to each SQL session (repeatable or comma-separated)",
127136
callback=_parse_kv_list,
128137
),
129138
]

vectordb_bench/backend/clients/doris/doris.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,42 @@ def _create_table(self):
157157
{"id": 1, "embedding": [0.0] * self.dim}
158158
])
159159

160-
# Prepare index options
160+
# Prepare index options (attach custom HNSW properties if provided)
161161
index_options = None
162162
if not getattr(self.case_config, "no_index", False):
163163
index_param = self.case_config.index_param()
164164
metric_type = index_param.get("metric_fn", "l2_distance")
165-
166165
index_options = IndexOptions(
167166
index_type="hnsw",
168167
metric_type=metric_type,
169-
dim=self.dim
168+
dim=self.dim,
170169
)
170+
# Anything beyond metric_fn are treated as index properties (e.g. max_degree, ef_construction, user props)
171+
extra_props = {k: v for k, v in index_param.items() if k != "metric_fn"}
172+
# Try to set as attributes first; fall back to a generic properties dict
173+
if extra_props:
174+
applied, stored = {}, {}
175+
for k, v in extra_props.items():
176+
attr_name = k
177+
if hasattr(index_options, attr_name):
178+
try:
179+
setattr(index_options, attr_name, v)
180+
applied[k] = v
181+
except Exception: # noqa: BLE001
182+
stored[k] = v
183+
else:
184+
stored[k] = v
185+
if stored:
186+
# Keep a dynamic container so downstream SDK logic can inspect
187+
setattr(index_options, "properties", {**getattr(index_options, "properties", {}), **stored})
188+
log.info(
189+
"Index options prepared: metric=%s applied_props=%s stored_props=%s",
190+
metric_type,
191+
applied,
192+
stored,
193+
)
194+
else:
195+
log.info("Index options prepared: metric=%s (no extra properties)", metric_type)
171196
log.info("Creating table %s with index %s", self.table_name, index_param)
172197
else:
173198
log.info("Creating table %s without ANN index", self.table_name)
@@ -188,6 +213,14 @@ def _create_table(self):
188213
self.table.index_options.metric_type = "inner_product"
189214
else:
190215
self.table.index_options.metric_type = "l2_distance"
216+
# Re-apply dynamic properties to runtime index object if we stored them
217+
if index_options and hasattr(index_options, "properties") and isinstance(index_options.properties, dict):
218+
for k, v in index_options.properties.items():
219+
if hasattr(self.table.index_options, k):
220+
try:
221+
setattr(self.table.index_options, k, v)
222+
except Exception: # noqa: BLE001
223+
log.debug("Skip setting index_options.%s at runtime", k)
191224
except Exception:
192225
pass
193226

0 commit comments

Comments
 (0)