pyobvector 0.2.12__tar.gz → 0.2.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyobvector-0.2.12 → pyobvector-0.2.13}/PKG-INFO +2 -2
- {pyobvector-0.2.12 → pyobvector-0.2.13}/README.md +1 -1
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/ob_vec_client.py +7 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/array.py +55 -39
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyproject.toml +1 -1
- {pyobvector-0.2.12 → pyobvector-0.2.13}/LICENSE +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/__init__.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/__init__.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/collection_schema.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/enum.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/exceptions.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/fts_index_param.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/index_param.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/milvus_like_client.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/ob_vec_json_table_client.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/partitions.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/client/schema_type.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/json_table/__init__.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/json_table/json_value_returning_func.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/json_table/oceanbase_dialect.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/json_table/virtual_data_type.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/__init__.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/dialect.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/full_text_index.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/geo_srid_point.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/gis_func.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/match_against_func.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/ob_table.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/reflection.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/replace_stmt.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/vec_dist_func.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/vector.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/schema/vector_index.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/util/__init__.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/util/ob_version.py +0 -0
- {pyobvector-0.2.12 → pyobvector-0.2.13}/pyobvector/util/vector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pyobvector
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.13
|
|
4
4
|
Summary: A python SDK for OceanBase Vector Store, based on SQLAlchemy, compatible with Milvus API.
|
|
5
5
|
Author: shanhaikang.shk
|
|
6
6
|
Author-email: shanhaikang.shk@oceanbase.com
|
|
@@ -36,7 +36,7 @@ poetry install
|
|
|
36
36
|
- install with pip:
|
|
37
37
|
|
|
38
38
|
```shell
|
|
39
|
-
pip install pyobvector==0.2.
|
|
39
|
+
pip install pyobvector==0.2.13
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Build Doc
|
|
@@ -89,6 +89,13 @@ class ObVecClient:
|
|
|
89
89
|
message=ExceptionsMessage.ClusterVersionIsLow,
|
|
90
90
|
)
|
|
91
91
|
|
|
92
|
+
def refresh_metadata(self, tables: Optional[list[str]] = None):
|
|
93
|
+
"""Reload metadata from the database."""
|
|
94
|
+
if tables is None:
|
|
95
|
+
self.metadata_obj.reflect(bind=self.engine, extend_existing=True)
|
|
96
|
+
else:
|
|
97
|
+
self.metadata_obj.reflect(bind=self.engine, only=tables, extend_existing=True)
|
|
98
|
+
|
|
92
99
|
def _insert_partition_hint_for_query_sql(self, sql: str, partition_hint: str):
|
|
93
100
|
from_index = sql.find("FROM")
|
|
94
101
|
assert from_index != -1
|
|
@@ -10,7 +10,6 @@ class ARRAY(UserDefinedType):
|
|
|
10
10
|
"""ARRAY data type definition with support for up to 6 levels of nesting."""
|
|
11
11
|
cache_ok = True
|
|
12
12
|
_string = String()
|
|
13
|
-
_max_nesting_level = 6
|
|
14
13
|
|
|
15
14
|
def __init__(self, item_type: Union[TypeEngine, type]):
|
|
16
15
|
"""Construct an ARRAY.
|
|
@@ -18,25 +17,17 @@ class ARRAY(UserDefinedType):
|
|
|
18
17
|
Args:
|
|
19
18
|
item_type: The data type of items in this array. For nested arrays,
|
|
20
19
|
pass another ARRAY type.
|
|
21
|
-
|
|
22
|
-
Raises:
|
|
23
|
-
ValueError: If nesting level exceeds the maximum allowed level (6).
|
|
24
20
|
"""
|
|
25
21
|
super(UserDefinedType, self).__init__()
|
|
26
22
|
if isinstance(item_type, type):
|
|
27
23
|
item_type = item_type()
|
|
28
24
|
self.item_type = item_type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
while isinstance(current_type, ARRAY):
|
|
36
|
-
level += 1
|
|
37
|
-
if level > self._max_nesting_level:
|
|
38
|
-
raise ValueError(f"Maximum nesting level of {self._max_nesting_level} exceeded")
|
|
39
|
-
current_type = current_type.item_type
|
|
25
|
+
if isinstance(item_type, ARRAY):
|
|
26
|
+
self.dim = item_type.dim + 1
|
|
27
|
+
else:
|
|
28
|
+
self.dim = 1
|
|
29
|
+
if self.dim > 6:
|
|
30
|
+
raise ValueError("Maximum nesting level of 6 exceeded")
|
|
40
31
|
|
|
41
32
|
def get_col_spec(self, **kw): # pylint: disable=unused-argument
|
|
42
33
|
"""Parse to array data type definition in text SQL."""
|
|
@@ -46,12 +37,33 @@ class ARRAY(UserDefinedType):
|
|
|
46
37
|
base_type = str(self.item_type)
|
|
47
38
|
return f"ARRAY({base_type})"
|
|
48
39
|
|
|
40
|
+
def _get_list_depth(self, value: Any) -> int:
|
|
41
|
+
if not isinstance(value, list):
|
|
42
|
+
return 0
|
|
43
|
+
max_depth = 0
|
|
44
|
+
for element in value:
|
|
45
|
+
current_depth = self._get_list_depth(element)
|
|
46
|
+
if current_depth > max_depth:
|
|
47
|
+
max_depth = current_depth
|
|
48
|
+
return 1 + max_depth
|
|
49
|
+
|
|
50
|
+
def _validate_dimension(self, value: list[Any]):
|
|
51
|
+
arr_depth = self._get_list_depth(value)
|
|
52
|
+
assert arr_depth == self.dim, "Array dimension mismatch, expected {}, got {}".format(self.dim, arr_depth)
|
|
53
|
+
|
|
49
54
|
def bind_processor(self, dialect):
|
|
50
|
-
|
|
55
|
+
item_type = self.item_type
|
|
56
|
+
while isinstance(item_type, ARRAY):
|
|
57
|
+
item_type = item_type.item_type
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
item_proc = item_type.dialect_impl(dialect).bind_processor(dialect)
|
|
60
|
+
|
|
61
|
+
def process(value: Optional[Sequence[Any] | str]) -> Optional[str]:
|
|
53
62
|
if value is None:
|
|
54
63
|
return None
|
|
64
|
+
if isinstance(value, str):
|
|
65
|
+
self._validate_dimension(json.loads(value))
|
|
66
|
+
return value
|
|
55
67
|
|
|
56
68
|
def convert(val):
|
|
57
69
|
if isinstance(val, (list, tuple)):
|
|
@@ -61,12 +73,17 @@ class ARRAY(UserDefinedType):
|
|
|
61
73
|
return val
|
|
62
74
|
|
|
63
75
|
processed = convert(value)
|
|
76
|
+
self._validate_dimension(processed)
|
|
64
77
|
return json.dumps(processed)
|
|
65
78
|
|
|
66
79
|
return process
|
|
67
80
|
|
|
68
81
|
def result_processor(self, dialect, coltype):
|
|
69
|
-
|
|
82
|
+
item_type = self.item_type
|
|
83
|
+
while isinstance(item_type, ARRAY):
|
|
84
|
+
item_type = item_type.item_type
|
|
85
|
+
|
|
86
|
+
item_proc = item_type.dialect_impl(dialect).result_processor(dialect, coltype)
|
|
70
87
|
|
|
71
88
|
def process(value: Optional[str]) -> Optional[List[Any]]:
|
|
72
89
|
if value is None:
|
|
@@ -85,7 +102,11 @@ class ARRAY(UserDefinedType):
|
|
|
85
102
|
return process
|
|
86
103
|
|
|
87
104
|
def literal_processor(self, dialect):
|
|
88
|
-
|
|
105
|
+
item_type = self.item_type
|
|
106
|
+
while isinstance(item_type, ARRAY):
|
|
107
|
+
item_type = item_type.item_type
|
|
108
|
+
|
|
109
|
+
item_proc = item_type.dialect_impl(dialect).literal_processor(dialect)
|
|
89
110
|
|
|
90
111
|
def process(value: Sequence[Any]) -> str:
|
|
91
112
|
def convert(val):
|
|
@@ -100,21 +121,6 @@ class ARRAY(UserDefinedType):
|
|
|
100
121
|
|
|
101
122
|
return process
|
|
102
123
|
|
|
103
|
-
def __repr__(self):
|
|
104
|
-
"""Return a string representation of the array type."""
|
|
105
|
-
current_type = self.item_type
|
|
106
|
-
nesting_level = 1
|
|
107
|
-
base_type = current_type
|
|
108
|
-
|
|
109
|
-
# Find the innermost type and count nesting level
|
|
110
|
-
while isinstance(current_type, ARRAY):
|
|
111
|
-
nesting_level += 1
|
|
112
|
-
current_type = current_type.item_type
|
|
113
|
-
if not isinstance(current_type, ARRAY):
|
|
114
|
-
base_type = current_type
|
|
115
|
-
|
|
116
|
-
return f"{nesting_level}D_Array({base_type})"
|
|
117
|
-
|
|
118
124
|
|
|
119
125
|
def nested_array(dim: int) -> Type[ARRAY]:
|
|
120
126
|
"""Create a nested array type class with specified dimensions.
|
|
@@ -131,12 +137,22 @@ def nested_array(dim: int) -> Type[ARRAY]:
|
|
|
131
137
|
if not 1 <= dim <= 6:
|
|
132
138
|
raise ValueError("Dimension must be between 1 and 6")
|
|
133
139
|
|
|
134
|
-
class
|
|
140
|
+
class NestedArray(ARRAY):
|
|
141
|
+
cache_ok = True
|
|
142
|
+
_string = String()
|
|
143
|
+
|
|
135
144
|
def __init__(self, item_type: Union[TypeEngine, type]):
|
|
145
|
+
super(UserDefinedType, self).__init__()
|
|
146
|
+
if isinstance(item_type, type):
|
|
147
|
+
item_type = item_type()
|
|
148
|
+
|
|
149
|
+
assert not isinstance(item_type, ARRAY), "The item_type of NestedArray should not be an ARRAY type"
|
|
150
|
+
|
|
136
151
|
nested_type = item_type
|
|
137
|
-
for _ in range(dim
|
|
152
|
+
for _ in range(dim):
|
|
138
153
|
nested_type = ARRAY(nested_type)
|
|
139
|
-
super().__init__(nested_type)
|
|
140
154
|
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
self.item_type = nested_type.item_type
|
|
156
|
+
self.dim = dim
|
|
157
|
+
|
|
158
|
+
return NestedArray
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "pyobvector"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.13"
|
|
4
4
|
description = "A python SDK for OceanBase Vector Store, based on SQLAlchemy, compatible with Milvus API."
|
|
5
5
|
authors = ["shanhaikang.shk <shanhaikang.shk@oceanbase.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|