iginx-pyclient 0.6.0__tar.gz → 0.7.0__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.
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/MANIFEST.in +3 -3
- {iginx-pyclient-0.6.0/iginx_pyclient.egg-info → iginx-pyclient-0.7.0}/PKG-INFO +38 -37
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/README.md +27 -26
- iginx-pyclient-0.7.0/iginx_pyclient/__init__.py +19 -0
- iginx-pyclient-0.7.0/iginx_pyclient/cluster_info.py +68 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient/dataset.py +109 -22
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient/session.py +59 -21
- iginx-pyclient-0.7.0/iginx_pyclient/thrift/__init__.py +18 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient/thrift/rpc/IService.py +585 -0
- iginx-pyclient-0.7.0/iginx_pyclient/thrift/rpc/__init__.py +19 -0
- iginx-pyclient-0.7.0/iginx_pyclient/thrift/rpc/constants.py +32 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient/thrift/rpc/ttypes.py +862 -251
- iginx-pyclient-0.7.0/iginx_pyclient/time_series.py +37 -0
- iginx-pyclient-0.7.0/iginx_pyclient/utils/__init__.py +19 -0
- iginx-pyclient-0.7.0/iginx_pyclient/utils/bitmap.py +41 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient/utils/byte_utils.py +28 -22
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0/iginx_pyclient.egg-info}/PKG-INFO +38 -37
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/setup.cfg +4 -4
- iginx-pyclient-0.7.0/setup.py +60 -0
- iginx-pyclient-0.6.0/iginx_pyclient/__init__.py +0 -17
- iginx-pyclient-0.6.0/iginx_pyclient/cluster_info.py +0 -53
- iginx-pyclient-0.6.0/iginx_pyclient/thrift/__init__.py +0 -0
- iginx-pyclient-0.6.0/iginx_pyclient/thrift/rpc/__init__.py +0 -1
- iginx-pyclient-0.6.0/iginx_pyclient/thrift/rpc/constants.py +0 -14
- iginx-pyclient-0.6.0/iginx_pyclient/time_series.py +0 -36
- iginx-pyclient-0.6.0/iginx_pyclient/utils/__init__.py +0 -17
- iginx-pyclient-0.6.0/iginx_pyclient/utils/bitmap.py +0 -41
- iginx-pyclient-0.6.0/setup.py +0 -35
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/LICENSE +0 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient.egg-info/SOURCES.txt +0 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient.egg-info/dependency_links.txt +0 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient.egg-info/requires.txt +0 -0
- {iginx-pyclient-0.6.0 → iginx-pyclient-0.7.0}/iginx_pyclient.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
global-exclude __pycache__ *.py[cod] *.egg-info
|
|
2
|
-
include setup.py
|
|
3
|
-
include README.md
|
|
1
|
+
global-exclude __pycache__ *.py[cod] *.egg-info
|
|
2
|
+
include setup.py
|
|
3
|
+
include README.md
|
|
4
4
|
include LICENSE
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: iginx-pyclient
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: IGinX-PyClient
|
|
5
|
-
Author: THU IGinX
|
|
6
|
-
Author-email: TSIginX@gmail.com
|
|
7
|
-
License: Apache License 2.0
|
|
8
|
-
Requires-Python: >=3.8
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
|
|
12
|
-
# IGinX-PyClient
|
|
13
|
-
|
|
14
|
-
## What is it?
|
|
15
|
-
|
|
16
|
-
[IGinX (Intelligent enGine X)](https://github.com/IGinX-THU/IGinX) is an open source polystore system. A polystore system provides an integrated data management service over a set of one or more potentially heterogeneous database/storage engines, serving heterogeneous workloads.
|
|
17
|
-
|
|
18
|
-
IGinX-PyClient is a Python interface library designed for IGinX, offering a convenient Session interface for users to effortlessly leverage the powerful features of IGinX within a Python environment. With this interface, users can perform database queries, manage data streams, and execute other operations supported by IGinX without leaving the Python ecosystem.
|
|
19
|
-
|
|
20
|
-
## Where to get?
|
|
21
|
-
|
|
22
|
-
Python binary installers for the latest released version are available at the [Python package index](https://pypi.org/project/iginx-pyclient)
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pip install iginx-pyclient
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Dependencies
|
|
29
|
-
|
|
30
|
-
- pandas(>=2.0.3)
|
|
31
|
-
|
|
32
|
-
## Example
|
|
33
|
-
|
|
34
|
-
Please refer to code below:
|
|
35
|
-
|
|
36
|
-
- [SQL example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/example.py)
|
|
37
|
-
- [file operation example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/file_example.py)
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iginx-pyclient
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: IGinX-PyClient
|
|
5
|
+
Author: THU IGinX
|
|
6
|
+
Author-email: TSIginX@gmail.com
|
|
7
|
+
License: Apache License 2.0
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
|
|
12
|
+
# IGinX-PyClient
|
|
13
|
+
|
|
14
|
+
## What is it?
|
|
15
|
+
|
|
16
|
+
[IGinX (Intelligent enGine X)](https://github.com/IGinX-THU/IGinX) is an open source polystore system. A polystore system provides an integrated data management service over a set of one or more potentially heterogeneous database/storage engines, serving heterogeneous workloads.
|
|
17
|
+
|
|
18
|
+
IGinX-PyClient is a Python interface library designed for IGinX, offering a convenient Session interface for users to effortlessly leverage the powerful features of IGinX within a Python environment. With this interface, users can perform database queries, manage data streams, and execute other operations supported by IGinX without leaving the Python ecosystem.
|
|
19
|
+
|
|
20
|
+
## Where to get?
|
|
21
|
+
|
|
22
|
+
Python binary installers for the latest released version are available at the [Python package index](https://pypi.org/project/iginx-pyclient)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install iginx-pyclient
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
- pandas(>=2.0.3)
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
Please refer to code below:
|
|
35
|
+
|
|
36
|
+
- [SQL example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/example.py)
|
|
37
|
+
- [file operation example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/file_example.py)
|
|
38
|
+
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
# IGinX-PyClient
|
|
2
|
-
|
|
3
|
-
## What is it?
|
|
4
|
-
|
|
5
|
-
[IGinX (Intelligent enGine X)](https://github.com/IGinX-THU/IGinX) is an open source polystore system. A polystore system provides an integrated data management service over a set of one or more potentially heterogeneous database/storage engines, serving heterogeneous workloads.
|
|
6
|
-
|
|
7
|
-
IGinX-PyClient is a Python interface library designed for IGinX, offering a convenient Session interface for users to effortlessly leverage the powerful features of IGinX within a Python environment. With this interface, users can perform database queries, manage data streams, and execute other operations supported by IGinX without leaving the Python ecosystem.
|
|
8
|
-
|
|
9
|
-
## Where to get?
|
|
10
|
-
|
|
11
|
-
Python binary installers for the latest released version are available at the [Python package index](https://pypi.org/project/iginx-pyclient)
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
pip install iginx-pyclient
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Dependencies
|
|
18
|
-
|
|
19
|
-
- pandas(>=2.0.3)
|
|
20
|
-
|
|
21
|
-
## Example
|
|
22
|
-
|
|
23
|
-
Please refer to code below:
|
|
24
|
-
|
|
25
|
-
- [SQL example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/example.py)
|
|
26
|
-
- [file operation example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/file_example.py)
|
|
1
|
+
# IGinX-PyClient
|
|
2
|
+
|
|
3
|
+
## What is it?
|
|
4
|
+
|
|
5
|
+
[IGinX (Intelligent enGine X)](https://github.com/IGinX-THU/IGinX) is an open source polystore system. A polystore system provides an integrated data management service over a set of one or more potentially heterogeneous database/storage engines, serving heterogeneous workloads.
|
|
6
|
+
|
|
7
|
+
IGinX-PyClient is a Python interface library designed for IGinX, offering a convenient Session interface for users to effortlessly leverage the powerful features of IGinX within a Python environment. With this interface, users can perform database queries, manage data streams, and execute other operations supported by IGinX without leaving the Python ecosystem.
|
|
8
|
+
|
|
9
|
+
## Where to get?
|
|
10
|
+
|
|
11
|
+
Python binary installers for the latest released version are available at the [Python package index](https://pypi.org/project/iginx-pyclient)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install iginx-pyclient
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Dependencies
|
|
18
|
+
|
|
19
|
+
- pandas(>=2.0.3)
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
Please refer to code below:
|
|
24
|
+
|
|
25
|
+
- [SQL example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/example.py)
|
|
26
|
+
- [file operation example code](https://github.com/IGinX-THU/IGinX/blob/main/session_py/file_example.py)
|
|
27
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# IGinX - the polystore system with high performance
|
|
3
|
+
# Copyright (C) Tsinghua University
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
#
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#
|
|
2
|
+
# IGinX - the polystore system with high performance
|
|
3
|
+
# Copyright (C) Tsinghua University
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
from .thrift.rpc.ttypes import StorageEngineType
|
|
20
|
+
class ClusterInfo(object):
|
|
21
|
+
|
|
22
|
+
def __init__(self, resp):
|
|
23
|
+
self.__iginx_list = resp.iginxInfos
|
|
24
|
+
self.__storage_engine_list = StorageEngineInfosWrapper(resp.storageEngineInfos)
|
|
25
|
+
self.__meta_storage_list = resp.metaStorageInfos
|
|
26
|
+
self.__local_meta_storage = resp.localMetaStorageInfo
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_iginx_list(self):
|
|
30
|
+
return self.__iginx_list
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_storage_engine_list(self):
|
|
34
|
+
return self.__storage_engine_list
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_local_meta_storage(self):
|
|
38
|
+
return self.__local_meta_storage
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_meta_storage_list(self):
|
|
42
|
+
return self.__meta_storage_list
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def is_use_local_meta_storage(self):
|
|
46
|
+
return self.__local_meta_storage is not None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def __str__(self):
|
|
50
|
+
value = str(self.__iginx_list) + "\n" + str(self.__storage_engine_list) + "\n"
|
|
51
|
+
if self.__meta_storage_list:
|
|
52
|
+
value += str(self.__meta_storage_list)
|
|
53
|
+
else:
|
|
54
|
+
value += str(self.__local_meta_storage)
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class StorageEngineInfosWrapper:
|
|
59
|
+
def __init__(self, storage_engine_infos):
|
|
60
|
+
self.storage_engine_infos = storage_engine_infos
|
|
61
|
+
|
|
62
|
+
def __repr__(self):
|
|
63
|
+
res = []
|
|
64
|
+
for sei in self.storage_engine_infos:
|
|
65
|
+
L = ['%s=%r' % (key, value if key != "type" else StorageEngineType._VALUES_TO_NAMES.get(int(value)))
|
|
66
|
+
for key, value in sei.__dict__.items()]
|
|
67
|
+
res.append('%s(%s)' % (sei.__class__.__name__, ', '.join(L)))
|
|
68
|
+
return '[%s]' % (', '.join(res))
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
1
|
#
|
|
9
|
-
#
|
|
2
|
+
# IGinX - the polystore system with high performance
|
|
3
|
+
# Copyright (C) Tsinghua University
|
|
10
4
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
17
9
|
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|
|
18
19
|
from enum import Enum
|
|
19
20
|
|
|
20
21
|
import pandas as pd
|
|
@@ -22,6 +23,84 @@ import pandas as pd
|
|
|
22
23
|
from .thrift.rpc.ttypes import SqlType, AggregateType, ExecuteSqlResp
|
|
23
24
|
from .utils.bitmap import Bitmap
|
|
24
25
|
from .utils.byte_utils import get_long_array, get_values_by_data_type, BytesParser
|
|
26
|
+
from .thrift.rpc.ttypes import DataType
|
|
27
|
+
|
|
28
|
+
def map_dtype(dtype):
|
|
29
|
+
if pd.api.types.is_bool_dtype(dtype):
|
|
30
|
+
return DataType.BOOLEAN
|
|
31
|
+
elif pd.api.types.is_integer_dtype(dtype):
|
|
32
|
+
if dtype == 'int32':
|
|
33
|
+
return DataType.INTEGER
|
|
34
|
+
else:
|
|
35
|
+
return DataType.LONG
|
|
36
|
+
elif pd.api.types.is_float_dtype(dtype):
|
|
37
|
+
if dtype == 'float32':
|
|
38
|
+
return DataType.FLOAT
|
|
39
|
+
else:
|
|
40
|
+
return DataType.DOUBLE
|
|
41
|
+
elif pd.api.types.is_numeric_dtype(dtype):
|
|
42
|
+
return DataType.DOUBLE
|
|
43
|
+
else:
|
|
44
|
+
return DataType.BINARY # all other types are treated as BINARY
|
|
45
|
+
|
|
46
|
+
# TODO: process NA values
|
|
47
|
+
def column_dataset_from_df(df: pd.DataFrame, prefix: str = ""):
|
|
48
|
+
# if no prefix is provided, the column names must contain at least one '.' except key.
|
|
49
|
+
column_list = df.columns.tolist()
|
|
50
|
+
if prefix == "":
|
|
51
|
+
for col in column_list:
|
|
52
|
+
if '.' not in col and col != 'key':
|
|
53
|
+
raise RuntimeError(f"The paths in data must contain '.' or prefix must be set")
|
|
54
|
+
else:
|
|
55
|
+
prefix = prefix + '.'
|
|
56
|
+
|
|
57
|
+
if 'key' in column_list:
|
|
58
|
+
# examine key type
|
|
59
|
+
key_dtype = df['key'].dtype
|
|
60
|
+
valid_key = False
|
|
61
|
+
if key_dtype == 'int64':
|
|
62
|
+
valid_key = True
|
|
63
|
+
elif pd.api.types.is_integer_dtype(key_dtype):
|
|
64
|
+
df['key'] = df['key'].astype('int64')
|
|
65
|
+
valid_key = True
|
|
66
|
+
|
|
67
|
+
if not valid_key:
|
|
68
|
+
raise RuntimeError(f"Invalid key type is provided. Required long/int but was %s.", df['key'].dtype)
|
|
69
|
+
key_list = df['key'].tolist()
|
|
70
|
+
df = df.drop(columns=['key'])
|
|
71
|
+
# if there is no key column in data, creat one
|
|
72
|
+
else:
|
|
73
|
+
key_list = list(range(len(df)))
|
|
74
|
+
|
|
75
|
+
mapped_types = [map_dtype(dtype) for col, dtype in df.dtypes.items()]
|
|
76
|
+
values_list = [df[col].tolist() for col in df.columns]
|
|
77
|
+
column_list = [prefix + col for col in df.columns.tolist()]
|
|
78
|
+
return ColumnDataSet(column_list, mapped_types, key_list, values_list)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class ColumnDataSet(object):
|
|
82
|
+
def __init__(self, paths, types, keys, values_list):
|
|
83
|
+
self.__paths = paths
|
|
84
|
+
self.__types = types
|
|
85
|
+
self.__keys = keys
|
|
86
|
+
self.__values_list = values_list
|
|
87
|
+
|
|
88
|
+
def get_insert_args(self):
|
|
89
|
+
return self.__paths, self.__keys, self.__values_list, self.__types
|
|
90
|
+
|
|
91
|
+
def __str__(self):
|
|
92
|
+
column_names = ['key'] + self.__paths
|
|
93
|
+
num_rows = len(self.__keys)
|
|
94
|
+
columns = [self.__keys] + self.__values_list
|
|
95
|
+
output = []
|
|
96
|
+
|
|
97
|
+
output.append('\t'.join(column_names))
|
|
98
|
+
|
|
99
|
+
for i in range(num_rows):
|
|
100
|
+
row = [str(columns[j][i]) for j in range(len(columns))]
|
|
101
|
+
output.append('\t'.join(row))
|
|
102
|
+
|
|
103
|
+
return '\n'.join(output)
|
|
25
104
|
|
|
26
105
|
|
|
27
106
|
class Point(object):
|
|
@@ -99,15 +178,20 @@ class QueryDataSet(object):
|
|
|
99
178
|
return value
|
|
100
179
|
|
|
101
180
|
def to_df(self):
|
|
102
|
-
|
|
181
|
+
has_key = self.__timestamps != []
|
|
182
|
+
columns = ["key"] if has_key else []
|
|
103
183
|
for column in self.__paths:
|
|
104
184
|
columns.append(str(column))
|
|
105
185
|
|
|
106
186
|
value_matrix = []
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
187
|
+
if has_key:
|
|
188
|
+
for i in range(len(self.__timestamps)):
|
|
189
|
+
value = [self.__timestamps[i]]
|
|
190
|
+
value.extend(self.__values[i])
|
|
191
|
+
value_matrix.append(value)
|
|
192
|
+
else:
|
|
193
|
+
for i in range(len(self.__values)):
|
|
194
|
+
value_matrix.append(self.__values[i])
|
|
111
195
|
|
|
112
196
|
return pd.DataFrame(value_matrix, columns=columns)
|
|
113
197
|
|
|
@@ -244,11 +328,14 @@ class StatementExecuteDataSet(object):
|
|
|
244
328
|
return None
|
|
245
329
|
|
|
246
330
|
values_buffer = self.__values_list[self.__index]
|
|
331
|
+
bitmap_buffer = self.__bitmap_list[self.__index]
|
|
247
332
|
self.__index += 1
|
|
248
|
-
|
|
333
|
+
|
|
334
|
+
bitmap = Bitmap(len(self.__types), bitmap_buffer)
|
|
335
|
+
bytes_list = BytesParser(values_buffer).get_bytes_from_types(self.__types, bitmap)
|
|
249
336
|
if remove_key:
|
|
250
|
-
|
|
251
|
-
return
|
|
337
|
+
bytes_list = bytes_list[1:]
|
|
338
|
+
return bytes_list
|
|
252
339
|
|
|
253
340
|
def close(self):
|
|
254
341
|
self.__session._close_statement(query_id=self.__query_id)
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
-
# or more contributor license agreements. See the NOTICE file
|
|
3
|
-
# distributed with this work for additional information
|
|
4
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
-
# to you under the Apache License, Version 2.0 (the
|
|
6
|
-
# "License"); you may not use this file except in compliance
|
|
7
|
-
# with the License. You may obtain a copy of the License at
|
|
8
1
|
#
|
|
9
|
-
#
|
|
2
|
+
# IGinX - the polystore system with high performance
|
|
3
|
+
# Copyright (C) Tsinghua University
|
|
10
4
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
17
9
|
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|
|
18
19
|
import csv
|
|
19
20
|
import logging
|
|
20
21
|
import os.path
|
|
21
22
|
from datetime import datetime
|
|
22
23
|
|
|
24
|
+
import pandas as pd
|
|
23
25
|
from thrift.protocol import TBinaryProtocol
|
|
24
26
|
from thrift.transport import TSocket, TTransport
|
|
25
27
|
from pathlib import Path
|
|
26
28
|
|
|
27
29
|
from .cluster_info import ClusterInfo
|
|
28
|
-
from .dataset import QueryDataSet, AggregateQueryDataSet, StatementExecuteDataSet
|
|
30
|
+
from .dataset import column_dataset_from_df, QueryDataSet, AggregateQueryDataSet, StatementExecuteDataSet
|
|
29
31
|
from .thrift.rpc.IService import Client
|
|
30
32
|
from .thrift.rpc.ttypes import (
|
|
31
33
|
OpenSessionReq,
|
|
@@ -62,6 +64,25 @@ from .utils.byte_utils import timestamps_to_bytes, row_values_to_bytes, column_v
|
|
|
62
64
|
|
|
63
65
|
logger = logging.getLogger("IginX")
|
|
64
66
|
|
|
67
|
+
# key value boundary for IGinX(defined in shared.GlobalConstant)
|
|
68
|
+
MAX_KEY = 9223372036854775807
|
|
69
|
+
MIN_KEY = -9223372036854775807
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def isPyReg(statement:str):
|
|
73
|
+
statement = statement.strip().lower()
|
|
74
|
+
return statement.startswith("create") and ("function" in statement)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def process_py_reg(statement:str):
|
|
78
|
+
assert len(statement.split("\"")) >= 7
|
|
79
|
+
path = statement.split("\"")[-1]
|
|
80
|
+
if os.path.isabs(path):
|
|
81
|
+
return statement
|
|
82
|
+
else:
|
|
83
|
+
abs_path = os.path.abspath(path)
|
|
84
|
+
return statement.replace(path, abs_path)
|
|
85
|
+
|
|
65
86
|
|
|
66
87
|
class Session(object):
|
|
67
88
|
SUCCESS_CODE = 200
|
|
@@ -267,7 +288,7 @@ class Session(object):
|
|
|
267
288
|
bitmap_buffer_list.append(bitmap_to_bytes(bitmap.get_bytes()))
|
|
268
289
|
|
|
269
290
|
req = InsertNonAlignedRowRecordsReq(sessionId=self.__session_id, paths=paths,
|
|
270
|
-
|
|
291
|
+
keys=timestamps_to_bytes(timestamps), valuesList=values_buffer_list,
|
|
271
292
|
bitmapList=bitmap_buffer_list, dataTypeList=sorted_data_type_list,
|
|
272
293
|
tagsList=sorted_tags_list, timePrecision=timePrecision)
|
|
273
294
|
status = self.__client.insertNonAlignedRowRecords(req)
|
|
@@ -322,7 +343,7 @@ class Session(object):
|
|
|
322
343
|
bitmap_buffer_list.append(bitmap_to_bytes(bitmap.get_bytes()))
|
|
323
344
|
|
|
324
345
|
req = InsertColumnRecordsReq(sessionId=self.__session_id, paths=paths,
|
|
325
|
-
|
|
346
|
+
keys=timestamps_to_bytes(timestamps),
|
|
326
347
|
valuesList=values_buffer_list,
|
|
327
348
|
bitmapList=bitmap_buffer_list, dataTypeList=sorted_data_type_list,
|
|
328
349
|
tagsList=sorted_tags_list, timePrecision=timePrecision)
|
|
@@ -379,13 +400,24 @@ class Session(object):
|
|
|
379
400
|
bitmap_buffer_list.append(bitmap_to_bytes(bitmap.get_bytes()))
|
|
380
401
|
|
|
381
402
|
req = InsertNonAlignedColumnRecordsReq(sessionId=self.__session_id, paths=paths,
|
|
382
|
-
|
|
403
|
+
keys=timestamps_to_bytes(timestamps),
|
|
383
404
|
valuesList=values_buffer_list,
|
|
384
405
|
bitmapList=bitmap_buffer_list, dataTypeList=sorted_data_type_list,
|
|
385
406
|
tagsList=sorted_tags_list, timePrecision=timePrecision)
|
|
386
407
|
status = self.__client.insertNonAlignedColumnRecords(req)
|
|
387
408
|
Session.verify_status(status)
|
|
388
409
|
|
|
410
|
+
def insert_df(self, df: pd.DataFrame, prefix: str = ""):
|
|
411
|
+
"""
|
|
412
|
+
insert dataframe data into IGinX
|
|
413
|
+
:param df: dataframe that contains data
|
|
414
|
+
:param prefix: (optional) path names in IGinX
|
|
415
|
+
must contain '.'. If columns in dataframe does not meet the requirement, a prefix can be used
|
|
416
|
+
"""
|
|
417
|
+
dataset = column_dataset_from_df(df, prefix)
|
|
418
|
+
paths, keys, value_list, type_list = dataset.get_insert_args()
|
|
419
|
+
self.insert_column_records(paths, keys, value_list, type_list)
|
|
420
|
+
|
|
389
421
|
def query(self, paths, start_time, end_time, timePrecision=None):
|
|
390
422
|
req = QueryDataReq(sessionId=self.__session_id, paths=Session.merge_and_sort_paths(paths),
|
|
391
423
|
startKey=start_time, endKey=end_time, timePrecision=timePrecision)
|
|
@@ -410,8 +442,12 @@ class Session(object):
|
|
|
410
442
|
return QueryDataSet(paths, data_types, raw_data_set.keys, raw_data_set.valuesList,
|
|
411
443
|
raw_data_set.bitmapList)
|
|
412
444
|
|
|
445
|
+
def downsample_query_no_interval(self, paths, type, precision, timePrecision=None):
|
|
446
|
+
return self.downsample_query(paths, MIN_KEY, MAX_KEY, type, precision, timePrecision)
|
|
447
|
+
|
|
448
|
+
|
|
413
449
|
def downsample_query(self, paths, start_time, end_time, type, precision, timePrecision=None):
|
|
414
|
-
req = DownsampleQueryReq(sessionId=self.__session_id, paths=paths,
|
|
450
|
+
req = DownsampleQueryReq(sessionId=self.__session_id, paths=paths, startKey=start_time, endKey=end_time,
|
|
415
451
|
aggregateType=type,
|
|
416
452
|
precision=precision, timePrecision=timePrecision)
|
|
417
453
|
resp = self.__client.downsampleQuery(req)
|
|
@@ -433,7 +469,7 @@ class Session(object):
|
|
|
433
469
|
self.batch_delete_data([path], start_time, end_time, timePrecision)
|
|
434
470
|
|
|
435
471
|
def batch_delete_data(self, paths, start_time, end_time, timePrecision=None):
|
|
436
|
-
req = DeleteDataInColumnsReq(sessionId=self.__session_id, paths=paths,
|
|
472
|
+
req = DeleteDataInColumnsReq(sessionId=self.__session_id, paths=paths, startKey=start_time, endKey=end_time,
|
|
437
473
|
timePrecision=timePrecision)
|
|
438
474
|
status = self.__client.deleteDataInColumns(req)
|
|
439
475
|
Session.verify_status(status)
|
|
@@ -464,6 +500,8 @@ class Session(object):
|
|
|
464
500
|
return ClusterInfo(resp)
|
|
465
501
|
|
|
466
502
|
def execute_sql(self, statement):
|
|
503
|
+
if isPyReg(statement):
|
|
504
|
+
statement = process_py_reg(statement)
|
|
467
505
|
req = ExecuteSqlReq(sessionId=self.__session_id, statement=statement)
|
|
468
506
|
resp = self.__client.executeSql(req)
|
|
469
507
|
Session.verify_status(resp.status)
|
|
@@ -608,7 +646,7 @@ class Session(object):
|
|
|
608
646
|
with open(column, mode) as fos:
|
|
609
647
|
for value in binary_data_list:
|
|
610
648
|
# 写入对应列的数据
|
|
611
|
-
fos.write(value)
|
|
649
|
+
fos.write(value[i-1])
|
|
612
650
|
except IOError as e:
|
|
613
651
|
raise RuntimeError(f"Encounter an error when writing file {column}, because {e}")
|
|
614
652
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#
|
|
2
|
+
# IGinX - the polystore system with high performance
|
|
3
|
+
# Copyright (C) Tsinghua University
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
#
|
|
18
|
+
|