This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch try_TBinaryProtocolAccelerated
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/try_TBinaryProtocolAccelerated 
by this push:
     new 285d1febb94 Use more intenum
285d1febb94 is described below

commit 285d1febb948136f98183da963a75cfc027b6547
Author: HTHou <[email protected]>
AuthorDate: Mon Sep 25 21:16:43 2023 +0800

    Use more intenum
---
 iotdb-client/client-py/iotdb/Session.py            | 34 +++++-----------------
 .../client-py/iotdb/utils/IoTDBConstants.py        | 24 ---------------
 iotdb-client/client-py/iotdb/utils/NumpyTablet.py  |  4 +--
 iotdb-client/client-py/iotdb/utils/Tablet.py       |  3 +-
 4 files changed, 10 insertions(+), 55 deletions(-)

diff --git a/iotdb-client/client-py/iotdb/Session.py 
b/iotdb-client/client-py/iotdb/Session.py
index e169b143244..af4ead9dd52 100644
--- a/iotdb-client/client-py/iotdb/Session.py
+++ b/iotdb-client/client-py/iotdb/Session.py
@@ -59,8 +59,6 @@ from .thrift.rpc.ttypes import (
 )
 from .utils.IoTDBConnectionException import IoTDBConnectionException
 
-from .utils.IoTDBConstants import TSDataType
-
 logger = logging.getLogger("IoTDB")
 
 
@@ -310,9 +308,6 @@ class Session(object):
         :param attributes: Dictionary, attribute map for time series
         :param alias: String, measurement alias for time series
         """
-        data_type = int(data_type)
-        encoding = int(encoding)
-        compressor = int(compressor)
         request = TSCreateTimeseriesReq(
             self.__session_id,
             ts_path,
@@ -349,9 +344,6 @@ class Session(object):
         :param encoding_lst: List of TSEncoding, encodings for time series
         :param compressor_lst: List of Compressor, compressing types for time 
series
         """
-        data_type_lst = [int(data_type) for data_type in data_type_lst]
-        encoding_lst = [int(encoding) for encoding in encoding_lst]
-        compressor_lst = [int(compressor) for compressor in compressor_lst]
 
         request = TSCreateAlignedTimeseriesReq(
             self.__session_id,
@@ -399,9 +391,6 @@ class Session(object):
         :param attributes_lst: List of attribute Dictionary, attribute maps 
for time series
         :param alias_lst: List of alias, measurement alias for time series
         """
-        data_type_lst = [int(data_type) for data_type in data_type_lst]
-        encoding_lst = [int(encoding) for encoding in encoding_lst]
-        compressor_lst = [int(compressor) for compressor in compressor_lst]
 
         request = TSCreateMultiTimeseriesReq(
             self.__session_id,
@@ -936,10 +925,7 @@ class Session(object):
                 
request.measurementsList.append(tablet_lst[i].get_measurements())
                 request.valuesList.append(tablet_lst[i].get_binary_values())
                 request.sizeList.append(tablet_lst[i].get_row_number())
-                data_type_values = [
-                    int(data_type) for data_type in 
tablet_lst[i].get_data_types()
-                ]
-                request.typesList.append(data_type_values)
+                request.typesList.append(tablet_lst[i].get_data_types())
             for client, request in request_group.items():
                 try:
                     Session.verify_success_with_redirection_for_multi_devices(
@@ -1030,10 +1016,7 @@ class Session(object):
                 
request.measurementsList.append(tablet_lst[i].get_measurements())
                 request.valuesList.append(tablet_lst[i].get_binary_values())
                 request.sizeList.append(tablet_lst[i].get_row_number())
-                data_type_values = [
-                    int(data_type) for data_type in 
tablet_lst[i].get_data_types()
-                ]
-                request.typesList.append(data_type_values)
+                request.typesList.append(tablet_lst[i].get_data_types())
             for client, request in request_group.items():
                 try:
                     Session.verify_success_with_redirection_for_multi_devices(
@@ -1287,14 +1270,13 @@ class Session(object):
                 raise IoTDBConnectionException(self.connection_error_msg()) 
from None
 
     def gen_insert_tablet_req(self, tablet, is_aligned=False):
-        data_type_values = [int(data_type) for data_type in 
tablet.get_data_types()]
         return TSInsertTabletReq(
             self.__session_id,
             tablet.get_device_id(),
             tablet.get_measurements(),
             tablet.get_binary_values(),
             tablet.get_binary_timestamps(),
-            data_type_values,
+            tablet.get_data_types(),
             tablet.get_row_number(),
             is_aligned,
         )
@@ -1307,12 +1289,11 @@ class Session(object):
         type_lst = []
         size_lst = []
         for tablet in tablet_lst:
-            data_type_values = [int(data_type) for data_type in 
tablet.get_data_types()]
             device_id_lst.append(tablet.get_device_id())
             measurements_lst.append(tablet.get_measurements())
             values_lst.append(tablet.get_binary_values())
             timestamps_lst.append(tablet.get_binary_timestamps())
-            type_lst.append(data_type_values)
+            type_lst.append(tablet.get_data_types())
             size_lst.append(tablet.get_row_number())
         return TSInsertTabletsReq(
             self.__session_id,
@@ -1422,7 +1403,6 @@ class Session(object):
         format_str_list = [">"]
         values_tobe_packed = []
         for data_type, value in zip(data_types, values):
-            data_type = int(data_type)
             # BOOLEAN
             if data_type == 0:
                 format_str_list.append("c?")
@@ -1896,9 +1876,9 @@ class Session(object):
             template_name,
             is_aligned,
             measurements_path,
-            list(map(lambda x: int(x), data_types)),
-            list(map(lambda x: int(x), encodings)),
-            list(map(lambda x: int(x), compressors)),
+            data_types,
+            encodings,
+            compressors,
         )
         try:
             return 
Session.verify_success(self.__client.appendSchemaTemplate(request))
diff --git a/iotdb-client/client-py/iotdb/utils/IoTDBConstants.py 
b/iotdb-client/client-py/iotdb/utils/IoTDBConstants.py
index 6f38d1d7664..9b671663ff4 100644
--- a/iotdb-client/client-py/iotdb/utils/IoTDBConstants.py
+++ b/iotdb-client/client-py/iotdb/utils/IoTDBConstants.py
@@ -28,14 +28,6 @@ class TSDataType(IntEnum):
     DOUBLE = 4
     TEXT = 5
 
-    # this method is implemented to avoid the issue reported by:
-    # https://bugs.python.org/issue30545
-    def __eq__(self, other) -> bool:
-        return self.value == other.value
-
-    def __hash__(self):
-        return self.value
-
     def np_dtype(self):
         return {
             TSDataType.BOOLEAN: np.dtype(">?"),
@@ -63,14 +55,6 @@ class TSEncoding(IntEnum):
     SPRINTZ = 12
     RLBE = 13
 
-    # this method is implemented to avoid the issue reported by:
-    # https://bugs.python.org/issue30545
-    def __eq__(self, other) -> bool:
-        return self.value == other.value
-
-    def __hash__(self):
-        return self.value
-
 
 @unique
 class Compressor(IntEnum):
@@ -84,11 +68,3 @@ class Compressor(IntEnum):
     LZ4 = 7
     ZSTD = 8
     LZMA2 = 9
-
-    # this method is implemented to avoid the issue reported by:
-    # https://bugs.python.org/issue30545
-    def __eq__(self, other) -> bool:
-        return self.value == other.value
-
-    def __hash__(self):
-        return self.value
diff --git a/iotdb-client/client-py/iotdb/utils/NumpyTablet.py 
b/iotdb-client/client-py/iotdb/utils/NumpyTablet.py
index 4841cf0e473..4577f7f880c 100644
--- a/iotdb-client/client-py/iotdb/utils/NumpyTablet.py
+++ b/iotdb-client/client-py/iotdb/utils/NumpyTablet.py
@@ -101,9 +101,9 @@ class NumpyTablet(object):
     def get_binary_values(self):
         bs_len = 0
         bs_list = []
-        for i, value in enumerate(self.__values):
+        for data_type, value in zip(self.__data_types, self.__values):
             # TEXT
-            if int(self.__data_types[i]) == 5:
+            if data_type == 5:
                 format_str_list = [">"]
                 values_tobe_packed = []
                 for str_list in value:
diff --git a/iotdb-client/client-py/iotdb/utils/Tablet.py 
b/iotdb-client/client-py/iotdb/utils/Tablet.py
index 2ee018351aa..508361dc857 100644
--- a/iotdb-client/client-py/iotdb/utils/Tablet.py
+++ b/iotdb-client/client-py/iotdb/utils/Tablet.py
@@ -18,7 +18,6 @@
 
 import struct
 
-from iotdb.utils.IoTDBConstants import TSDataType
 from iotdb.utils.BitMap import BitMap
 
 
@@ -95,7 +94,7 @@ class Tablet(object):
         for i in range(self.__column_number):
             bitmap = None
             bitmaps.append(bitmap)
-            data_type_value = int(self.__data_types[i])
+            data_type_value = self.__data_types[i]
             if data_type_value == 0:
                 format_str_list.append(str(self.__row_number))
                 format_str_list.append("?")

Reply via email to