You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/11/05 04:42:32 UTC

[incubator-iotdb] 01/01: fix that strings int the python example should be cast to bytes

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

jiangtian pushed a commit to branch fix_python_example
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 4196696355cda8119802165cb5857a2a6a07ff18
Author: jt2594838 <jt...@163.com>
AuthorDate: Tue Nov 5 12:41:09 2019 +0800

    fix that strings int the python example should be cast to bytes
---
 client-py/src/client_example.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/client-py/src/client_example.py b/client-py/src/client_example.py
index 3bf7567..2d4188b 100644
--- a/client-py/src/client_example.py
+++ b/client-py/src/client_example.py
@@ -79,7 +79,7 @@ def convertQueryDataSet(queryDataSet, dataTypeList):
                 records[j].append('null')
             else:
                 if type == 'BOOLEAN':
-                    value = value_bytes[0]
+                    value = value_bytes[:1]
                     value_bytes = value_bytes[1:]
                     records[j].append(struct.unpack('>?', value)[0])
                 elif type == 'INT32':
@@ -201,10 +201,15 @@ if __name__ == '__main__':
     # IoTDB use big endian in rpc
     value_pack_str = '>3q3i3d3f3bi7si7si7s'
     time_pack_str = '>3q'
+    encoding = 'utf-8'
     values.extend(struct.pack(value_pack_str, 2, 3, 4, 22, 33, 44, 2.2, 3.3,
                               4.4, 22.2, 33.3, 44.4, True, True, False,
-                              len('\'text1\''), '\'text1\'', len('\'text2\''),
-                              '\'text2\'', len('\'text3\''), '\'text3\''))
+                              len(bytes('\'text1\'', encoding)),
+                              bytes('\'text1\'', encoding),
+                              len(bytes('\'text2\'', encoding)),
+                              bytes('\'text2\'', encoding),
+                              len(bytes('\'text3\'', encoding)),
+                              bytes('\'text3\'', encoding)))
     times.extend(struct.pack(time_pack_str, 2, 3, 4))
     resp = client.insertBatch(TSBatchInsertionReq(deviceId, measurements, values,
                                                   times, dataTypes, rowCnt))