apache-iotdb 2.0.2__py3-none-any.whl → 2.0.4.dev0__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.
- {apache_iotdb-2.0.2.dist-info → apache_iotdb-2.0.4.dev0.dist-info}/METADATA +6 -6
- {apache_iotdb-2.0.2.dist-info → apache_iotdb-2.0.4.dev0.dist-info}/RECORD +34 -22
- {apache_iotdb-2.0.2.dist-info → apache_iotdb-2.0.4.dev0.dist-info}/WHEEL +1 -1
- iotdb/Session.py +158 -184
- iotdb/SessionPool.py +3 -1
- iotdb/template/MeasurementNode.py +1 -1
- iotdb/template/Template.py +3 -3
- iotdb/thrift/common/ttypes.py +18 -1
- iotdb/thrift/confignode/IConfigNodeRPCService.py +28290 -0
- iotdb/thrift/confignode/__init__.py +1 -0
- iotdb/thrift/confignode/constants.py +14 -0
- iotdb/thrift/confignode/ttypes.py +17249 -0
- iotdb/thrift/datanode/IDataNodeRPCService.py +17960 -0
- iotdb/thrift/datanode/MPPDataExchangeService.py +1071 -0
- iotdb/thrift/datanode/__init__.py +1 -0
- iotdb/thrift/datanode/constants.py +14 -0
- iotdb/thrift/datanode/ttypes.py +10920 -0
- iotdb/tsfile/utils/tsblock_serde.py +266 -0
- iotdb/utils/Field.py +30 -5
- iotdb/utils/NumpyTablet.py +1 -1
- iotdb/utils/SessionDataSet.py +43 -24
- iotdb/utils/Tablet.py +1 -1
- iotdb/utils/{IoTDBConnectionException.py → exception.py} +20 -0
- iotdb/utils/iotdb_rpc_dataset.py +406 -0
- iotdb/utils/rpc_utils.py +110 -0
- tests/integration/tablet_performance_comparison.py +3 -1
- tests/integration/test_new_data_types.py +6 -6
- tests/integration/test_tablemodel_query.py +476 -0
- iotdb/utils/IoTDBRpcDataSet.py +0 -463
- {apache_iotdb-2.0.2.dist-info → apache_iotdb-2.0.4.dev0.dist-info}/entry_points.txt +0 -0
- {apache_iotdb-2.0.2.dist-info → apache_iotdb-2.0.4.dev0.dist-info}/top_level.txt +0 -0
- /iotdb/tsfile/common/constant/{TsFileConstant.py → tsfile_constant.py} +0 -0
- /iotdb/tsfile/utils/{DateUtils.py → date_utils.py} +0 -0
- /iotdb/tsfile/utils/{Pair.py → pair.py} +0 -0
- /iotdb/tsfile/utils/{ReadWriteIOUtils.py → read_write_io_utils.py} +0 -0
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Serialized tsBlock:
|
|
23
|
+
# +-------------+---------------+---------+------------+-----------+----------+
|
|
24
|
+
# | val col cnt | val col types | pos cnt | encodings | time col | val col |
|
|
25
|
+
# +-------------+---------------+---------+------------+-----------+----------+
|
|
26
|
+
# | int32 | list[byte] | int32 | list[byte] | bytes | byte |
|
|
27
|
+
# +-------------+---------------+---------+------------+-----------+----------+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def deserialize(buffer):
|
|
31
|
+
value_column_count, buffer = read_int_from_buffer(buffer)
|
|
32
|
+
data_types, buffer = read_column_types(buffer, value_column_count)
|
|
33
|
+
|
|
34
|
+
position_count, buffer = read_int_from_buffer(buffer)
|
|
35
|
+
column_encodings, buffer = read_column_encoding(buffer, value_column_count + 1)
|
|
36
|
+
|
|
37
|
+
time_column_values, _, buffer = read_column(
|
|
38
|
+
column_encodings[0], buffer, 2, position_count
|
|
39
|
+
)
|
|
40
|
+
column_values = []
|
|
41
|
+
null_indicators = []
|
|
42
|
+
for i in range(value_column_count):
|
|
43
|
+
column_value, null_indicator, buffer = read_column(
|
|
44
|
+
column_encodings[i + 1], buffer, data_types[i], position_count
|
|
45
|
+
)
|
|
46
|
+
column_values.append(column_value)
|
|
47
|
+
null_indicators.append(null_indicator)
|
|
48
|
+
|
|
49
|
+
return time_column_values, column_values, null_indicators, position_count
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# General Methods
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def read_int_from_buffer(buffer):
|
|
56
|
+
res = np.frombuffer(buffer, dtype=">i4", count=1)
|
|
57
|
+
buffer = buffer[4:]
|
|
58
|
+
return res[0], buffer
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def read_byte_from_buffer(buffer):
|
|
62
|
+
return read_from_buffer(buffer, 1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def read_from_buffer(buffer, size):
|
|
66
|
+
res = buffer[:size]
|
|
67
|
+
new_buffer = buffer[size:]
|
|
68
|
+
return res, new_buffer
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Read ColumnType
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def read_column_types(buffer, value_column_count):
|
|
75
|
+
data_types = np.frombuffer(buffer, dtype=np.uint8, count=value_column_count)
|
|
76
|
+
new_buffer = buffer[value_column_count:]
|
|
77
|
+
if not np.all(np.isin(data_types, (0, 1, 2, 3, 4, 5))):
|
|
78
|
+
raise Exception("Invalid data type encountered: " + str(data_types))
|
|
79
|
+
return data_types, new_buffer
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# Read ColumnEncodings
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def read_column_encoding(buffer, size):
|
|
86
|
+
encodings = np.frombuffer(buffer, dtype=np.uint8, count=size)
|
|
87
|
+
new_buffer = buffer[size:]
|
|
88
|
+
return encodings, new_buffer
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# Read Column
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def deserialize_null_indicators(buffer, size):
|
|
95
|
+
may_have_null = buffer[0]
|
|
96
|
+
buffer = buffer[1:]
|
|
97
|
+
if may_have_null != 0:
|
|
98
|
+
return deserialize_from_boolean_array(buffer, size)
|
|
99
|
+
return None, buffer
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# Serialized data layout:
|
|
103
|
+
# +---------------+-----------------+-------------+
|
|
104
|
+
# | may have null | null indicators | values |
|
|
105
|
+
# +---------------+-----------------+-------------+
|
|
106
|
+
# | byte | list[byte] | list[int64] |
|
|
107
|
+
# +---------------+-----------------+-------------+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def read_int64_column(buffer, data_type, position_count):
|
|
111
|
+
null_indicators, buffer = deserialize_null_indicators(buffer, position_count)
|
|
112
|
+
if null_indicators is None:
|
|
113
|
+
size = position_count
|
|
114
|
+
else:
|
|
115
|
+
size = np.count_nonzero(~null_indicators)
|
|
116
|
+
|
|
117
|
+
if data_type == 2:
|
|
118
|
+
dtype = ">i8"
|
|
119
|
+
elif data_type == 4:
|
|
120
|
+
dtype = ">f8"
|
|
121
|
+
else:
|
|
122
|
+
raise Exception("Invalid data type: " + str(data_type))
|
|
123
|
+
values = np.frombuffer(buffer, dtype, count=size)
|
|
124
|
+
buffer = buffer[size * 8 :]
|
|
125
|
+
return values, null_indicators, buffer
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# Serialized data layout:
|
|
129
|
+
# +---------------+-----------------+-------------+
|
|
130
|
+
# | may have null | null indicators | values |
|
|
131
|
+
# +---------------+-----------------+-------------+
|
|
132
|
+
# | byte | list[byte] | list[int32] |
|
|
133
|
+
# +---------------+-----------------+-------------+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def read_int32_column(buffer, data_type, position_count):
|
|
137
|
+
null_indicators, buffer = deserialize_null_indicators(buffer, position_count)
|
|
138
|
+
if null_indicators is None:
|
|
139
|
+
size = position_count
|
|
140
|
+
else:
|
|
141
|
+
size = np.count_nonzero(~null_indicators)
|
|
142
|
+
|
|
143
|
+
if data_type == 1:
|
|
144
|
+
dtype = ">i4"
|
|
145
|
+
elif data_type == 3:
|
|
146
|
+
dtype = ">f4"
|
|
147
|
+
else:
|
|
148
|
+
raise Exception("Invalid data type: " + str(data_type))
|
|
149
|
+
values = np.frombuffer(buffer, dtype, count=size)
|
|
150
|
+
buffer = buffer[size * 4 :]
|
|
151
|
+
return values, null_indicators, buffer
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# Serialized data layout:
|
|
155
|
+
# +---------------+-----------------+-------------+
|
|
156
|
+
# | may have null | null indicators | values |
|
|
157
|
+
# +---------------+-----------------+-------------+
|
|
158
|
+
# | byte | list[byte] | list[byte] |
|
|
159
|
+
# +---------------+-----------------+-------------+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def read_byte_column(buffer, data_type, position_count):
|
|
163
|
+
if data_type != 0:
|
|
164
|
+
raise Exception("Invalid data type: " + data_type)
|
|
165
|
+
null_indicators, buffer = deserialize_null_indicators(buffer, position_count)
|
|
166
|
+
res, buffer = deserialize_from_boolean_array(buffer, position_count)
|
|
167
|
+
return res, null_indicators, buffer
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def deserialize_from_boolean_array(buffer, size):
|
|
171
|
+
num_bytes = (size + 7) // 8
|
|
172
|
+
packed_boolean_array, buffer = read_from_buffer(buffer, num_bytes)
|
|
173
|
+
arr = np.frombuffer(packed_boolean_array, dtype=np.uint8)
|
|
174
|
+
output = np.unpackbits(arr)[:size].astype(bool)
|
|
175
|
+
return output, buffer
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
# Serialized data layout:
|
|
179
|
+
# +---------------+-----------------+-------------+
|
|
180
|
+
# | may have null | null indicators | values |
|
|
181
|
+
# +---------------+-----------------+-------------+
|
|
182
|
+
# | byte | list[byte] | list[entry] |
|
|
183
|
+
# +---------------+-----------------+-------------+
|
|
184
|
+
#
|
|
185
|
+
# Each entry is represented as:
|
|
186
|
+
# +---------------+-------+
|
|
187
|
+
# | value length | value |
|
|
188
|
+
# +---------------+-------+
|
|
189
|
+
# | int32 | bytes |
|
|
190
|
+
# +---------------+-------+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def read_binary_column(buffer, data_type, position_count):
|
|
194
|
+
if data_type != 5:
|
|
195
|
+
raise Exception("Invalid data type: " + data_type)
|
|
196
|
+
null_indicators, buffer = deserialize_null_indicators(buffer, position_count)
|
|
197
|
+
|
|
198
|
+
if null_indicators is None:
|
|
199
|
+
size = position_count
|
|
200
|
+
else:
|
|
201
|
+
size = np.count_nonzero(~null_indicators)
|
|
202
|
+
values = np.empty(size, dtype=object)
|
|
203
|
+
for i in range(size):
|
|
204
|
+
length, buffer = read_int_from_buffer(buffer)
|
|
205
|
+
res, buffer = read_from_buffer(buffer, length)
|
|
206
|
+
values[i] = res.tobytes()
|
|
207
|
+
return values, null_indicators, buffer
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# Serialized data layout:
|
|
211
|
+
# +-----------+-------------------------+
|
|
212
|
+
# | encoding | serialized inner column |
|
|
213
|
+
# +-----------+-------------------------+
|
|
214
|
+
# | byte | list[byte] |
|
|
215
|
+
# +-----------+-------------------------+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def read_run_length_column(buffer, data_type, position_count):
|
|
219
|
+
encoding, buffer = read_byte_from_buffer(buffer)
|
|
220
|
+
column, null_indicators, buffer = read_column(encoding[0], buffer, data_type, 1)
|
|
221
|
+
return (
|
|
222
|
+
repeat(column, data_type, position_count),
|
|
223
|
+
(
|
|
224
|
+
None
|
|
225
|
+
if null_indicators is None
|
|
226
|
+
else np.full(position_count, null_indicators[0])
|
|
227
|
+
),
|
|
228
|
+
buffer,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def repeat(column, data_type, position_count):
|
|
233
|
+
if data_type in (0, 5):
|
|
234
|
+
if column.size == 1:
|
|
235
|
+
return np.full(
|
|
236
|
+
position_count, column[0], dtype=(bool if data_type == 0 else object)
|
|
237
|
+
)
|
|
238
|
+
else:
|
|
239
|
+
return np.array(column * position_count, dtype=object)
|
|
240
|
+
else:
|
|
241
|
+
res = bytearray()
|
|
242
|
+
for _ in range(position_count):
|
|
243
|
+
res.extend(column if isinstance(column, bytes) else bytes(column))
|
|
244
|
+
return bytes(res)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def read_dictionary_column(buffer, data_type, position_count):
|
|
248
|
+
raise Exception("dictionary column not implemented")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
ENCODING_FUNC_MAP = {
|
|
252
|
+
0: read_byte_column,
|
|
253
|
+
1: read_int32_column,
|
|
254
|
+
2: read_int64_column,
|
|
255
|
+
3: read_binary_column,
|
|
256
|
+
4: read_run_length_column,
|
|
257
|
+
5: read_dictionary_column,
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def read_column(encoding, buffer, data_type, position_count):
|
|
262
|
+
try:
|
|
263
|
+
func = ENCODING_FUNC_MAP[encoding]
|
|
264
|
+
except KeyError:
|
|
265
|
+
raise Exception("Unsupported encoding: " + str(encoding))
|
|
266
|
+
return func(buffer, data_type, position_count)
|
iotdb/utils/Field.py
CHANGED
|
@@ -18,18 +18,21 @@
|
|
|
18
18
|
|
|
19
19
|
# for package
|
|
20
20
|
from iotdb.utils.IoTDBConstants import TSDataType
|
|
21
|
-
from iotdb.tsfile.utils.
|
|
21
|
+
from iotdb.tsfile.utils.date_utils import parse_int_to_date
|
|
22
|
+
from iotdb.utils.rpc_utils import convert_to_timestamp, isoformat
|
|
22
23
|
import numpy as np
|
|
23
24
|
import pandas as pd
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class Field(object):
|
|
27
|
-
def __init__(self, data_type, value=None):
|
|
28
|
+
def __init__(self, data_type, value=None, timezone=None, precision=None):
|
|
28
29
|
"""
|
|
29
30
|
:param data_type: TSDataType
|
|
30
31
|
"""
|
|
31
32
|
self.__data_type = data_type
|
|
32
33
|
self.value = value
|
|
34
|
+
self.__timezone = timezone
|
|
35
|
+
self.__precision = precision
|
|
33
36
|
|
|
34
37
|
@staticmethod
|
|
35
38
|
def copy(field):
|
|
@@ -157,6 +160,17 @@ class Field(object):
|
|
|
157
160
|
return None
|
|
158
161
|
return self.value
|
|
159
162
|
|
|
163
|
+
def get_timestamp_value(self):
|
|
164
|
+
if self.__data_type is None:
|
|
165
|
+
raise Exception("Null Field Exception!")
|
|
166
|
+
if (
|
|
167
|
+
self.__data_type != TSDataType.TIMESTAMP
|
|
168
|
+
or self.value is None
|
|
169
|
+
or self.value is pd.NA
|
|
170
|
+
):
|
|
171
|
+
return None
|
|
172
|
+
return convert_to_timestamp(self.value, self.__precision, self.__timezone)
|
|
173
|
+
|
|
160
174
|
def get_date_value(self):
|
|
161
175
|
if self.__data_type is None:
|
|
162
176
|
raise Exception("Null Field Exception!")
|
|
@@ -172,11 +186,18 @@ class Field(object):
|
|
|
172
186
|
if self.__data_type is None or self.value is None or self.value is pd.NA:
|
|
173
187
|
return "None"
|
|
174
188
|
# TEXT, STRING
|
|
175
|
-
|
|
189
|
+
if self.__data_type == 5 or self.__data_type == 11:
|
|
176
190
|
return self.value.decode("utf-8")
|
|
177
191
|
# BLOB
|
|
178
192
|
elif self.__data_type == 10:
|
|
179
193
|
return str(hex(int.from_bytes(self.value, byteorder="big")))
|
|
194
|
+
# TIMESTAMP
|
|
195
|
+
elif self.__data_type == 8:
|
|
196
|
+
return isoformat(
|
|
197
|
+
convert_to_timestamp(self.value, self.__precision, self.__timezone),
|
|
198
|
+
self.__precision,
|
|
199
|
+
)
|
|
200
|
+
# Others
|
|
180
201
|
else:
|
|
181
202
|
return str(self.get_object_value(self.__data_type))
|
|
182
203
|
|
|
@@ -193,15 +214,19 @@ class Field(object):
|
|
|
193
214
|
return bool(self.value)
|
|
194
215
|
elif data_type == 1:
|
|
195
216
|
return np.int32(self.value)
|
|
196
|
-
elif data_type == 2
|
|
217
|
+
elif data_type == 2:
|
|
197
218
|
return np.int64(self.value)
|
|
198
219
|
elif data_type == 3:
|
|
199
220
|
return np.float32(self.value)
|
|
200
221
|
elif data_type == 4:
|
|
201
222
|
return np.float64(self.value)
|
|
223
|
+
elif data_type == 8:
|
|
224
|
+
return convert_to_timestamp(self.value, self.__precision, self.__timezone)
|
|
202
225
|
elif data_type == 9:
|
|
203
226
|
return parse_int_to_date(self.value)
|
|
204
|
-
elif data_type == 5 or data_type ==
|
|
227
|
+
elif data_type == 5 or data_type == 11:
|
|
228
|
+
return self.value.decode("utf-8")
|
|
229
|
+
elif data_type == 10:
|
|
205
230
|
return self.value
|
|
206
231
|
else:
|
|
207
232
|
raise RuntimeError("Unsupported data type:" + str(data_type))
|
iotdb/utils/NumpyTablet.py
CHANGED
|
@@ -22,7 +22,7 @@ import numpy as np
|
|
|
22
22
|
from numpy import ndarray
|
|
23
23
|
from typing import List
|
|
24
24
|
|
|
25
|
-
from iotdb.tsfile.utils.
|
|
25
|
+
from iotdb.tsfile.utils.date_utils import parse_date_to_int
|
|
26
26
|
from iotdb.utils.IoTDBConstants import TSDataType
|
|
27
27
|
from iotdb.utils.BitMap import BitMap
|
|
28
28
|
from iotdb.utils.Tablet import ColumnType
|
iotdb/utils/SessionDataSet.py
CHANGED
|
@@ -21,7 +21,7 @@ from iotdb.utils.Field import Field
|
|
|
21
21
|
|
|
22
22
|
# for package
|
|
23
23
|
from iotdb.utils.IoTDBConstants import TSDataType
|
|
24
|
-
from iotdb.utils.
|
|
24
|
+
from iotdb.utils.iotdb_rpc_dataset import IoTDBRpcDataSet
|
|
25
25
|
from iotdb.utils.RowRecord import RowRecord
|
|
26
26
|
|
|
27
27
|
import pandas as pd
|
|
@@ -37,40 +37,51 @@ class SessionDataSet(object):
|
|
|
37
37
|
column_type_list,
|
|
38
38
|
column_name_index,
|
|
39
39
|
query_id,
|
|
40
|
-
client,
|
|
41
40
|
statement_id,
|
|
41
|
+
client,
|
|
42
42
|
session_id,
|
|
43
|
-
|
|
43
|
+
query_result,
|
|
44
44
|
ignore_timestamp,
|
|
45
|
+
time_out,
|
|
46
|
+
more_data,
|
|
47
|
+
fetch_size,
|
|
48
|
+
zone_id,
|
|
49
|
+
time_precision,
|
|
50
|
+
column_index_2_tsblock_column_index_list,
|
|
45
51
|
):
|
|
46
52
|
self.iotdb_rpc_data_set = IoTDBRpcDataSet(
|
|
47
53
|
sql,
|
|
48
54
|
column_name_list,
|
|
49
55
|
column_type_list,
|
|
50
|
-
column_name_index,
|
|
51
56
|
ignore_timestamp,
|
|
57
|
+
more_data,
|
|
52
58
|
query_id,
|
|
53
59
|
client,
|
|
54
60
|
statement_id,
|
|
55
61
|
session_id,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
self.column_ordinal_dict = self.iotdb_rpc_data_set.column_ordinal_dict
|
|
63
|
-
self.column_type_deduplicated_list = tuple(
|
|
64
|
-
self.iotdb_rpc_data_set.column_type_deduplicated_list
|
|
62
|
+
query_result,
|
|
63
|
+
fetch_size,
|
|
64
|
+
time_out,
|
|
65
|
+
zone_id,
|
|
66
|
+
time_precision,
|
|
67
|
+
column_index_2_tsblock_column_index_list,
|
|
65
68
|
)
|
|
66
|
-
if
|
|
69
|
+
if ignore_timestamp:
|
|
67
70
|
self.__field_list = [
|
|
68
|
-
|
|
71
|
+
(
|
|
72
|
+
Field(data_type, timezone=zone_id, precision=time_precision)
|
|
73
|
+
if data_type == 8
|
|
74
|
+
else Field(data_type)
|
|
75
|
+
)
|
|
69
76
|
for data_type in self.iotdb_rpc_data_set.get_column_types()
|
|
70
77
|
]
|
|
71
78
|
else:
|
|
72
79
|
self.__field_list = [
|
|
73
|
-
|
|
80
|
+
(
|
|
81
|
+
Field(data_type, timezone=zone_id, precision=time_precision)
|
|
82
|
+
if data_type == 8
|
|
83
|
+
else Field(data_type)
|
|
84
|
+
)
|
|
74
85
|
for data_type in self.iotdb_rpc_data_set.get_column_types()[1:]
|
|
75
86
|
]
|
|
76
87
|
self.row_index = 0
|
|
@@ -105,14 +116,22 @@ class SessionDataSet(object):
|
|
|
105
116
|
def construct_row_record_from_data_frame(self):
|
|
106
117
|
df = self.iotdb_rpc_data_set.data_frame
|
|
107
118
|
row = df.iloc[self.row_index].to_list()
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
if self.iotdb_rpc_data_set.ignore_timestamp:
|
|
120
|
+
for field, value in zip(self.__field_list, row):
|
|
121
|
+
field.value = value
|
|
122
|
+
|
|
123
|
+
row_record = RowRecord(
|
|
124
|
+
0,
|
|
125
|
+
self.__field_list,
|
|
126
|
+
)
|
|
127
|
+
else:
|
|
128
|
+
for field, value in zip(self.__field_list, row[1:]):
|
|
129
|
+
field.value = value
|
|
111
130
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
row_record = RowRecord(
|
|
132
|
+
row[0],
|
|
133
|
+
self.__field_list,
|
|
134
|
+
)
|
|
116
135
|
self.row_index += 1
|
|
117
136
|
if self.row_index == len(df):
|
|
118
137
|
self.row_index = 0
|
|
@@ -147,7 +166,7 @@ def get_typed_point(field: Field, none_value=None):
|
|
|
147
166
|
TSDataType.INT32: lambda f: f.get_int_value(),
|
|
148
167
|
TSDataType.DOUBLE: lambda f: f.get_double_value(),
|
|
149
168
|
TSDataType.INT64: lambda f: f.get_long_value(),
|
|
150
|
-
TSDataType.TIMESTAMP: lambda f: f.
|
|
169
|
+
TSDataType.TIMESTAMP: lambda f: f.get_timestamp_value(),
|
|
151
170
|
TSDataType.STRING: lambda f: f.get_string_value(),
|
|
152
171
|
TSDataType.DATE: lambda f: f.get_date_value(),
|
|
153
172
|
TSDataType.BLOB: lambda f: f.get_binary_value(),
|
iotdb/utils/Tablet.py
CHANGED
|
@@ -20,7 +20,7 @@ import struct
|
|
|
20
20
|
from enum import unique, IntEnum
|
|
21
21
|
from typing import List, Union
|
|
22
22
|
|
|
23
|
-
from iotdb.tsfile.utils.
|
|
23
|
+
from iotdb.tsfile.utils.date_utils import parse_date_to_int
|
|
24
24
|
from iotdb.utils.BitMap import BitMap
|
|
25
25
|
from iotdb.utils.IoTDBConstants import TSDataType
|
|
26
26
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
# specific language governing permissions and limitations
|
|
16
16
|
# under the License.
|
|
17
17
|
#
|
|
18
|
+
from iotdb.thrift.common.ttypes import TEndPoint, TSStatus
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
class IoTDBConnectionException(Exception):
|
|
@@ -27,3 +28,22 @@ class IoTDBConnectionException(Exception):
|
|
|
27
28
|
super().__init__(message, cause)
|
|
28
29
|
else:
|
|
29
30
|
super().__init__()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class StatementExecutionException(Exception):
|
|
34
|
+
def __init__(self, status: TSStatus = None, message=None):
|
|
35
|
+
if status is not None:
|
|
36
|
+
super().__init__(f"{status.code}: {status.message}")
|
|
37
|
+
elif message is not None:
|
|
38
|
+
super().__init__(message)
|
|
39
|
+
else:
|
|
40
|
+
super().__init__()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class RedirectException(Exception):
|
|
44
|
+
def __init__(self, redirect_info):
|
|
45
|
+
Exception.__init__(self)
|
|
46
|
+
if isinstance(redirect_info, TEndPoint):
|
|
47
|
+
self.redirect_node = redirect_info
|
|
48
|
+
else:
|
|
49
|
+
self.device_to_endpoint = redirect_info
|