Skip to content

Commit 35f2e94

Browse files
committed
collection name
1 parent df3650e commit 35f2e94

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

vectordb_bench/backend/clients/doris/doris.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(
1818
dim: int,
1919
db_config: dict,
2020
db_case_config: DorisCaseConfig,
21+
collection_name: str | None = None,
2122
drop_old: bool = False,
2223
**kwargs,
2324
):
@@ -26,8 +27,9 @@ def __init__(
2627
self.case_config = db_case_config
2728
self.dim = dim
2829
self.search_fn = db_case_config.search_param()["metric_fn"]
30+
# Prefer provided collection_name; otherwise fallback to a simple default
2931
# e.g. l2_distance128, inner_product128
30-
self.table_name = self.search_fn + str(dim)
32+
self.table_name = collection_name if collection_name else (self.search_fn + str(dim))
3133

3234
# Store connection configuration for lazy initialization
3335
self.auth_options = AuthOptions(

vectordb_bench/backend/task_runner.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,33 @@ def normalize(self) -> bool:
9797

9898
def init_db(self, drop_old: bool = True) -> None:
9999
db_cls = self.config.db.init_cls
100+
# Compose a compact, case-unique collection/table name for Doris to avoid cross-case interference
101+
collection_name = None
102+
try:
103+
from .clients import DB
104+
if self.config.db == DB.Doris:
105+
import re, hashlib
106+
# Primary identifier = case-type enum name from CLI (e.g., Performance768D10M)
107+
case_type_name = self.config.case_config.case_id.name
108+
base = f"vdb_{case_type_name.lower()}"
109+
# Sanitize to [a-z0-9_]
110+
base = re.sub(r"[^a-z0-9_]+", "_", base).strip("_")
111+
# Cap to 63 chars; add short hash if truncated
112+
if len(base) > 63:
113+
h = hashlib.md5(base.encode()).hexdigest()[:6]
114+
base = f"{base[:(63-7)]}_{h}"
115+
collection_name = base
116+
except Exception:
117+
# If anything goes wrong, fall back silently; Doris will use its default name logic
118+
collection_name = None
100119

101120
self.db = db_cls(
102121
dim=self.ca.dataset.data.dim,
103122
db_config=self.config.db_config.to_dict(),
104123
db_case_config=self.config.db_case_config,
105124
drop_old=drop_old,
106125
with_scalar_labels=self.ca.with_scalar_labels,
126+
**({"collection_name": collection_name} if collection_name else {}),
107127
)
108128

109129
def _pre_run(self, drop_old: bool = True):

0 commit comments

Comments
 (0)