infinity-sdk 0.6.3__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.
infinity/__init__.py ADDED
@@ -0,0 +1,34 @@
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}")
infinity/common.py ADDED
@@ -0,0 +1,124 @@
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
@@ -0,0 +1,59 @@
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()
infinity/db.py ADDED
@@ -0,0 +1,48 @@
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 abc import ABC, abstractmethod
16
+
17
+
18
+ class Database(ABC):
19
+
20
+ @abstractmethod
21
+ def create_table(self, table_name, schema, options):
22
+ pass # implement create table logic here
23
+
24
+ @abstractmethod
25
+ def drop_table(self, table_name):
26
+ pass # implement drop table logic here
27
+
28
+ @abstractmethod
29
+ def list_tables(self):
30
+ pass # implement list tables logic here
31
+
32
+ @abstractmethod
33
+ def show_table(self, table_name):
34
+ pass # implement describe table logic here
35
+
36
+ @abstractmethod
37
+ def get_table(self, table_name):
38
+ pass # implement get table logic here
39
+
40
+ @abstractmethod
41
+ def create_table_snapshot(self, snapshot_name: str, table_name: str):
42
+ pass
43
+
44
+ @abstractmethod
45
+ def restore_table_snapshot(self, snapshot_name: str):
46
+ pass
47
+
48
+
infinity/errors.py ADDED
@@ -0,0 +1,183 @@
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 IntEnum
16
+
17
+
18
+ class ErrorCode(IntEnum):
19
+ OK = 0,
20
+
21
+ INVALID_TIME_INFO = 1001,
22
+ EMPTY_CONFIG_PARAMETER = 1002,
23
+ MISMATCH_VERSION = 1003,
24
+ INVALID_TIMEZONE = 1004,
25
+ INVALID_BYTE_SIZE = 1005,
26
+ INVALID_IP_ADDR = 1006,
27
+ INVALID_LOG_LEVEL = 1007,
28
+ INVALID_CONFIG = 1008
29
+
30
+ WRONG_PASSWD = 2001,
31
+ INSUFFICIENT_PRIVILEGE = 2002,
32
+ UNSUPPORTED_VERSION_INDEX = 2003,
33
+ CLIENT_VERSION_MISMATCH = 2004,
34
+ INFINITY_IS_STARTING = 2007,
35
+ INFINITY_IS_INITING = 2008,
36
+
37
+ INVALID_USERNAME = 3001,
38
+ INVALID_PASSWD = 3002,
39
+ INVALID_IDENTIFIER_NAME = 3003,
40
+ INVALID_TABLE_NAME = 3004,
41
+ INVALID_COLUMN_NAME = 3005,
42
+ INVALID_INDEX_NAME = 3006,
43
+ INVALID_COLUMN_DEFINITION = 3007,
44
+ INVALID_TABLE_DEFINITION = 3008,
45
+ INVALID_INDEX_DEFINITION = 3009,
46
+ DATA_TYPE_MISMATCH = 3010,
47
+ NAME_TOO_LONG = 3011,
48
+ RESERVED_NAME = 3012,
49
+ SYNTAX_ERROR = 3013,
50
+ INVALID_PARAMETER_VALUE = 3014,
51
+ DUPLICATE_USER = 3015,
52
+ DUPLICATE_DATABASE_NAME = 3016,
53
+ DUPLICATE_TABLE_NAME = 3017,
54
+ DUPLICATE_INDEX_NAME = 3018,
55
+ DUPLICATE_INDEX_ON_COLUMN = 3019,
56
+ NO_SUCH_USER = 3020,
57
+ DB_NOT_EXIST = 3021,
58
+ TABLE_NOT_EXIST = 3022,
59
+ INDEX_NOT_EXIST = 3023,
60
+ COLUMN_NOT_EXIST = 3024,
61
+ AGG_NOT_ALLOW_IN_WHERE_CLAUSE = 3025,
62
+ COLUMN_IN_SELECT_NOT_IN_GROUP_BY = 3026,
63
+ NO_SUCH_SYSTEM_VAR = 3027,
64
+ INVALID_SYSTEM_VAR_VALUE = 3028,
65
+ SYSTEM_VAR_READ_ONLY = 3029,
66
+ FUNCTION_NOT_FOUND = 3030,
67
+ SPECIAL_FUNCTION_NOT_FOUND = 3031,
68
+ NOT_SUPPORTED = 3032,
69
+ DROPPING_USING_DB = 3033,
70
+ SESSION_NOT_FOUND = 3034,
71
+ RECURSIVE_AGG = 3035,
72
+ FUNCTION_ARGS_ERROR = 3036,
73
+ IMPORT_FILE_FORMAT_ERROR = 3037,
74
+ DATA_NOT_EXIST = 3038,
75
+ COLUMN_COUNT_MISMATCH = 3039,
76
+ EMPTY_DB_NAME = 3040,
77
+ EMPTY_TABLE_NAME = 3041,
78
+ EMPTY_COLUMN_NAME = 3042,
79
+ EMPTY_INDEX_NAME = 3043,
80
+ EXCEED_DB_NAME_LENGTH = 3044,
81
+ EXCEED_TABLE_NAME_LENGTH = 3045,
82
+ EXCEED_COLUMN_NAME_LENGTH = 3046,
83
+ EXCEED_INDEX_NAME_LENGTH = 3047,
84
+ NO_COLUMN_DEFINED = 3048,
85
+ NOT_SUPPORTED_TYPE_CONVERSION = 3049,
86
+ EMPTY_SELECT_FIELDS = 3050,
87
+ INVALID_DATA_TYPE = 3051,
88
+ PARSE_MATCH_EXPR_FAILED = 3052,
89
+ FTS_INDEX_NOT_EXIST = 3053,
90
+ UNKNOWN_FTS_FAULT = 3054,
91
+ INVALID_CONSTRAINT_TYPE = 3055,
92
+ INVALID_KNN_DISTANCE_TYPE = 3056,
93
+ INVALID_EMBEDDING_DATA_TYPE = 3057,
94
+ INVALID_CONSTANT_TYPE = 3058,
95
+ INVALID_PARSED_EXPR_TYPE = 3059,
96
+ INVALID_INDEX_TYPE = 3060,
97
+ INVALID_INDEX_PARAM = 3061,
98
+ LACK_INDEX_PARAM = 3062,
99
+ INVALID_FILTER_EXPRESSION = 3063,
100
+ MUTIPLE_FUNCTION_MATCHED = 3064,
101
+ INSERT_WITHOUT_VALUES = 3065,
102
+ INVALID_CONFLICT_TYPE = 3066,
103
+ INVALID_JSON_FORMAT = 3067,
104
+ DUPLICATE_COLUMN_NAME = 3068,
105
+ INVALID_EXPRESSION = 3069,
106
+ SEGMENT_NOT_EXIST = 3070,
107
+ AGGREGATE_FUNCTION_WITH_EMPTY_ARGS = 3071,
108
+ BLOCK_NOT_EXIST = 3072,
109
+ INVALID_TOPK_TYPE = 3073,
110
+ INVALID_CREATE_OPTION = 3074,
111
+ INVALID_DROP_OPTION = 3075,
112
+ INVALID_COMMAND = 3076,
113
+ ANALYZER_NOT_FOUND = 3077,
114
+ NOT_SUPPORTED_ANALYZER = 3078,
115
+ INVALID_ANALYZER_NAME = 3079,
116
+ INVALID_ANALYZER_FILE = 3080,
117
+ INVALID_EXPLAIN_TYPE = 3081,
118
+ CHUNK_NOT_EXIST = 3082,
119
+ NAME_MISMATCHED = 3083,
120
+ TRANSACTION_NOT_FOUND = 3084,
121
+ INVALID_DATABASE_INDEX = 3085,
122
+ INVALID_TABLE_INDEX = 3086,
123
+ FUNCTION_IS_DISABLE = 3087,
124
+ NOT_FOUND = 3088,
125
+ ERROR_INIT = 3089,
126
+ FILE_IS_OPEN = 3090,
127
+ UNKNOWN = 3091,
128
+ INVALID_QUERY_OPTION = 3092,
129
+
130
+ TXN_ROLLBACK = 4001,
131
+ TXN_CONFLICT = 4002,
132
+
133
+ DISK_FULL = 5001,
134
+ OUT_OF_MEMORY = 5002,
135
+ TOO_MANY_CONNECTIONS = 5003,
136
+ CONFIGURATION_LIMIT_EXCEED = 5004,
137
+ QUERY_IS_TOO_COMPLEX = 5005,
138
+ FAIL_TO_GET_SYS_INFO = 5006,
139
+
140
+ QUERY_CANCELLED = 6001,
141
+ QUERY_NOT_SUPPORTED = 6002,
142
+ CLIENT_CLOSE = 6003,
143
+
144
+ DISK_IO_ERROR = 7001,
145
+ DUPLICATED_FILE = 7002,
146
+ CONFIG_FILE_ERROR = 7003,
147
+ LOCK_FILE_EXISTS = 7004,
148
+ CATALOG_CORRUPTED = 7005,
149
+ DATA_CORRUPTED = 7006,
150
+ INDEX_CORRUPTED = 7007,
151
+ FILE_NOT_FOUND = 7008,
152
+ DIR_NOT_FOUND = 7009,
153
+ DATA_IO_ERROR = 7010,
154
+ UNEXPECTED_ERROR = 7011,
155
+ PARSER_ERROR = 7012,
156
+ MMAP_FILE_ERROR = 7013,
157
+ MUNMAP_FILE_ERROR = 7014,
158
+ INVALID_FILE_FLAG = 7015,
159
+ INVALID_SERVER_ADDRESS = 7016,
160
+ FAIL_TO_FUN_PYTHON = 7017,
161
+ CANT_CONNECT_SERVER = 7018,
162
+ NOT_EXIST_NODE = 7019,
163
+ DUPLICATE_NODE = 7020,
164
+ CANT_CONNECT_LEADER = 7021,
165
+ MINIO_INVALID_ACCESS_KEY = 7022,
166
+ MINIO_BUCKET_NOT_EXISTS = 7023,
167
+ INVALID_STORAGE_TYPE = 7024,
168
+ NOT_REGISTERED = 7025,
169
+ CANT_SWITCH_ROLE = 7026,
170
+ TOO_MANY_FOLLOWER = 7027,
171
+ TOO_MANY_LEARNER = 7028,
172
+ CHECKPOINTING = 7029,
173
+
174
+ INVALID_ENTRY = 8001,
175
+ DUPLICATE_ENTRY = 8002
176
+ NOT_FOUND_ENTRY = 8003,
177
+ EMPTY_ENTRY_LIST = 8004,
178
+ NO_WAL_ENTRY_FOUND = 8005,
179
+ WRONG_CHECKPOINT_TYPE = 8006,
180
+ INVALID_NODE_ROLE = 8007,
181
+ INVALID_NODE_STATUS = 8008,
182
+ NODE_INFO_UPDATED = 8009,
183
+ NODE_NAME_MISMATCH = 8010
infinity/index.py ADDED
@@ -0,0 +1,103 @@
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
+ )
infinity/infinity.py ADDED
@@ -0,0 +1,79 @@
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
File without changes