Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix419
Browse files Browse the repository at this point in the history
  • Loading branch information
JinHai-CN committed Dec 13, 2024
2 parents e52d6e2 + ba8dc1c commit 6d47bbd
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 141 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/slow_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ jobs:
env:
old_value: ${{ steps.start_tests_debug.outputs.old_mmmap_rnd_bits }}
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity debug version"
exit 1
Expand Down Expand Up @@ -216,9 +216,9 @@ jobs:
# && !contains(github.event.pull_request.labels.*.name, 'invalid')
id: stop_py_tests
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity release version"
exit 1
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ jobs:
if: ${{ !cancelled() }}
id: stop_tests_debug_minio
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity debug version"
exit 1
Expand Down Expand Up @@ -170,9 +170,9 @@ jobs:
if: ${{ !cancelled() }}
id: stop_tests_debug
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-debug/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity debug version"
exit 1
Expand Down Expand Up @@ -307,9 +307,9 @@ jobs:
if: ${{ !cancelled() }}
id: stop_tests_release_minio
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity debug version"
exit 1
Expand Down Expand Up @@ -337,9 +337,9 @@ jobs:
if: ${{ !cancelled() }}
id: stop_tests_release
run: |
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo chmod +x scripts/timeout_kill.sh
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 10 ${pids}"
pids=$(sudo docker exec ${BUILDER_CONTAINER} pgrep -f cmake-build-release/src/infinity | xargs echo)
sudo docker exec ${BUILDER_CONTAINER} bash -c "/infinity/scripts/timeout_kill.sh 15 ${pids}"
if [ $? -ne 0 ]; then
echo "Failed to kill infinity debug version"
exit 1
Expand Down
8 changes: 5 additions & 3 deletions python/infinity_embedded/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,12 +20,14 @@
# import pkg_resources
# __version__ = pkg_resources.get_distribution("infinity_sdk").version

from infinity_embedded.common import URI, NetworkAddress, LOCAL_HOST, LOCAL_INFINITY_PATH, InfinityException, LOCAL_INFINITY_CONFIG_PATH
from infinity_embedded.common import URI, NetworkAddress, LOCAL_HOST, LOCAL_INFINITY_PATH, InfinityException, \
LOCAL_INFINITY_CONFIG_PATH
from infinity_embedded.infinity import InfinityConnection
from infinity_embedded.local_infinity.infinity import LocalInfinityConnection
from infinity_embedded.errors import ErrorCode

def connect(uri = LOCAL_INFINITY_PATH, config_path = LOCAL_INFINITY_CONFIG_PATH) -> InfinityConnection:

def connect(uri=LOCAL_INFINITY_PATH, config_path=LOCAL_INFINITY_CONFIG_PATH) -> InfinityConnection:
if isinstance(uri, str) and len(uri) != 0:
return LocalInfinityConnection(uri, config_path)
else:
Expand Down
5 changes: 4 additions & 1 deletion python/infinity_embedded/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path
from typing import Union
from dataclasses import dataclass
Expand Down Expand Up @@ -75,10 +76,12 @@ class ConflictType(object):
Error = 1
Replace = 2


class SortType(object):
Asc = 0
Desc = 1


class InfinityException(Exception):
def __init__(self, error_code=0, error_message=None):
self.error_code = error_code
Expand Down
3 changes: 2 additions & 1 deletion python/infinity_embedded/db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,7 @@

from abc import ABC, abstractmethod


class Database(ABC):

@abstractmethod
Expand Down
35 changes: 32 additions & 3 deletions python/infinity_embedded/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -117,6 +117,15 @@ class ErrorCode(IntEnum):
INVALID_EXPLAIN_TYPE = 3081,
CHUNK_NOT_EXIST = 3082,
NAME_MISMATCHED = 3083,
TRANSACTION_NOT_FOUND = 3084,
INVALID_DATABASE_INDEX = 3085,
INVALID_TABLE_INDEX = 3086,
FUNCTION_IS_DISABLE = 3087,
NOT_FOUND = 3088,
ERROR_INIT = 3089,
FILE_IS_OPEN = 3090,
UNKNOWN = 3091,
INVALID_QUERY_OPTION = 3092,

TXN_ROLLBACK = 4001,
TXN_CONFLICT = 4002,
Expand All @@ -126,6 +135,7 @@ class ErrorCode(IntEnum):
TOO_MANY_CONNECTIONS = 5003,
CONFIGURATION_LIMIT_EXCEED = 5004,
QUERY_IS_TOO_COMPLEX = 5005,
FAIL_TO_GET_SYS_INFO = 5006,

QUERY_CANCELLED = 6001,
QUERY_NOT_SUPPORTED = 6002,
Expand All @@ -147,7 +157,26 @@ class ErrorCode(IntEnum):
MUNMAP_FILE_ERROR = 7014,
INVALID_FILE_FLAG = 7015,
INVALID_SERVER_ADDRESS = 7016,
FAIL_TO_FUN_PYTHON = 7017,
CANT_CONNECT_SERVER = 7018,
NOT_EXIST_NODE = 7019,
DUPLICATE_NODE = 7020,
CANT_CONNECT_LEADER = 7021,
MINIO_INVALID_ACCESS_KEY = 7022,
MINIO_BUCKET_NOT_EXISTS = 7023,
INVALID_STORAGE_TYPE = 7024,
NOT_REGISTERED = 7025,
CANT_SWITCH_ROLE = 7026,
TOO_MANY_FOLLOWER = 7027,
TOO_MANY_LEARNER = 7028,

INVALID_ENTRY = 8001,
NOT_FOUND_ENTRY = 8002,
EMPTY_ENTRY_LIST = 8003,
DUPLICATE_ENTRY = 8002
NOT_FOUND_ENTRY = 8003,
EMPTY_ENTRY_LIST = 8004,
NO_WAL_ENTRY_FOUND = 8005,
WRONG_CHECKPOINT_TYPE = 8006,
INVALID_NODE_ROLE = 8007,
INVALID_NODE_STATUS = 8008,
NODE_INFO_UPDATED = 8009,
NODE_NAME_MISMATCH = 8010
3 changes: 1 addition & 2 deletions python/infinity_embedded/index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@

from infinity_embedded.embedded_infinity_ext import IndexType as LocalIndexType, WrapIndexInfo
from infinity_embedded.embedded_infinity_ext import InitParameter as LocalInitParameter
from infinity_embedded.embedded_infinity_ext import WrapIndexInfo as LocalIndexInfo
from infinity_embedded.errors import ErrorCode


Expand Down
4 changes: 3 additions & 1 deletion python/infinity_embedded/infinity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,8 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC, abstractmethod


# abstract class
class InfinityConnection(ABC):
def __init__(self, uri):
Expand Down
7 changes: 4 additions & 3 deletions python/infinity_embedded/local_infinity/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,8 @@ class LocalQueryResult:
def __init__(self, error_code: PyErrorCode, error_msg: str, db_names=None, table_names=None, index_names=None,
column_defs=None, column_fields=None, database_name=None, store_dir=None, table_count=None,
comment=None,
table_name=None, index_name=None, index_type=None, index_comment=None, deleted_rows=0, extra_result=None):
table_name=None, index_name=None, index_type=None, index_comment=None, deleted_rows=0,
extra_result=None):
self.error_code = error_code
self.error_msg = error_msg
self.db_names = db_names
Expand All @@ -44,7 +45,7 @@ def __init__(self, error_code: PyErrorCode, error_msg: str, db_names=None, table


class LocalInfinityClient:
def __init__(self, path: str = LOCAL_INFINITY_PATH, config_path = LOCAL_INFINITY_CONFIG_PATH):
def __init__(self, path: str = LOCAL_INFINITY_PATH, config_path=LOCAL_INFINITY_CONFIG_PATH):
self.path = path
Infinity.LocalInit(path, config_path)
self.client = Infinity.LocalConnect()
Expand Down
14 changes: 14 additions & 0 deletions python/infinity_embedded/local_infinity/db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from abc import ABC

from infinity_embedded.db import Database
Expand Down
15 changes: 14 additions & 1 deletion python/infinity_embedded/local_infinity/infinity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright(C) 2024 InfiniFlow, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from infinity_embedded import InfinityConnection
from abc import ABC
Expand Down Expand Up @@ -90,7 +104,6 @@ def show_current_node(self):
else:
raise InfinityException(res.error_code, res.error_msg)


def search(self, db_name, table_name):
self.check_connect()
res = self._client.search(db_name, table_name, [])
Expand Down
Loading

0 comments on commit 6d47bbd

Please sign in to comment.