You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/03/06 07:00:03 UTC

[iotdb] 01/01: Support insert bytes by Python API

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

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

commit 5c19e28534260f12b6f7ddd1ca9411a4161219b4
Author: HTHou <hh...@outlook.com>
AuthorDate: Mon Mar 6 14:58:53 2023 +0800

    Support insert bytes by Python API
---
 client-py/iotdb/Session.py           | 5 ++++-
 client-py/iotdb/utils/NumpyTablet.py | 5 ++++-
 client-py/iotdb/utils/Tablet.py      | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/client-py/iotdb/Session.py b/client-py/iotdb/Session.py
index 0dc516ce2f..c32ecc8b34 100644
--- a/client-py/iotdb/Session.py
+++ b/client-py/iotdb/Session.py
@@ -999,7 +999,10 @@ class Session(object):
                 values_tobe_packed.append(bytes([TSDataType.DOUBLE.value]))
                 values_tobe_packed.append(value)
             elif data_type == TSDataType.TEXT.value:
-                value_bytes = bytes(value, "utf-8")
+                if isinstance(value, str):
+                    value_bytes = bytes(value, "utf-8")
+                else:
+                    value_bytes = value
                 format_str_list.append("c")
                 format_str_list.append("i")
                 format_str_list.append(str(len(value_bytes)))
diff --git a/client-py/iotdb/utils/NumpyTablet.py b/client-py/iotdb/utils/NumpyTablet.py
index b217841f74..7315b872e5 100644
--- a/client-py/iotdb/utils/NumpyTablet.py
+++ b/client-py/iotdb/utils/NumpyTablet.py
@@ -105,7 +105,10 @@ class NumpyTablet(object):
                 values_tobe_packed = []
                 for str_list in value:
                     # Fot TEXT, it's same as the original solution
-                    value_bytes = bytes(str_list, "utf-8")
+                    if isinstance(str_list, str):
+                        value_bytes = bytes(str_list, "utf-8")
+                    else:
+                        value_bytes = str_list
                     format_str_list.append("i")
                     format_str_list.append(str(len(value_bytes)))
                     format_str_list.append("s")
diff --git a/client-py/iotdb/utils/Tablet.py b/client-py/iotdb/utils/Tablet.py
index 58fc84603a..61a3e1d926 100644
--- a/client-py/iotdb/utils/Tablet.py
+++ b/client-py/iotdb/utils/Tablet.py
@@ -153,7 +153,10 @@ class Tablet(object):
             elif self.__data_types[i] == TSDataType.TEXT:
                 for j in range(self.__row_number):
                     if self.__values[j][i] is not None:
-                        value_bytes = bytes(self.__values[j][i], "utf-8")
+                        if isinstance(self.__values[j][i], str):
+                            value_bytes = bytes(self.__values[j][i], "utf-8")
+                        else:
+                            value_bytes = self.__values[j][i]
                         format_str_list.append("i")
                         format_str_list.append(str(len(value_bytes)))
                         format_str_list.append("s")