infinity-sdk 0.7.0.dev2__tar.gz → 0.7.0.dev4__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.
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity_sdk.egg-info → infinity_sdk-0.7.0.dev4}/PKG-INFO +2 -2
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/README.md +1 -1
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/pyproject.toml +1 -1
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/README.md +1 -1
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/connection_pool.py +10 -2
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/http_utils.py +1 -1
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/index.py +3 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/client.py +7 -4
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/infinity.py +5 -2
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/ttypes.py +3 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4/python/infinity_sdk/infinity_sdk.egg-info}/PKG-INFO +2 -2
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity_sdk.egg-info/SOURCES.txt +0 -22
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity_sdk.egg-info/top_level.txt +0 -1
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/__init__.py +0 -34
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/common.py +0 -124
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/connection_pool.py +0 -59
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/index.py +0 -103
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/infinity.py +0 -79
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/rag_tokenizer.py +0 -575
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/client.py +0 -491
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/db.py +0 -133
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/infinity.py +0 -238
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/infinity_thrift_rpc/ttypes.py +0 -11402
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/query_builder.py +0 -686
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/table.py +0 -573
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/types.py +0 -629
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/remote_thrift/utils.py +0 -904
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/table.py +0 -50
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib/infinity/utils.py +0 -52
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/db.py +0 -48
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/errors.py +0 -183
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/remote_thrift/__init__.py +0 -0
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/InfinityService.py +0 -9517
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/__init__.py +0 -1
- infinity_sdk-0.7.0.dev2/python/infinity_sdk/infinity/remote_thrift/infinity_thrift_rpc/constants.py +0 -15
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/LICENSE +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/__init__.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/common.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/db.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/errors.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/huqie.txt +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/huqie.txt.trie +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/infinity.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/infinity_http.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/rag_tokenizer.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/remote_thrift/__init__.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/db.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/remote_thrift/infinity_thrift_rpc/InfinityService.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/remote_thrift/infinity_thrift_rpc/__init__.py +0 -0
- {infinity_sdk-0.7.0.dev2/python/infinity_sdk/build/lib → infinity_sdk-0.7.0.dev4/python/infinity_sdk}/infinity/remote_thrift/infinity_thrift_rpc/constants.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/query_builder.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/table.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/types.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/remote_thrift/utils.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/table.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/utils.py +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity_sdk.egg-info/dependency_links.txt +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity_sdk.egg-info/requires.txt +0 -0
- {infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: infinity-sdk
|
|
3
|
-
Version: 0.7.0.
|
|
3
|
+
Version: 0.7.0.dev4
|
|
4
4
|
Summary: infinity
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
@@ -97,7 +97,7 @@ Infinity supports two working modes, embedded mode and client-server mode. The f
|
|
|
97
97
|
|
|
98
98
|
2. Install the `infinity-sdk` package:
|
|
99
99
|
```bash
|
|
100
|
-
pip install infinity-sdk==0.7.0.
|
|
100
|
+
pip install infinity-sdk==0.7.0.dev4
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
3. Use Infinity to conduct a dense vector search:
|
|
@@ -63,7 +63,7 @@ Infinity supports two working modes, embedded mode and client-server mode. The f
|
|
|
63
63
|
|
|
64
64
|
2. Install the `infinity-sdk` package:
|
|
65
65
|
```bash
|
|
66
|
-
pip install infinity-sdk==0.7.0.
|
|
66
|
+
pip install infinity-sdk==0.7.0.dev4
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
3. Use Infinity to conduct a dense vector search:
|
{infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/connection_pool.py
RENAMED
|
@@ -28,7 +28,10 @@ class ConnectionPool(object):
|
|
|
28
28
|
self._create_conn()
|
|
29
29
|
|
|
30
30
|
def __del__(self):
|
|
31
|
-
|
|
31
|
+
try:
|
|
32
|
+
self.destroy()
|
|
33
|
+
except Exception:
|
|
34
|
+
pass # Ignore errors in destructor
|
|
32
35
|
|
|
33
36
|
def _create_conn(self):
|
|
34
37
|
infinity_coon = infinity.connect(self.uri_)
|
|
@@ -54,6 +57,11 @@ class ConnectionPool(object):
|
|
|
54
57
|
logging.debug("release_conn")
|
|
55
58
|
|
|
56
59
|
def destroy(self):
|
|
60
|
+
if not hasattr(self, 'free_pool_'):
|
|
61
|
+
return
|
|
57
62
|
for conn in iter(self.free_pool_):
|
|
58
|
-
|
|
63
|
+
try:
|
|
64
|
+
conn.disconnect()
|
|
65
|
+
except Exception:
|
|
66
|
+
pass # Ignore errors when disconnecting
|
|
59
67
|
self.free_pool_.clear()
|
{infinity_sdk-0.7.0.dev2 → infinity_sdk-0.7.0.dev4}/python/infinity_sdk/infinity/http_utils.py
RENAMED
|
@@ -101,7 +101,7 @@ def function_return_type(function_name, param_type):
|
|
|
101
101
|
elif function_name in ["json_extract", "json_extract_string"]:
|
|
102
102
|
return 'string'
|
|
103
103
|
elif function_name == "json_extract_int":
|
|
104
|
-
return '
|
|
104
|
+
return 'Int64'
|
|
105
105
|
elif function_name == "json_extract_double":
|
|
106
106
|
return 'Float64'
|
|
107
107
|
elif function_name in ["json_extract_bool", "json_extract_isnull",
|
|
@@ -30,6 +30,7 @@ class IndexType(Enum):
|
|
|
30
30
|
EMVB = 6
|
|
31
31
|
BMP = 7
|
|
32
32
|
DiskAnn = 8
|
|
33
|
+
PLAID = 9
|
|
33
34
|
|
|
34
35
|
def to_ttype(self):
|
|
35
36
|
match self:
|
|
@@ -49,6 +50,8 @@ class IndexType(Enum):
|
|
|
49
50
|
return ttypes.IndexType.BMP
|
|
50
51
|
case IndexType.DiskAnn:
|
|
51
52
|
return ttypes.IndexType.DiskAnn
|
|
53
|
+
case IndexType.PLAID:
|
|
54
|
+
return ttypes.IndexType.PLAID
|
|
52
55
|
case _:
|
|
53
56
|
raise InfinityException(ErrorCode.INVALID_INDEX_TYPE, "Unknown index type")
|
|
54
57
|
|
|
@@ -70,8 +70,11 @@ class ThriftInfinityClient:
|
|
|
70
70
|
self.logger.addHandler(ch)
|
|
71
71
|
|
|
72
72
|
def __del__(self):
|
|
73
|
-
|
|
74
|
-
self.
|
|
73
|
+
try:
|
|
74
|
+
if hasattr(self, '_is_connected') and self._is_connected:
|
|
75
|
+
self.disconnect()
|
|
76
|
+
except Exception:
|
|
77
|
+
pass # Ignore errors in destructor
|
|
75
78
|
|
|
76
79
|
def _reconnect(self):
|
|
77
80
|
if self.transport is not None:
|
|
@@ -120,8 +123,8 @@ class ThriftInfinityClient:
|
|
|
120
123
|
# version: 0.6.8 and 0.6.9 and 0.6.10, client_version: 33
|
|
121
124
|
# version: 0.6.13, client_version: 34
|
|
122
125
|
# version: 0.6.15, client_version: 35
|
|
123
|
-
# version: 0.7.0, 0.7.0.dev1, 0.7.0.dev2, client_version: 36
|
|
124
|
-
res = self.client.Connect(ConnectRequest(client_version=36)) # 0.7.0.
|
|
126
|
+
# version: 0.7.0, 0.7.0.dev1, 0.7.0.dev2, 0.7.0.dev3 and 0.7.0.dev4, client_version: 36
|
|
127
|
+
res = self.client.Connect(ConnectRequest(client_version=36)) # 0.7.0.dev4
|
|
125
128
|
if res.error_code != 0:
|
|
126
129
|
raise InfinityException(res.error_code, res.error_msg)
|
|
127
130
|
self.session_id = res.session_id
|
|
@@ -42,8 +42,11 @@ class RemoteThriftInfinityConnection(InfinityConnection, ABC):
|
|
|
42
42
|
self._is_connected = True
|
|
43
43
|
|
|
44
44
|
def __del__(self):
|
|
45
|
-
|
|
46
|
-
self.
|
|
45
|
+
try:
|
|
46
|
+
if hasattr(self, '_is_connected') and self._is_connected:
|
|
47
|
+
self.disconnect()
|
|
48
|
+
except Exception:
|
|
49
|
+
pass # Ignore errors in destructor
|
|
47
50
|
|
|
48
51
|
@name_validity_check("db_name", "DB")
|
|
49
52
|
def create_database(self, db_name: str, conflict_type: ConflictType = ConflictType.Error, comment: str = None):
|
|
@@ -398,6 +398,7 @@ class IndexType(object):
|
|
|
398
398
|
SecondaryFunctional = 5
|
|
399
399
|
EMVB = 6
|
|
400
400
|
DiskAnn = 7
|
|
401
|
+
PLAID = 8
|
|
401
402
|
|
|
402
403
|
_VALUES_TO_NAMES = {
|
|
403
404
|
0: "IVF",
|
|
@@ -408,6 +409,7 @@ class IndexType(object):
|
|
|
408
409
|
5: "SecondaryFunctional",
|
|
409
410
|
6: "EMVB",
|
|
410
411
|
7: "DiskAnn",
|
|
412
|
+
8: "PLAID",
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
_NAMES_TO_VALUES = {
|
|
@@ -419,6 +421,7 @@ class IndexType(object):
|
|
|
419
421
|
"SecondaryFunctional": 5,
|
|
420
422
|
"EMVB": 6,
|
|
421
423
|
"DiskAnn": 7,
|
|
424
|
+
"PLAID": 8,
|
|
422
425
|
}
|
|
423
426
|
|
|
424
427
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: infinity-sdk
|
|
3
|
-
Version: 0.7.0.
|
|
3
|
+
Version: 0.7.0.dev4
|
|
4
4
|
Summary: infinity
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
@@ -97,7 +97,7 @@ Infinity supports two working modes, embedded mode and client-server mode. The f
|
|
|
97
97
|
|
|
98
98
|
2. Install the `infinity-sdk` package:
|
|
99
99
|
```bash
|
|
100
|
-
pip install infinity-sdk==0.7.0.
|
|
100
|
+
pip install infinity-sdk==0.7.0.dev4
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
3. Use Infinity to conduct a dense vector search:
|
|
@@ -2,28 +2,6 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
python/infinity_sdk/README.md
|
|
5
|
-
python/infinity_sdk/build/lib/infinity/__init__.py
|
|
6
|
-
python/infinity_sdk/build/lib/infinity/common.py
|
|
7
|
-
python/infinity_sdk/build/lib/infinity/connection_pool.py
|
|
8
|
-
python/infinity_sdk/build/lib/infinity/db.py
|
|
9
|
-
python/infinity_sdk/build/lib/infinity/errors.py
|
|
10
|
-
python/infinity_sdk/build/lib/infinity/index.py
|
|
11
|
-
python/infinity_sdk/build/lib/infinity/infinity.py
|
|
12
|
-
python/infinity_sdk/build/lib/infinity/rag_tokenizer.py
|
|
13
|
-
python/infinity_sdk/build/lib/infinity/table.py
|
|
14
|
-
python/infinity_sdk/build/lib/infinity/utils.py
|
|
15
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/__init__.py
|
|
16
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/client.py
|
|
17
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/db.py
|
|
18
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/infinity.py
|
|
19
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/query_builder.py
|
|
20
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/table.py
|
|
21
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/types.py
|
|
22
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/utils.py
|
|
23
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/infinity_thrift_rpc/InfinityService.py
|
|
24
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/infinity_thrift_rpc/__init__.py
|
|
25
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/infinity_thrift_rpc/constants.py
|
|
26
|
-
python/infinity_sdk/build/lib/infinity/remote_thrift/infinity_thrift_rpc/ttypes.py
|
|
27
5
|
python/infinity_sdk/infinity/__init__.py
|
|
28
6
|
python/infinity_sdk/infinity/common.py
|
|
29
7
|
python/infinity_sdk/infinity/connection_pool.py
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
# import importlib.metadata
|
|
16
|
-
#
|
|
17
|
-
# __version__ = importlib.metadata.version("infinity_sdk")
|
|
18
|
-
|
|
19
|
-
import logging
|
|
20
|
-
import os
|
|
21
|
-
# import pkg_resources
|
|
22
|
-
# __version__ = pkg_resources.get_distribution("infinity_sdk").version
|
|
23
|
-
|
|
24
|
-
from infinity.common import URI, NetworkAddress, LOCAL_HOST, LOCAL_INFINITY_PATH, InfinityException
|
|
25
|
-
from infinity.infinity import InfinityConnection
|
|
26
|
-
from infinity.remote_thrift.infinity import RemoteThriftInfinityConnection
|
|
27
|
-
from infinity.errors import ErrorCode
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def connect(uri=LOCAL_HOST, logger: logging.Logger = None) -> InfinityConnection:
|
|
31
|
-
if isinstance(uri, NetworkAddress):
|
|
32
|
-
return RemoteThriftInfinityConnection(uri, logger)
|
|
33
|
-
else:
|
|
34
|
-
raise InfinityException(ErrorCode.INVALID_SERVER_ADDRESS, f"Unknown uri: {uri}")
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
from typing import Union
|
|
16
|
-
from dataclasses import dataclass, field
|
|
17
|
-
import numpy as np
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class NetworkAddress:
|
|
21
|
-
def __init__(self, ip, port):
|
|
22
|
-
self.ip = ip
|
|
23
|
-
self.port = port
|
|
24
|
-
|
|
25
|
-
def __str__(self):
|
|
26
|
-
return f'IP: {self.ip}, Port: {self.port}'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@dataclass
|
|
30
|
-
class SparseVector:
|
|
31
|
-
indices: list[int]
|
|
32
|
-
values: Union[list[float], list[int], None] = None
|
|
33
|
-
|
|
34
|
-
def __post_init__(self):
|
|
35
|
-
assert (self.values is None) or (len(self.indices) == len(self.values))
|
|
36
|
-
|
|
37
|
-
def to_dict_old(self):
|
|
38
|
-
d = {"indices": self.indices}
|
|
39
|
-
if self.values is not None:
|
|
40
|
-
d["values"] = self.values
|
|
41
|
-
return d
|
|
42
|
-
|
|
43
|
-
def to_dict(self):
|
|
44
|
-
if self.values is None:
|
|
45
|
-
raise ValueError("SparseVector.values is None")
|
|
46
|
-
result = {}
|
|
47
|
-
for i, v in zip(self.indices, self.values):
|
|
48
|
-
result[str(i)] = v
|
|
49
|
-
return result
|
|
50
|
-
|
|
51
|
-
@staticmethod
|
|
52
|
-
def from_dict(d):
|
|
53
|
-
return SparseVector(d["indices"], d.get("values"))
|
|
54
|
-
|
|
55
|
-
def __str__(self):
|
|
56
|
-
return f"SparseVector(indices={self.indices}{'' if self.values is None else f', values={self.values}'})"
|
|
57
|
-
|
|
58
|
-
def __repr__(self):
|
|
59
|
-
return str(self)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
@dataclass
|
|
63
|
-
class Array:
|
|
64
|
-
elements: list = field(default_factory=list)
|
|
65
|
-
|
|
66
|
-
def append(self, element):
|
|
67
|
-
self.elements.append(element)
|
|
68
|
-
|
|
69
|
-
def __init__(self, *args):
|
|
70
|
-
self.elements = list(args)
|
|
71
|
-
|
|
72
|
-
def __str__(self):
|
|
73
|
-
return f"Array({', '.join(str(e) for e in self.elements)})"
|
|
74
|
-
|
|
75
|
-
def __repr__(self):
|
|
76
|
-
return str(self)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
@dataclass
|
|
80
|
-
class FDE:
|
|
81
|
-
"""Fixed Dimensional Encoding function call for insert operations."""
|
|
82
|
-
tensor_data: list # 2D array of numbers
|
|
83
|
-
target_dimension: int # Target embedding dimension
|
|
84
|
-
|
|
85
|
-
def __init__(self, tensor_data: list, target_dimension: int):
|
|
86
|
-
self.tensor_data = tensor_data
|
|
87
|
-
self.target_dimension = target_dimension
|
|
88
|
-
|
|
89
|
-
def __str__(self):
|
|
90
|
-
return f"FDE(tensor_data={self.tensor_data}, target_dimension={self.target_dimension})"
|
|
91
|
-
|
|
92
|
-
def __repr__(self):
|
|
93
|
-
return str(self)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
URI = Union[NetworkAddress, Path]
|
|
97
|
-
VEC = Union[list, np.ndarray, FDE]
|
|
98
|
-
INSERT_DATA = dict[str, Union[str, int, float, list[Union[int, float]]], SparseVector, dict, Array, FDE]
|
|
99
|
-
|
|
100
|
-
LOCAL_HOST = NetworkAddress("127.0.0.1", 23817)
|
|
101
|
-
|
|
102
|
-
# test embedded_infinity
|
|
103
|
-
LOCAL_INFINITY_PATH = "/var/infinity"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
class ConflictType(object):
|
|
107
|
-
Ignore = 0
|
|
108
|
-
Error = 1
|
|
109
|
-
Replace = 2
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
class SortType(object):
|
|
113
|
-
Asc = 0
|
|
114
|
-
Desc = 1
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class InfinityException(Exception):
|
|
118
|
-
def __init__(self, error_code=0, error_msg=None):
|
|
119
|
-
self.error_code = error_code
|
|
120
|
-
self.error_msg = error_msg
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
DEFAULT_MATCH_VECTOR_TOPN = 10
|
|
124
|
-
DEFAULT_MATCH_SPARSE_TOPN = 10
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from threading import Lock
|
|
16
|
-
import infinity
|
|
17
|
-
from infinity.common import NetworkAddress
|
|
18
|
-
import logging
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ConnectionPool(object):
|
|
22
|
-
def __init__(self, uri=NetworkAddress("127.0.0.1", 23817), max_size=16):
|
|
23
|
-
self.uri_ = uri
|
|
24
|
-
self.max_size_ = max_size
|
|
25
|
-
self.free_pool_ = []
|
|
26
|
-
self.lock_ = Lock()
|
|
27
|
-
for i in range(max_size):
|
|
28
|
-
self._create_conn()
|
|
29
|
-
|
|
30
|
-
def _del__(self):
|
|
31
|
-
self.destroy()
|
|
32
|
-
|
|
33
|
-
def _create_conn(self):
|
|
34
|
-
infinity_coon = infinity.connect(self.uri_)
|
|
35
|
-
self.free_pool_.append(infinity_coon)
|
|
36
|
-
|
|
37
|
-
def get_conn(self):
|
|
38
|
-
with self.lock_:
|
|
39
|
-
if (len(self.free_pool_) == 0):
|
|
40
|
-
self._create_conn()
|
|
41
|
-
conn = self.free_pool_.pop()
|
|
42
|
-
logging.debug("get_conn")
|
|
43
|
-
return conn
|
|
44
|
-
|
|
45
|
-
def release_conn(self, conn):
|
|
46
|
-
"""
|
|
47
|
-
Note: User is allowed to release a connection not created by ConnectionPool, or not releasing(due to exception or some other reasons) a connection created by ConnectionPool.
|
|
48
|
-
"""
|
|
49
|
-
with self.lock_:
|
|
50
|
-
if (self.free_pool_.count(conn)):
|
|
51
|
-
raise Exception("the connection has been released")
|
|
52
|
-
if (len(self.free_pool_) < self.max_size_):
|
|
53
|
-
self.free_pool_.append(conn)
|
|
54
|
-
logging.debug("release_conn")
|
|
55
|
-
|
|
56
|
-
def destroy(self):
|
|
57
|
-
for conn in iter(self.free_pool_):
|
|
58
|
-
conn.disconnect()
|
|
59
|
-
self.free_pool_.clear()
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from enum import Enum
|
|
16
|
-
|
|
17
|
-
import infinity.remote_thrift.infinity_thrift_rpc.ttypes as ttypes
|
|
18
|
-
from infinity.common import InfinityException
|
|
19
|
-
from infinity.errors import ErrorCode
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class IndexType(Enum):
|
|
23
|
-
IVF = 1
|
|
24
|
-
Hnsw = 2
|
|
25
|
-
FullText = 3
|
|
26
|
-
Secondary = 4
|
|
27
|
-
EMVB = 5
|
|
28
|
-
BMP = 6
|
|
29
|
-
DiskAnn = 7
|
|
30
|
-
|
|
31
|
-
def to_ttype(self):
|
|
32
|
-
match self:
|
|
33
|
-
case IndexType.IVF:
|
|
34
|
-
return ttypes.IndexType.IVF
|
|
35
|
-
case IndexType.Hnsw:
|
|
36
|
-
return ttypes.IndexType.Hnsw
|
|
37
|
-
case IndexType.FullText:
|
|
38
|
-
return ttypes.IndexType.FullText
|
|
39
|
-
case IndexType.Secondary:
|
|
40
|
-
return ttypes.IndexType.Secondary
|
|
41
|
-
case IndexType.EMVB:
|
|
42
|
-
return ttypes.IndexType.EMVB
|
|
43
|
-
case IndexType.BMP:
|
|
44
|
-
return ttypes.IndexType.BMP
|
|
45
|
-
case IndexType.DiskAnn:
|
|
46
|
-
return ttypes.IndexType.DiskAnn
|
|
47
|
-
case _:
|
|
48
|
-
raise InfinityException(ErrorCode.INVALID_INDEX_TYPE, "Unknown index type")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class InitParameter:
|
|
52
|
-
def __init__(self, param_name: str, param_value: str):
|
|
53
|
-
self.param_name = param_name
|
|
54
|
-
self.param_value = param_value
|
|
55
|
-
|
|
56
|
-
def __str__(self):
|
|
57
|
-
return f"InitParameter({self.param_name}, {self.param_value})"
|
|
58
|
-
|
|
59
|
-
def __repr__(self):
|
|
60
|
-
return self.__str__()
|
|
61
|
-
|
|
62
|
-
def to_ttype(self):
|
|
63
|
-
return ttypes.InitParameter(self.param_name, self.param_value)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class IndexInfo:
|
|
67
|
-
def __init__(self, column_name: str, index_type: IndexType, params: dict = None):
|
|
68
|
-
self.column_name = column_name
|
|
69
|
-
self.index_type = index_type
|
|
70
|
-
if params is not None:
|
|
71
|
-
if isinstance(params, dict):
|
|
72
|
-
self.params = params
|
|
73
|
-
else:
|
|
74
|
-
raise InfinityException(ErrorCode.INVALID_INDEX_PARAM, f"{params} should be dictionary type")
|
|
75
|
-
else:
|
|
76
|
-
self.params = None
|
|
77
|
-
|
|
78
|
-
def __str__(self):
|
|
79
|
-
return f"IndexInfo({self.column_name}, {self.index_type}, {self.params})"
|
|
80
|
-
|
|
81
|
-
def __repr__(self):
|
|
82
|
-
return self.__str__()
|
|
83
|
-
|
|
84
|
-
def __eq__(self, other):
|
|
85
|
-
return self.column_name == other.index_name and self.index_type == other.index_type and self.params == other.params
|
|
86
|
-
|
|
87
|
-
def __hash__(self):
|
|
88
|
-
return hash((self.column_name, self.index_type, self.params))
|
|
89
|
-
|
|
90
|
-
def to_ttype(self):
|
|
91
|
-
init_params_list = []
|
|
92
|
-
if self.params is not None:
|
|
93
|
-
for key, value in self.params.items():
|
|
94
|
-
if isinstance(value, str):
|
|
95
|
-
init_params_list.append(ttypes.InitParameter(key, value))
|
|
96
|
-
else:
|
|
97
|
-
raise InfinityException(ErrorCode.INVALID_INDEX_PARAM, f"{value} should be string type")
|
|
98
|
-
|
|
99
|
-
return ttypes.IndexInfo(
|
|
100
|
-
self.column_name.strip(),
|
|
101
|
-
self.index_type.to_ttype(),
|
|
102
|
-
init_params_list
|
|
103
|
-
)
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
from abc import ABC, abstractmethod
|
|
15
|
-
from enum import Enum
|
|
16
|
-
|
|
17
|
-
from infinity import URI
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# abstract class
|
|
21
|
-
class InfinityConnection(ABC):
|
|
22
|
-
def __init__(self, uri):
|
|
23
|
-
self.uri = uri
|
|
24
|
-
|
|
25
|
-
@abstractmethod
|
|
26
|
-
def create_database(self, db_name, options=None, comment: str = None):
|
|
27
|
-
pass
|
|
28
|
-
|
|
29
|
-
@abstractmethod
|
|
30
|
-
def list_databases(self):
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
@abstractmethod
|
|
34
|
-
def show_database(self, db_name):
|
|
35
|
-
pass
|
|
36
|
-
|
|
37
|
-
@abstractmethod
|
|
38
|
-
def drop_database(self, db_name, options=None):
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
@abstractmethod
|
|
42
|
-
def get_database(self, db_name):
|
|
43
|
-
pass
|
|
44
|
-
|
|
45
|
-
@abstractmethod
|
|
46
|
-
def show_current_node(self):
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
@abstractmethod
|
|
50
|
-
def disconnect(self):
|
|
51
|
-
pass
|
|
52
|
-
|
|
53
|
-
@abstractmethod
|
|
54
|
-
def create_database_snapshot(self, snapshot_name: str, db_name: str):
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
|
-
@abstractmethod
|
|
58
|
-
def restore_database_snapshot(self, snapshot_name: str):
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
@abstractmethod
|
|
62
|
-
def create_system_snapshot(self, snapshot_name: str):
|
|
63
|
-
pass
|
|
64
|
-
|
|
65
|
-
@abstractmethod
|
|
66
|
-
def restore_system_snapshot(self, snapshot_name: str):
|
|
67
|
-
pass
|
|
68
|
-
|
|
69
|
-
@abstractmethod
|
|
70
|
-
def list_snapshots(self):
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
@abstractmethod
|
|
74
|
-
def show_snapshot(self, snapshot_name: str):
|
|
75
|
-
pass
|
|
76
|
-
|
|
77
|
-
@abstractmethod
|
|
78
|
-
def drop_snapshot(self, snapshot_name: str):
|
|
79
|
-
pass
|