pyvastbase 0.2.2__py3-none-any.whl

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.
Files changed (54) hide show
  1. pyvastbase/__init__.py +364 -0
  2. pyvastbase/async_impl/__init__.py +159 -0
  3. pyvastbase/async_impl/collection.py +1367 -0
  4. pyvastbase/async_impl/connections.py +561 -0
  5. pyvastbase/async_impl/index_builder.py +299 -0
  6. pyvastbase/async_impl/search_builder.py +338 -0
  7. pyvastbase/async_impl/utility.py +814 -0
  8. pyvastbase/client.py +611 -0
  9. pyvastbase/collection.py +1053 -0
  10. pyvastbase/core/__init__.py +1 -0
  11. pyvastbase/core/collection_core.py +902 -0
  12. pyvastbase/core/connections.py +443 -0
  13. pyvastbase/core/constants.py +202 -0
  14. pyvastbase/core/exceptions.py +166 -0
  15. pyvastbase/core/executor.py +115 -0
  16. pyvastbase/core/mutation_result.py +143 -0
  17. pyvastbase/core/schema.py +610 -0
  18. pyvastbase/core/search_result.py +138 -0
  19. pyvastbase/core/vector_types.py +224 -0
  20. pyvastbase/executor/__init__.py +1 -0
  21. pyvastbase/executor/async_impl.py +144 -0
  22. pyvastbase/executor/sync.py +119 -0
  23. pyvastbase/index/__init__.py +1 -0
  24. pyvastbase/index/index_builder.py +485 -0
  25. pyvastbase/operations/__init__.py +130 -0
  26. pyvastbase/operations/admin.py +256 -0
  27. pyvastbase/operations/ddl.py +75 -0
  28. pyvastbase/operations/delete.py +44 -0
  29. pyvastbase/operations/index.py +170 -0
  30. pyvastbase/operations/insert.py +131 -0
  31. pyvastbase/operations/query.py +94 -0
  32. pyvastbase/operations/result.py +35 -0
  33. pyvastbase/operations/schema_reflect.py +106 -0
  34. pyvastbase/operations/search.py +40 -0
  35. pyvastbase/operations/search_result.py +54 -0
  36. pyvastbase/operations/upsert.py +34 -0
  37. pyvastbase/orm/__init__.py +66 -0
  38. pyvastbase/orm/base.py +711 -0
  39. pyvastbase/orm/fields.py +280 -0
  40. pyvastbase/search/__init__.py +1 -0
  41. pyvastbase/search/search_builder.py +691 -0
  42. pyvastbase/test_conn.py +17 -0
  43. pyvastbase/utility.py +2677 -0
  44. pyvastbase/utils/__init__.py +163 -0
  45. pyvastbase/utils/distance_utils.py +531 -0
  46. pyvastbase/utils/filter_utils.py +333 -0
  47. pyvastbase/utils/index_utils.py +387 -0
  48. pyvastbase/utils/result_utils.py +435 -0
  49. pyvastbase/utils/sql_utils.py +230 -0
  50. pyvastbase/utils/vector_utils.py +708 -0
  51. pyvastbase-0.2.2.dist-info/METADATA +584 -0
  52. pyvastbase-0.2.2.dist-info/RECORD +54 -0
  53. pyvastbase-0.2.2.dist-info/WHEEL +5 -0
  54. pyvastbase-0.2.2.dist-info/top_level.txt +1 -0
pyvastbase/__init__.py ADDED
@@ -0,0 +1,364 @@
1
+ """
2
+ pyvastbase - Python SDK for Vastbase Vector Database
3
+
4
+ A PyMilvus-style Python SDK for Vastbase vector database with
5
+ support for vector storage, similarity search, and hybrid queries.
6
+
7
+ Example:
8
+ >>> from pyvastbase import connect, Collection
9
+ >>>
10
+ >>> # Connect to database
11
+ >>> connect(host="localhost", database="mydb")
12
+ >>>
13
+ >>> # Create collection with schema
14
+ >>> from pyvastbase import FieldSchema, CollectionSchema, DataType
15
+ >>>
16
+ >>> fields = [
17
+ ... FieldSchema(name="id", dtype=DataType.INT64, is_primary_key=True),
18
+ ... FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=128),
19
+ ... FieldSchema(name="text", dtype=DataType.VARCHAR, max_length=65535)
20
+ ... ]
21
+ >>> schema = CollectionSchema(name="my_vectors", fields=fields)
22
+ >>>
23
+ >>> # Create and use collection
24
+ >>> collection = Collection("my_vectors", schema=schema)
25
+ >>> collection.create()
26
+ >>>
27
+ >>> # Insert data
28
+ >>> collection.insert([
29
+ ... {"id": 1, "embedding": [0.1] * 128, "text": "hello world"},
30
+ ... {"id": 2, "embedding": [0.2] * 128, "text": "goodbye world"}
31
+ ... ])
32
+ >>>
33
+ >>> # Search
34
+ >>> results = collection.search(
35
+ ... data=[[0.15] * 128],
36
+ ... anns_field="embedding",
37
+ ... top_k=10
38
+ ... )
39
+ """
40
+
41
+ __version__ = "0.2.2"
42
+ __author__ = "pyvastbase contributors"
43
+
44
+ # Core imports
45
+ from .core.constants import (
46
+ IndexType,
47
+ DistanceType,
48
+ MetricType,
49
+ QuantizerType,
50
+ DEFAULT_INDEX_PARAMS,
51
+ DEFAULT_QUERY_PARAMS,
52
+ VectorConstraints,
53
+ VB_VERSION_3_0_9,
54
+ VB_VERSION_SPARSEVECTOR,
55
+ VB_VERSION_NEW_VECTOR_TYPES,
56
+ VB_VERSION_BM25_HIGHLIGHT,
57
+ VB_VERSION_AUTO_QUANTIZATION,
58
+ )
59
+
60
+ from .core.exceptions import (
61
+ VastbaseException,
62
+ ConnectionError as VastbaseConnectionError,
63
+ ParamError,
64
+ SchemaError,
65
+ IndexError,
66
+ CollectionError,
67
+ DataError,
68
+ SearchError,
69
+ ExpressionError,
70
+ VectorDimensionError,
71
+ IndexNotSupportedError,
72
+ NotSupportedError,
73
+ CollectionNotExistsError,
74
+ MilvusException,
75
+ MilvusUnavailableException,
76
+ )
77
+
78
+ from .client import VastbaseClient, MilvusClient
79
+
80
+ from .core.connections import (
81
+ ConnectionConfig,
82
+ Connections,
83
+ VastbaseConnection,
84
+ )
85
+
86
+ from .core.schema import (
87
+ DataType,
88
+ FieldSchema,
89
+ CollectionSchema,
90
+ create_collection_schema,
91
+ )
92
+
93
+ # Index imports
94
+ from .index.index_builder import (
95
+ IndexParams,
96
+ IndexBuilder,
97
+ create_vector_index,
98
+ create_fulltext_index,
99
+ )
100
+
101
+ # Search imports
102
+ from .search.search_builder import (
103
+ SearchParams,
104
+ SearchResultItem,
105
+ SearchResult,
106
+ SearchQueryBuilder,
107
+ FulltextSearchBuilder,
108
+ SearchType,
109
+ AnnSearchRequest,
110
+ BaseRanker,
111
+ RRFRanker,
112
+ WeightedRRFRanker,
113
+ WeightedRanker,
114
+ )
115
+
116
+ from .core.mutation_result import (
117
+ MutationResult,
118
+ )
119
+
120
+ # Collection import
121
+ from .collection import Collection, SearchIterator, QueryIterator
122
+
123
+ # Async imports (renamed from async to async_impl to avoid Python keyword)
124
+ from .async_impl import (
125
+ AsyncConnections,
126
+ AsyncVastbaseConnection,
127
+ AsyncCollection,
128
+ QueryIterator,
129
+ add_connection,
130
+ connect,
131
+ get_connection,
132
+ remove_connection,
133
+ close_all,
134
+ # Alias management
135
+ create_alias,
136
+ drop_alias,
137
+ alter_alias,
138
+ # Load state
139
+ get_load_state,
140
+ )
141
+
142
+ # Utility imports
143
+ from .utility import (
144
+ connect,
145
+ add_connection,
146
+ get_connection,
147
+ remove_connection,
148
+ close_all,
149
+ list_connections,
150
+ get_server_version,
151
+ get_server_status,
152
+ list_collections,
153
+ has_collection,
154
+ describe_collection,
155
+ create_collection,
156
+ drop_collection,
157
+ rename_collection,
158
+ health_check,
159
+ normalize_vector,
160
+ batch_iterator,
161
+ # Alias management (sync versions override async from async_impl)
162
+ create_alias,
163
+ drop_alias,
164
+ alter_alias,
165
+ # Load state (sync version overrides async)
166
+ get_load_state,
167
+ # User management
168
+ create_user,
169
+ drop_user,
170
+ reset_password,
171
+ list_users,
172
+ # Privilege management
173
+ grant,
174
+ revoke,
175
+ # Database management
176
+ create_database,
177
+ drop_database,
178
+ list_databases,
179
+ describe_database,
180
+ # User management (extended)
181
+ describe_user,
182
+ update_password,
183
+ # Index management
184
+ describe_index,
185
+ alter_index_properties,
186
+ drop_index_properties,
187
+ # Alias management (extended)
188
+ list_aliases,
189
+ describe_alias,
190
+ # Collection property management
191
+ alter_collection_properties,
192
+ drop_collection_properties,
193
+ add_collection_field,
194
+ # Flush
195
+ flush_all,
196
+ get_flush_all_state,
197
+ # Vastbase 3.0.9+ version detection
198
+ get_vb_version,
199
+ check_vb_version,
200
+ # Vastbase 3.0.9+ search highlight
201
+ bm25_search_highlight,
202
+ # Vastbase 3.0.9+ buffer inspection
203
+ vectorbuffer_inspect,
204
+ bulkbuffer_inspect,
205
+ )
206
+
207
+ # Public API
208
+ __all__ = sorted([
209
+ "__version__",
210
+ "AnnSearchRequest",
211
+ "AsyncCollection",
212
+ "AsyncConnections",
213
+ "AsyncVastbaseConnection",
214
+ "BaseRanker",
215
+ "BatchIterator",
216
+ "Collection",
217
+ "CollectionError",
218
+ "CollectionNotExistsError",
219
+ "CollectionSchema",
220
+ "ConnectionConfig",
221
+ "Connections",
222
+ "DataError",
223
+ "DataType",
224
+ "DEFAULT_INDEX_PARAMS",
225
+ "DEFAULT_QUERY_PARAMS",
226
+ "DistanceType",
227
+ "ExpressionError",
228
+ "FieldSchema",
229
+ "FulltextSearchBuilder",
230
+ "IndexBuilder",
231
+ "IndexError",
232
+ "IndexNotSupportedError",
233
+ "IndexParams",
234
+ "IndexType",
235
+ "MetricType",
236
+ "MilvusClient",
237
+ "MilvusException",
238
+ "MilvusUnavailableException",
239
+ "MutationResult",
240
+ "MutationResultWrapper",
241
+ "NotSupportedError",
242
+ "ParamError",
243
+ "QuantizerType",
244
+ "QueryIterator",
245
+ "RRFRanker",
246
+ "SchemaError",
247
+ "SearchBuilder",
248
+ "SearchError",
249
+ "SearchParams",
250
+ "SearchQueryBuilder",
251
+ "SearchResult",
252
+ "SearchResultItem",
253
+ "SearchResults",
254
+ "SearchType",
255
+ "SearchIterator",
256
+ "VastbaseClient",
257
+ "VastbaseConnection",
258
+ "VastbaseConnectionError",
259
+ "VastbaseException",
260
+ "VectorConstraints",
261
+ "VectorDimensionError",
262
+ "VB_VERSION_3_0_9",
263
+ "VB_VERSION_AUTO_QUANTIZATION",
264
+ "VB_VERSION_BM25_HIGHLIGHT",
265
+ "VB_VERSION_NEW_VECTOR_TYPES",
266
+ "VB_VERSION_SPARSEVECTOR",
267
+ "WeightedRanker",
268
+ "WeightedRRFRanker",
269
+ "add_connection",
270
+ "alter_alias",
271
+ "batch_iterator",
272
+ "bm25_search_highlight",
273
+ "bulkbuffer_inspect",
274
+ "check_vb_version",
275
+ "close_all",
276
+ "configure",
277
+ "connect",
278
+ "create_alias",
279
+ "create_collection",
280
+ "create_collection_schema",
281
+ "create_database",
282
+ "create_fulltext_index",
283
+ "create_user",
284
+ "create_vector_index",
285
+ "describe_collection",
286
+ "drop_alias",
287
+ "drop_collection",
288
+ "drop_database",
289
+ "drop_user",
290
+ "get_config",
291
+ "get_connection",
292
+ "get_load_state",
293
+ "get_server_status",
294
+ "get_server_version",
295
+ "get_vb_version",
296
+ "grant",
297
+ "has_collection",
298
+ "health_check",
299
+ "list_collections",
300
+ "list_connections",
301
+ "list_databases",
302
+ "list_users",
303
+ "normalize_vector",
304
+ "remove_connection",
305
+ "rename_collection",
306
+ "reset_password",
307
+ "revoke",
308
+ "add_collection_field",
309
+ "alter_collection_properties",
310
+ "alter_index_properties",
311
+ "describe_alias",
312
+ "describe_database",
313
+ "describe_index",
314
+ "describe_user",
315
+ "drop_collection_properties",
316
+ "drop_index_properties",
317
+ "flush_all",
318
+ "get_flush_all_state",
319
+ "list_aliases",
320
+ "update_password",
321
+ "vectorbuffer_inspect",
322
+ ])
323
+
324
+
325
+ def __getattr__(name):
326
+ """Lazy deprecated aliases — warn on access."""
327
+ if name == "MutationResultWrapper":
328
+ import warnings
329
+ warnings.warn(
330
+ "MutationResultWrapper is deprecated, use MutationResult instead",
331
+ DeprecationWarning,
332
+ stacklevel=2,
333
+ )
334
+ from .core.mutation_result import MutationResult
335
+ return MutationResult
336
+ if name == "SearchResults":
337
+ import warnings
338
+ warnings.warn(
339
+ "SearchResults is deprecated, use SearchResult instead",
340
+ DeprecationWarning,
341
+ stacklevel=2,
342
+ )
343
+ from .core.search_result import SearchResult
344
+ return SearchResult
345
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
346
+
347
+
348
+ # Module-level configuration
349
+ _config = {
350
+ "default_connection": "default",
351
+ "timeout": 30.0,
352
+ "pool_size": 10,
353
+ "max_overflow": 10,
354
+ }
355
+
356
+
357
+ def configure(**kwargs) -> None:
358
+ """Configure pyvastbase settings"""
359
+ _config.update(kwargs)
360
+
361
+
362
+ def get_config() -> dict:
363
+ """Get current configuration"""
364
+ return _config.copy()
@@ -0,0 +1,159 @@
1
+ """
2
+ Vastbase Vector Database SDK - Async Module
3
+
4
+ Async implementations for async/await patterns.
5
+ Fully compatible with the sync API - same method names, parameters, and return types.
6
+
7
+ Example:
8
+ # Sync version
9
+ from pyvastbase import Collection, connect
10
+ connect(host="localhost", database="mydb")
11
+ collection = Collection("my_vectors")
12
+ collection.insert([{"id": 1, "vector": [0.1] * 128}])
13
+
14
+ # Async version - same API, async/await
15
+ from pyvastbase.async_impl import AsyncCollection, connect
16
+ await connect(host="localhost", database="mydb")
17
+ collection = AsyncCollection("my_vectors")
18
+ await collection.insert([{"id": 1, "vector": [0.1] * 128}])
19
+ """
20
+
21
+ # Async connections
22
+ from .connections import (
23
+ AsyncConnections,
24
+ AsyncVastbaseConnection,
25
+ ConnectionConfig,
26
+ add_connection,
27
+ connect,
28
+ get_connection,
29
+ remove_connection,
30
+ close_all,
31
+ )
32
+
33
+ # Async collection (main class)
34
+ from .collection import AsyncCollection, QueryIterator
35
+
36
+
37
+ # Async index builder
38
+ from .index_builder import AsyncIndexBuilder
39
+
40
+ # Async index CRUD functions
41
+ from .index_builder import (
42
+ async_drop_index,
43
+ async_list_indexes,
44
+ async_describe_index,
45
+ async_index_exists,
46
+ )
47
+
48
+ # Async search builder
49
+ from .search_builder import (
50
+ AsyncSearchBuilder,
51
+ AsyncSearchResultItem,
52
+ AsyncSearchResult,
53
+ AsyncSearchQueryBuilder,
54
+ AsyncFulltextSearchBuilder,
55
+ )
56
+
57
+ # Utility functions
58
+ from .search_builder import (
59
+ async_search_vector,
60
+ async_search_fulltext,
61
+ )
62
+
63
+ # Alias and load state utilities
64
+ from .utility import (
65
+ create_alias,
66
+ drop_alias,
67
+ alter_alias,
68
+ get_load_state,
69
+ wait_for_loading_complete,
70
+ get_loading_progress,
71
+ calc_distance,
72
+ async_calc_distance,
73
+ search_iterator,
74
+ async_search_iterator,
75
+ AsyncSearchIterator,
76
+ # User management
77
+ create_user,
78
+ drop_user,
79
+ reset_password,
80
+ list_users,
81
+ # Privilege management
82
+ grant,
83
+ revoke,
84
+ # Database management
85
+ create_database,
86
+ drop_database,
87
+ list_databases,
88
+ # Flush & Collection Load/Release
89
+ flush,
90
+ get_flush_state,
91
+ flush_sync,
92
+ load_collection,
93
+ release_collection,
94
+ )
95
+
96
+ # For convenience, also export from connections module
97
+ __all__ = [
98
+ # Connections
99
+ "AsyncConnections",
100
+ "AsyncVastbaseConnection",
101
+ "ConnectionConfig",
102
+ "add_connection",
103
+ "connect",
104
+ "get_connection",
105
+ "remove_connection",
106
+ "close_all",
107
+ # Collection
108
+ "AsyncCollection",
109
+ "QueryIterator",
110
+ # Index Builder
111
+ "AsyncIndexBuilder",
112
+ "async_drop_index",
113
+ "async_list_indexes",
114
+ "async_describe_index",
115
+ "async_index_exists",
116
+ # Search Builder
117
+ "AsyncSearchBuilder",
118
+ "AsyncSearchResultItem",
119
+ "AsyncSearchResult",
120
+ "AsyncSearchResult",
121
+ "AsyncSearchQueryBuilder",
122
+ "AsyncFulltextSearchBuilder",
123
+ # Utility functions
124
+ "async_search_vector",
125
+ "async_search_fulltext",
126
+ # Alias management
127
+ "create_alias",
128
+ "drop_alias",
129
+ "alter_alias",
130
+ "get_load_state",
131
+ # Loading progress
132
+ "wait_for_loading_complete",
133
+ "get_loading_progress",
134
+ # Distance calculation
135
+ "calc_distance",
136
+ "async_calc_distance",
137
+ # Search iterator
138
+ "search_iterator",
139
+ "async_search_iterator",
140
+ "AsyncSearchIterator",
141
+ # User management
142
+ "create_user",
143
+ "drop_user",
144
+ "reset_password",
145
+ "list_users",
146
+ # Privilege management
147
+ "grant",
148
+ "revoke",
149
+ # Database management
150
+ "create_database",
151
+ "drop_database",
152
+ "list_databases",
153
+ # Flush & Collection Load/Release
154
+ "flush",
155
+ "get_flush_state",
156
+ "flush_sync",
157
+ "load_collection",
158
+ "release_collection",
159
+ ]