Skip to content

Commit 2c5b26b

Browse files
feat: add OceanBase UI config settings (#691)
Signed-off-by: min.tian <min.tian.cn@gmail.com>
1 parent eb79134 commit 2c5b26b

File tree

4 files changed

+115
-11
lines changed

4 files changed

+115
-11
lines changed

vectordb_bench/backend/clients/oceanbase/config.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TypedDict
22

3-
from pydantic import BaseModel, SecretStr, validator
3+
from pydantic import BaseModel, SecretStr
44

55
from ..api import DBCaseConfig, DBConfig, IndexType, MetricType
66

@@ -31,14 +31,6 @@ def to_dict(self) -> OceanBaseConfigDict:
3131
"database": self.database,
3232
}
3333

34-
@validator("*")
35-
def not_empty_field(cls, v: any, field: any):
36-
if field.name in ["password", "host", "db_label"]:
37-
return v
38-
if isinstance(v, str | SecretStr) and len(v) == 0:
39-
raise ValueError("Empty string!")
40-
return v
41-
4234

4335
class OceanBaseIndexConfig(BaseModel):
4436
index: IndexType
@@ -83,7 +75,7 @@ def search_param(self) -> dict:
8375

8476

8577
class OceanBaseIVFConfig(OceanBaseIndexConfig, DBCaseConfig):
86-
m: int
78+
m: int | None = None
8779
sample_per_nlist: int
8880
nbits: int | None = None
8981
nlist: int

vectordb_bench/frontend/components/run_test/generateTasks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ def generate_tasks(activedDbList: list[DB], dbConfigs, activedCaseList: list[Cas
66
tasks = []
77
for db in activedDbList:
88
for case in activedCaseList:
9+
cfg = {key.value: value for key, value in allCaseConfigs[db][case].items()}
10+
# Many DBCaseConfig models require an `index` field, while the UI stores the selection under `IndexType`.
11+
# Passing both keeps backwards-compatibility (extra fields are ignored) and enables strict models (e.g. OceanBase).
12+
if CaseConfigParamType.IndexType in allCaseConfigs[db][case] and "index" not in cfg:
13+
cfg["index"] = allCaseConfigs[db][case][CaseConfigParamType.IndexType]
914
task = TaskConfig(
1015
db=db.value,
1116
db_config=dbConfigs[db],
1217
case_config=case,
1318
db_case_config=db.case_config_cls(allCaseConfigs[db][case].get(CaseConfigParamType.IndexType, None))(
14-
**{key.value: value for key, value in allCaseConfigs[db][case].items()}
19+
**cfg
1520
),
1621
)
1722
tasks.append(task)

vectordb_bench/frontend/config/dbCaseConfigs.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,22 @@ class CaseConfigInput(BaseModel):
423423
},
424424
)
425425

426+
CaseConfigParamInput_IndexType_OceanBase = CaseConfigInput(
427+
label=CaseConfigParamType.IndexType,
428+
inputType=InputType.Option,
429+
inputHelp="Select OceanBase index type",
430+
inputConfig={
431+
"options": [
432+
IndexType.HNSW.value,
433+
IndexType.HNSW_SQ.value,
434+
IndexType.HNSW_BQ.value,
435+
IndexType.IVFFlat.value,
436+
IndexType.IVFSQ8.value,
437+
IndexType.IVFPQ.value,
438+
],
439+
},
440+
)
441+
426442
CaseConfigParamInput_IndexType_PgDiskANN = CaseConfigInput(
427443
label=CaseConfigParamType.IndexType,
428444
inputHelp="Select Index Type",
@@ -685,6 +701,20 @@ class CaseConfigInput(BaseModel):
685701
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None) == IndexType.HNSW.value,
686702
)
687703

704+
CaseConfigParamInput_m_OceanBase = CaseConfigInput(
705+
label=CaseConfigParamType.m,
706+
displayLabel="m",
707+
inputHelp="HNSW graph degree (m) for OceanBase HNSW/HNSW_SQ/HNSW_BQ",
708+
inputType=InputType.Number,
709+
inputConfig={
710+
"min": 4,
711+
"max": 128,
712+
"value": 16,
713+
},
714+
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None)
715+
in [IndexType.HNSW.value, IndexType.HNSW_SQ.value, IndexType.HNSW_BQ.value],
716+
)
717+
688718

689719
CaseConfigParamInput_EFConstruction_Milvus = CaseConfigInput(
690720
label=CaseConfigParamType.EFConstruction,
@@ -703,6 +733,20 @@ class CaseConfigInput(BaseModel):
703733
],
704734
)
705735

736+
CaseConfigParamInput_EFConstruction_OceanBase = CaseConfigInput(
737+
label=CaseConfigParamType.EFConstruction,
738+
displayLabel="efConstruction",
739+
inputHelp="HNSW efConstruction for OceanBase HNSW/HNSW_SQ/HNSW_BQ",
740+
inputType=InputType.Number,
741+
inputConfig={
742+
"min": 8,
743+
"max": 65535,
744+
"value": 256,
745+
},
746+
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None)
747+
in [IndexType.HNSW.value, IndexType.HNSW_SQ.value, IndexType.HNSW_BQ.value],
748+
)
749+
706750
CaseConfigParamInput_SQType = CaseConfigInput(
707751
label=CaseConfigParamType.sq_type,
708752
inputType=InputType.Option,
@@ -862,6 +906,48 @@ class CaseConfigInput(BaseModel):
862906
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None) == IndexType.HNSW.value,
863907
)
864908

909+
CaseConfigParamInput_ef_search_OceanBase = CaseConfigInput(
910+
label=CaseConfigParamType.ef_search,
911+
displayLabel="ef_search",
912+
inputHelp="HNSW ef_search (session var ob_hnsw_ef_search) for OceanBase",
913+
inputType=InputType.Number,
914+
inputConfig={
915+
"min": 1,
916+
"max": 65535,
917+
"value": 100,
918+
},
919+
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None)
920+
in [IndexType.HNSW.value, IndexType.HNSW_SQ.value, IndexType.HNSW_BQ.value],
921+
)
922+
923+
CaseConfigParamInput_sample_per_nlist_OceanBase = CaseConfigInput(
924+
label=CaseConfigParamType.sample_per_nlist,
925+
displayLabel="sample_per_nlist",
926+
inputHelp="OceanBase IVF training sample multiplier (total samples = sample_per_nlist * nlist)",
927+
inputType=InputType.Number,
928+
inputConfig={
929+
"min": 1,
930+
"max": 1000000,
931+
"value": 256,
932+
},
933+
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None)
934+
in [IndexType.IVFFlat.value, IndexType.IVFSQ8.value, IndexType.IVFPQ.value],
935+
)
936+
937+
CaseConfigParamInput_ivf_nprobes_OceanBase = CaseConfigInput(
938+
label=CaseConfigParamType.ivf_nprobes,
939+
displayLabel="ivf_nprobes",
940+
inputHelp="OceanBase IVF search probes (session var ob_ivf_nprobes)",
941+
inputType=InputType.Number,
942+
inputConfig={
943+
"min": 1,
944+
"max": 65535,
945+
"value": 10,
946+
},
947+
isDisplayed=lambda config: config.get(CaseConfigParamType.IndexType, None)
948+
in [IndexType.IVFFlat.value, IndexType.IVFSQ8.value, IndexType.IVFPQ.value],
949+
)
950+
865951
CaseConfigParamInput_EFConstruction_PgVector = CaseConfigInput(
866952
label=CaseConfigParamType.ef_construction,
867953
inputType=InputType.Number,
@@ -2302,6 +2388,19 @@ class CaseConfigInput(BaseModel):
23022388
CaseConfigParamInput_VectorSearchBeamSize_CockroachDB,
23032389
]
23042390

2391+
OceanBaseLoadConfig = [
2392+
CaseConfigParamInput_IndexType_OceanBase,
2393+
CaseConfigParamInput_m_OceanBase,
2394+
CaseConfigParamInput_EFConstruction_OceanBase,
2395+
CaseConfigParamInput_ef_search_OceanBase,
2396+
CaseConfigParamInput_Nlist,
2397+
CaseConfigParamInput_sample_per_nlist_OceanBase,
2398+
CaseConfigParamInput_Nbits_PQ,
2399+
CaseConfigParamInput_M_PQ,
2400+
CaseConfigParamInput_ivf_nprobes_OceanBase,
2401+
]
2402+
OceanBasePerformanceConfig = OceanBaseLoadConfig
2403+
23052404
MariaDBLoadingConfig = [
23062405
CaseConfigParamInput_IndexType_MariaDB,
23072406
CaseConfigParamInput_StorageEngine_MariaDB,
@@ -2616,6 +2715,10 @@ class CaseConfigInput(BaseModel):
26162715
CaseLabel.Load: CockroachDBLoadingConfig,
26172716
CaseLabel.Performance: CockroachDBPerformanceConfig,
26182717
},
2718+
DB.OceanBase: {
2719+
CaseLabel.Load: OceanBaseLoadConfig,
2720+
CaseLabel.Performance: OceanBasePerformanceConfig,
2721+
},
26192722
}
26202723

26212724

vectordb_bench/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class CaseConfigParamType(Enum):
137137
confidence_interval = "confidence_interval"
138138
clip = "clip"
139139

140+
# OceanBase IVF parameters
141+
sample_per_nlist = "sample_per_nlist"
142+
ivf_nprobes = "ivf_nprobes"
143+
140144
# CockroachDB parameters
141145
min_partition_size = "min_partition_size"
142146
max_partition_size = "max_partition_size"

0 commit comments

Comments
 (0)