You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ka...@apache.org on 2021/06/17 02:59:27 UTC

[iotdb] branch f_py_cli_opt updated: add

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

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


The following commit(s) were added to refs/heads/f_py_cli_opt by this push:
     new 246592f  add
246592f is described below

commit 246592fba4200e9a0aeb24a16d63714d95a4b5f0
Author: kr11 <3095717866.com>
AuthorDate: Thu Jun 17 10:58:57 2021 +0800

    add
---
 client-py/SessionInsertRecord.py                   | 123 +++++++++++++++++++++
 client-py/SessionInsertTablet.py                   |  85 ++++++++++++++
 client-py/TabletOptimizeAssert.py                  |  85 ++++++++++++++
 client-py/TabletOriginalAssert.py                  |  85 ++++++++++++++
 client-py/TestIOTDb.py                             | 104 +++++++++++++++++
 client-py/debugInsertRecord.py                     |  28 +++++
 client-py/iotdb/Session.py                         |  10 +-
 client-py/iotdb/utils/IoTDBConstants.py            |   3 +
 client-py/iotdb/utils/Tablet.py                    | 111 +++++++++++--------
 client-py/main.py                                  |  22 ++++
 .../main/java/org/apache/iotdb/TestSession.java    | 100 +++++++++++++++++
 11 files changed, 707 insertions(+), 49 deletions(-)

diff --git a/client-py/SessionInsertRecord.py b/client-py/SessionInsertRecord.py
new file mode 100644
index 0000000..5458c60
--- /dev/null
+++ b/client-py/SessionInsertRecord.py
@@ -0,0 +1,123 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Uncomment the following line to use apache-iotdb module installed by pip3
+
+from iotdb.Session import Session
+from iotdb.utils.IoTDBConstants import TSDataType, TSEncoding, Compressor
+from iotdb.utils.Tablet import Tablet
+
+# creating session connection.
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = "root"
+password_ = "root"
+session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+session.open(False)
+
+# set and delete storage groups
+session.set_storage_group("root.sg_test_01")
+session.set_storage_group("root.sg_test_02")
+session.set_storage_group("root.sg_test_03")
+session.set_storage_group("root.sg_test_04")
+session.delete_storage_group("root.sg_test_02")
+session.delete_storage_groups(["root.sg_test_03", "root.sg_test_04"])
+
+# setting time series.
+session.create_time_series(
+    "root.sg_test_01.d_01.s_01", TSDataType.BOOLEAN, TSEncoding.PLAIN, Compressor.SNAPPY
+)
+session.create_time_series(
+    "root.sg_test_01.d_01.s_02", TSDataType.INT32, TSEncoding.PLAIN, Compressor.SNAPPY
+)
+session.create_time_series(
+    "root.sg_test_01.d_01.s_03", TSDataType.INT64, TSEncoding.PLAIN, Compressor.SNAPPY
+)
+
+# setting multiple time series once.
+ts_path_lst_ = [
+    "root.sg_test_01.d_01.s_04",
+    "root.sg_test_01.d_01.s_05",
+    "root.sg_test_01.d_01.s_06",
+    "root.sg_test_01.d_01.s_07",
+    "root.sg_test_01.d_01.s_08",
+    "root.sg_test_01.d_01.s_09",
+]
+data_type_lst_ = [
+    TSDataType.FLOAT,
+    TSDataType.DOUBLE,
+    TSDataType.TEXT,
+    TSDataType.FLOAT,
+    TSDataType.DOUBLE,
+    TSDataType.TEXT,
+]
+encoding_lst_ = [TSEncoding.PLAIN for _ in range(len(data_type_lst_))]
+compressor_lst_ = [Compressor.SNAPPY for _ in range(len(data_type_lst_))]
+session.create_multi_time_series(
+    ts_path_lst_, data_type_lst_, encoding_lst_, compressor_lst_
+)
+
+# delete time series
+session.delete_time_series(
+    [
+        "root.sg_test_01.d_01.s_07",
+        "root.sg_test_01.d_01.s_08",
+        "root.sg_test_01.d_01.s_09",
+    ]
+)
+
+# checking time series
+print(
+    "s_07 expecting False, checking result: ",
+    session.check_time_series_exists("root.sg_test_01.d_01.s_07"),
+)
+print(
+    "s_03 expecting True, checking result: ",
+    session.check_time_series_exists("root.sg_test_01.d_01.s_03"),
+)
+
+# insert one record into the database.
+measurements_ = ["s_01", "s_02", "s_03", "s_04", "s_05", "s_06"]
+values_ = [False, 10, 11, 1.1, 10011.1, "test_record"]
+data_types_ = [
+    TSDataType.BOOLEAN,
+    TSDataType.INT32,
+    TSDataType.INT64,
+    TSDataType.FLOAT,
+    TSDataType.DOUBLE,
+    TSDataType.TEXT,
+]
+
+import time
+
+st = time.perf_counter()
+last_time = st
+total_count = 1_000_000
+
+for i in range(total_count):
+    if i % 10000 == 0:
+        now = time.perf_counter()
+        print("write %d, use time: %.3f" % (i, now - last_time))
+        last_time = now
+    session.insert_record("root.sg_test_01.d_01", i, measurements_, data_types_, values_)
+end = time.perf_counter()
+# close session connection.
+session.close()
+
+print("All executions done!!")
+print("write %d, total time: %.3f" % (total_count, end - st))
diff --git a/client-py/SessionInsertTablet.py b/client-py/SessionInsertTablet.py
new file mode 100644
index 0000000..0dd2758
--- /dev/null
+++ b/client-py/SessionInsertTablet.py
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Uncomment the following line to use apache-iotdb module installed by pip3
+
+from iotdb.Session import Session
+from iotdb.utils.IoTDBConstants import TSDataType, TSEncoding, Compressor, UseNew
+from iotdb.utils.Tablet import Tablet
+import random
+import numpy as np
+from numba import jit
+# creating session connection.
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = "root"
+password_ = "root"
+session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+session.open(False)
+import time
+
+st = time.perf_counter()
+
+@jit
+def run():
+    random.seed(a=0, version=2)
+    insertCost = 0
+    for i in range(2000, 4000):
+        deviceId = "root.sg%d.%d" % (i % 8, i)
+        measurements_ = ["s1",
+                         # "is_true"
+                         ]
+        data_types_ = [
+            TSDataType.FLOAT,
+            # TSDataType.BOOLEAN,
+        ]
+
+        rowSize = 10080
+        # rowSize = 5080
+        if not UseNew:
+            timestamps_ = []
+            values_ = []
+            # for t in range(0, 10080):
+            for t in range(0, rowSize):
+                timestamps_.append(t)
+                # values_.append([-2 + 6 * random.random(), True])
+                values_.append([-2 + 6 * 0.5
+                                   # , True
+                                ])
+        else:
+            timestamps_ = np.zeros(rowSize, dtype='>q')
+            values_ = np.zeros(rowSize, dtype='>f')
+            # for t in range(0, 10080):
+            for t in range(0, rowSize):
+                timestamps_[t] = t
+                values_[t] = -2 + 6 * 0.5
+                # values_.append([-2 + 6 * random.random(), True])
+
+        tablet_ = Tablet(deviceId, measurements_, data_types_, values_, timestamps_)
+        cost_st = time.perf_counter()
+        session.insert_tablet(tablet_)
+        insertCost += time.perf_counter() - cost_st
+
+    session.close()
+    end = time.perf_counter()
+
+    print("All executions done!!")
+    print("use time: %.3f" % (end - st))
+    print("insert time: %.3f" % insertCost)
+
+run()
\ No newline at end of file
diff --git a/client-py/TabletOptimizeAssert.py b/client-py/TabletOptimizeAssert.py
new file mode 100644
index 0000000..98bb02f
--- /dev/null
+++ b/client-py/TabletOptimizeAssert.py
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Uncomment the following line to use apache-iotdb module installed by pip3
+
+from iotdb.Session import Session
+from iotdb.utils.IoTDBConstants import TSDataType, TSEncoding, Compressor, UseNew
+from iotdb.utils.Tablet import Tablet
+import random
+import numpy as np
+from numba import jit
+
+# creating session connection.
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = "root"
+password_ = "root"
+session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+session.open(False)
+import time
+
+# parameters for test
+row_size = 10000
+column_size = 2000
+
+
+measurements_ = ["s_01", "s_02", "s_03", "s_04", "s_05", "s_06"]
+data_types_ = [
+    TSDataType.BOOLEAN,
+    TSDataType.INT32,
+    TSDataType.INT64,
+    TSDataType.FLOAT,
+    TSDataType.DOUBLE,
+    TSDataType.TEXT,
+]
+one_value = [False, 10, 11, 1.1, 10011.1, "test_record"]
+
+insert_cost = 0
+st = time.perf_counter()
+for i in range(0, column_size):
+    device_id = "root.sg%d.%d" % (i % 8, i)
+    timestamps_ = []
+    values_ = []
+    for t in range(0, row_size):
+        timestamps_.append(t)
+        # values_.append([-2 + 6 * random.random(), True])
+        values_.append(one_value)
+
+    tablet_ = Tablet(device_id, measurements_, data_types_, values_, timestamps_)
+    cost_st = time.perf_counter()
+    session.insert_tablet(tablet_)
+    insert_cost += time.perf_counter() - cost_st
+
+end = time.perf_counter()
+print("use time: %.3f" % (end - st))
+print("insert time: %.3f" % insert_cost)
+print("All executions done!!")
+# assert
+for i in range(0, column_size):
+    device_id = "root.sg%d.%d" % (i % 8, i)
+
+    session_data_set = session.execute_query_statement("select * from " + device_id)
+    session_data_set.set_fetch_size(row_size)
+    while session_data_set.has_next():
+        print(session_data_set.next())
+    session_data_set.close_operation_handle()
+
+session.close()
+
+print("Assert successfully")
diff --git a/client-py/TabletOriginalAssert.py b/client-py/TabletOriginalAssert.py
new file mode 100644
index 0000000..98bb02f
--- /dev/null
+++ b/client-py/TabletOriginalAssert.py
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Uncomment the following line to use apache-iotdb module installed by pip3
+
+from iotdb.Session import Session
+from iotdb.utils.IoTDBConstants import TSDataType, TSEncoding, Compressor, UseNew
+from iotdb.utils.Tablet import Tablet
+import random
+import numpy as np
+from numba import jit
+
+# creating session connection.
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = "root"
+password_ = "root"
+session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+session.open(False)
+import time
+
+# parameters for test
+row_size = 10000
+column_size = 2000
+
+
+measurements_ = ["s_01", "s_02", "s_03", "s_04", "s_05", "s_06"]
+data_types_ = [
+    TSDataType.BOOLEAN,
+    TSDataType.INT32,
+    TSDataType.INT64,
+    TSDataType.FLOAT,
+    TSDataType.DOUBLE,
+    TSDataType.TEXT,
+]
+one_value = [False, 10, 11, 1.1, 10011.1, "test_record"]
+
+insert_cost = 0
+st = time.perf_counter()
+for i in range(0, column_size):
+    device_id = "root.sg%d.%d" % (i % 8, i)
+    timestamps_ = []
+    values_ = []
+    for t in range(0, row_size):
+        timestamps_.append(t)
+        # values_.append([-2 + 6 * random.random(), True])
+        values_.append(one_value)
+
+    tablet_ = Tablet(device_id, measurements_, data_types_, values_, timestamps_)
+    cost_st = time.perf_counter()
+    session.insert_tablet(tablet_)
+    insert_cost += time.perf_counter() - cost_st
+
+end = time.perf_counter()
+print("use time: %.3f" % (end - st))
+print("insert time: %.3f" % insert_cost)
+print("All executions done!!")
+# assert
+for i in range(0, column_size):
+    device_id = "root.sg%d.%d" % (i % 8, i)
+
+    session_data_set = session.execute_query_statement("select * from " + device_id)
+    session_data_set.set_fetch_size(row_size)
+    while session_data_set.has_next():
+        print(session_data_set.next())
+    session_data_set.close_operation_handle()
+
+session.close()
+
+print("Assert successfully")
diff --git a/client-py/TestIOTDb.py b/client-py/TestIOTDb.py
new file mode 100644
index 0000000..d1d1e19
--- /dev/null
+++ b/client-py/TestIOTDb.py
@@ -0,0 +1,104 @@
+# import argparse
+# import datetime
+# import random
+#
+# import numpy
+# import pandas as pd
+# import time
+#
+# from iotdb.Session import Session
+#
+# from iotdb.utils.IoTDBConstants import TSDataType
+# from iotdb.utils.Tablet import Tablet
+#
+# # from mertic.utils.iotdb_helper import resultset_to_pandas
+# # from mertic.common import setting
+# from datetime import datetime
+# import time
+#
+# def insertRecordData():
+#     # session = setting.get_IoTDB_session()
+#     ip = "127.0.0.1"
+#     port_ = "6667"
+#     username_ = "root"
+#     password_ = "root"
+#     session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+#     session.open(False)
+#     listtablet = []
+#     for i in range(2000, 4000):
+#         sgnum = int(i) % 8
+#         k = 0
+#         time = 1621250000 + i
+#         json_body = [
+#         ]
+#         tsd=[]
+#         for t in range(10080):
+#             k = k + 1
+#             time = 1621250000 + k * 60
+#             subtsd = []
+#
+#             subtsd.append(int(time*1000))
+#             subtsd.append(random.uniform(-2, 4))
+#             subtsd.append(True)
+#             tsd.append(subtsd)
+#
+#         # print(tsd[:,0])
+#         # break
+#         tsd=numpy.array(tsd)
+#         device_id = "root.sg" + str(sgnum) + "." + str(i)
+#         measurements = [setting.LABEL_TSD_VALUE, setting.LABEL_TSD_ISTRUE]
+#         data_types = [TSDataType.FLOAT, TSDataType.BOOLEAN]
+#         values = numpy.array(tsd)[:, 1:]
+#         times = [int(x) for x in tsd[:, 0]]
+#         tablet=Tablet(device_id,measurements,data_types,values,times)
+#
+#         listtablet.append(tablet)
+#
+#         session.insert_tablets(listtablet)
+#         listtablet=[]
+#
+#         # session.insert_records(["root.sg"+str(sgnum)+"."+str(i)]*len(tsd),
+#         #                     [int(x) for x in tsd[:,0]],
+#         #                     [[setting.LABEL_TSD_VALUE, setting.LABEL_TSD_ISTRUE]]*len(tsd),
+#         #                     [[TSDataType.FLOAT, TSDataType.BOOLEAN]]*len(tsd),
+#         #                     numpy.array(tsd)[:,1:])
+#
+#     session.close()
+#
+#
+#
+# def testiotdb():
+#     session = setting.get_IoTDB_session()
+#     session.open(False)
+#     metric_meta_data = session.execute_query_statement(
+#         "select metricID, LastUpdateTime, grain, LastTimeofLocal from root.meta")
+#     metric_meta_data = resultset_to_pandas(metric_meta_data)
+#     del metric_meta_data['Time']
+#     metric_meta_data.columns = [setting.LABEL_METRIC_ID, setting.LABEL_METRIC_LASTUPDATETIME, setting.LABEL_TSD_GRAIN,
+#                                 setting.LABEL_METRIC_LASTTIMEOFLOCAL]
+#     session.close()
+# def queryData():
+#
+#     for i in range(2000,4000):
+#         session = setting.get_IoTDB_session()
+#         session.open(False)
+#         sgnum = int(i) % 8
+#
+#         metric_meta_data = session.execute_query_statement(
+#             "select time,value,is_true from root.sg"+str(sgnum)+"."+str(i))
+#         # metric_meta_data = resultset_to_pandas(metric_meta_data)
+#         # print(metric_meta_data)
+#         print(i)
+#         session.close()
+#
+# if __name__ == '__main__':
+#     #args = parse_args()
+#     #main(host=args.host, port=args.port)
+#     #insertData()
+#     #queryData(0,2000,1619193180000,1619193180000)
+#     a = datetime.now()  # 获得当前时间
+#     insertRecordData()
+#     b = datetime.now()  # 获取当前时间
+#     durn = (b - a).seconds  # 两个时间差,并以秒显示出来
+#     print(durn)
+#     print("--------")
\ No newline at end of file
diff --git a/client-py/debugInsertRecord.py b/client-py/debugInsertRecord.py
new file mode 100644
index 0000000..6d8d0e7
--- /dev/null
+++ b/client-py/debugInsertRecord.py
@@ -0,0 +1,28 @@
+from iotdb.Session import Session
+from iotdb.utils.IoTDBConstants import TSDataType, TSEncoding, Compressor
+
+# creating session connection.
+ip = "127.0.0.1"
+port_ = "6667"
+username_ = "root"
+password_ = "root"
+session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="UTC+8")
+session.open(False)
+
+
+# setting time series.
+session.create_time_series("root.dj.d_01.temperature", TSDataType.FLOAT, TSEncoding.PLAIN, Compressor.SNAPPY)
+session.create_time_series("root.dj.d_01.status", TSDataType.BOOLEAN, TSEncoding.PLAIN, Compressor.SNAPPY)
+
+# insert one record into the database.
+measurements_ = ["temperature", "status"]
+values_ = [19.01, True]
+data_types_ = [
+    TSDataType.FLOAT,
+    TSDataType.BOOLEAN,
+]
+device_id = "root.dj.d_01"
+session.insert_record(device_id, 2, measurements_, data_types_, values_)
+
+session.execute_non_query_statement("insert into root.sg_test_01.wf02.wf01(timestamp, temperature, status) values(now(), 20.00, True)")
+session.close()
diff --git a/client-py/iotdb/Session.py b/client-py/iotdb/Session.py
index 5db100a..c3c685c 100644
--- a/client-py/iotdb/Session.py
+++ b/client-py/iotdb/Session.py
@@ -84,6 +84,7 @@ class Session(object):
         self.__session_id = None
         self.__statement_id = None
         self.__zone_id = zone_id
+        self.values_in_bytes = None
 
     def open(self, enable_rpc_compression):
         if not self.__is_close:
@@ -403,13 +404,18 @@ class Session(object):
     def gen_insert_record_req(
         self, device_id, timestamp, measurements, data_types, values
     ):
+        # if self.values_in_bytes != None:
+        #     return TSInsertRecordReq(
+        #         self.__session_id, device_id, measurements, self.values_in_bytes, timestamp
+        #     )
         if (len(values) != len(data_types)) or (len(values) != len(measurements)):
             raise RuntimeError(
                 "length of data types does not equal to length of values!"
             )
-        values_in_bytes = Session.value_to_bytes(data_types, values)
+        self.values_in_bytes = Session.value_to_bytes(data_types, values)
+
         return TSInsertRecordReq(
-            self.__session_id, device_id, measurements, values_in_bytes, timestamp
+            self.__session_id, device_id, measurements, self.values_in_bytes, timestamp
         )
 
     def gen_insert_str_record_req(
diff --git a/client-py/iotdb/utils/IoTDBConstants.py b/client-py/iotdb/utils/IoTDBConstants.py
index ff92773..4faa710 100644
--- a/client-py/iotdb/utils/IoTDBConstants.py
+++ b/client-py/iotdb/utils/IoTDBConstants.py
@@ -51,3 +51,6 @@ class Compressor(Enum):
     PAA = 5
     PLA = 6
     LZ4 = 7
+
+UseNew=True
+# UseNew=False
\ No newline at end of file
diff --git a/client-py/iotdb/utils/Tablet.py b/client-py/iotdb/utils/Tablet.py
index 667adcb..9eb36a1 100644
--- a/client-py/iotdb/utils/Tablet.py
+++ b/client-py/iotdb/utils/Tablet.py
@@ -19,6 +19,7 @@
 import struct
 
 from iotdb.utils.IoTDBConstants import TSDataType
+from iotdb.utils.IoTDBConstants import UseNew
 
 
 class Tablet(object):
@@ -78,54 +79,70 @@ class Tablet(object):
         return self.__device_id
 
     def get_binary_timestamps(self):
-        format_str_list = [">"]
-        values_tobe_packed = []
-        for timestamp in self.__timestamps:
-            format_str_list.append("q")
-            values_tobe_packed.append(timestamp)
+        if not UseNew:
+            format_str_list = [">"]
+            values_tobe_packed = []
+            for timestamp in self.__timestamps:
+                format_str_list.append("q")
+                values_tobe_packed.append(timestamp)
 
-        format_str = "".join(format_str_list)
-        return struct.pack(format_str, *values_tobe_packed)
+            format_str = "".join(format_str_list)
+            return struct.pack(format_str, *values_tobe_packed)
+        else:
+            return self.__timestamps.tobytes()
 
     def get_binary_values(self):
-        format_str_list = [">"]
-        values_tobe_packed = []
-        for i in range(self.__column_number):
-            if self.__data_types[i] == TSDataType.BOOLEAN:
-                format_str_list.append(str(self.__row_number))
-                format_str_list.append("?")
-                for j in range(self.__row_number):
-                    values_tobe_packed.append(self.__values[j][i])
-            elif self.__data_types[i] == TSDataType.INT32:
-                format_str_list.append(str(self.__row_number))
-                format_str_list.append("i")
-                for j in range(self.__row_number):
-                    values_tobe_packed.append(self.__values[j][i])
-            elif self.__data_types[i] == TSDataType.INT64:
-                format_str_list.append(str(self.__row_number))
-                format_str_list.append("q")
-                for j in range(self.__row_number):
-                    values_tobe_packed.append(self.__values[j][i])
-            elif self.__data_types[i] == TSDataType.FLOAT:
-                format_str_list.append(str(self.__row_number))
-                format_str_list.append("f")
-                for j in range(self.__row_number):
-                    values_tobe_packed.append(self.__values[j][i])
-            elif self.__data_types[i] == TSDataType.DOUBLE:
-                format_str_list.append(str(self.__row_number))
-                format_str_list.append("d")
-                for j in range(self.__row_number):
-                    values_tobe_packed.append(self.__values[j][i])
-            elif self.__data_types[i] == TSDataType.TEXT:
-                for j in range(self.__row_number):
-                    value_bytes = bytes(self.__values[j][i], "utf-8")
+        if not UseNew:
+            format_str_list = [">"]
+            values_tobe_packed = []
+            for i in range(self.__column_number):
+                if self.__data_types[i] == TSDataType.BOOLEAN:
+                    format_str_list.append(str(self.__row_number))
+                    format_str_list.append("?")
+                    for j in range(self.__row_number):
+                        values_tobe_packed.append(self.__values[j][i])
+                elif self.__data_types[i] == TSDataType.INT32:
+                    format_str_list.append(str(self.__row_number))
                     format_str_list.append("i")
-                    format_str_list.append(str(len(value_bytes)))
-                    format_str_list.append("s")
-                    values_tobe_packed.append(len(value_bytes))
-                    values_tobe_packed.append(value_bytes)
-            else:
-                raise RuntimeError("Unsupported data type:" + str(self.__data_types[i]))
-
-        format_str = "".join(format_str_list)
-        return struct.pack(format_str, *values_tobe_packed)
+                    for j in range(self.__row_number):
+                        values_tobe_packed.append(self.__values[j][i])
+                elif self.__data_types[i] == TSDataType.INT64:
+                    format_str_list.append(str(self.__row_number))
+                    format_str_list.append("q")
+                    for j in range(self.__row_number):
+                        values_tobe_packed.append(self.__values[j][i])
+                elif self.__data_types[i] == TSDataType.FLOAT:
+                    format_str_list.append(str(self.__row_number))
+                    format_str_list.append("f")
+                    for j in range(self.__row_number):
+                        values_tobe_packed.append(self.__values[j][i])
+                elif self.__data_types[i] == TSDataType.DOUBLE:
+                    format_str_list.append(str(self.__row_number))
+                    format_str_list.append("d")
+                    for j in range(self.__row_number):
+                        values_tobe_packed.append(self.__values[j][i])
+                elif self.__data_types[i] == TSDataType.TEXT:
+                    for j in range(self.__row_number):
+                        value_bytes = bytes(self.__values[j][i], "utf-8")
+                        format_str_list.append("i")
+                        format_str_list.append(str(len(value_bytes)))
+                        format_str_list.append("s")
+                        values_tobe_packed.append(len(value_bytes))
+                        values_tobe_packed.append(value_bytes)
+                else:
+                    raise RuntimeError("Unsupported data type:" + str(self.__data_types[i]))
+
+            format_str = "".join(format_str_list)
+            return struct.pack(format_str, *values_tobe_packed)
+        else:
+            ret = None
+            for i in range(self.__column_number):
+                if self.__data_types[i] == TSDataType.FLOAT:
+                    # format_str_list.append(str(self.__row_number))
+                    # format_str_list.append("f")
+                    # for j in range(self.__row_number):
+                    #     values_tobe_packed.append(self.__values[j][i])
+                    ret = self.__values.tobytes()
+                else:
+                    raise RuntimeError("Unsupported data type:" + str(self.__data_types[i]))
+            return ret
diff --git a/client-py/main.py b/client-py/main.py
new file mode 100644
index 0000000..981a983
--- /dev/null
+++ b/client-py/main.py
@@ -0,0 +1,22 @@
+import struct
+import numpy as np
+
+format_str = '>2f'
+ret = struct.pack(format_str, *[1., 1.])
+print(ret)
+print(type(ret))
+
+ret = np.array([1., 1.], dtype='>f').tobytes()
+print(ret)
+print(type(ret))
+
+
+format_str = '>2q'
+ret = struct.pack(format_str, *[123321, 123123])
+print(ret)
+print(type(ret))
+
+ret = np.array([123321, 123123], dtype='>q').tobytes()
+print(ret)
+print(type(ret))
+
diff --git a/example/session/src/main/java/org/apache/iotdb/TestSession.java b/example/session/src/main/java/org/apache/iotdb/TestSession.java
new file mode 100644
index 0000000..2351dc5
--- /dev/null
+++ b/example/session/src/main/java/org/apache/iotdb/TestSession.java
@@ -0,0 +1,100 @@
+package org.apache.iotdb;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.iotdb.session.Session;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.write.record.Tablet;
+import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+
+public class TestSession {
+
+  public static void main(String[] args) throws Exception {
+    Session session = new Session("127.0.0.1", 6667, "root", "root");
+    session.open();
+//        session.setStorageGroup("root.sestest");
+//        session.createTimeseries("root.sestest.wf01.wt01.s0", TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY);
+//        session.createTimeseries("root.sestest.wf01.wt01.s1", TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY);
+//        session.createTimeseries("root.sestest.wf01.wt01.s2", TSDataType.INT32, TSEncoding.RLE, CompressionType.SNAPPY);
+
+    Date d = new Date();
+    Random r = new Random(0);
+    long insertCost = 0;
+    for (int i = 2000; i < 4000; i++) {
+//      Calendar c = Calendar.getInstance();
+//      c.setTime(d);
+      String deviceId = "root.sg" + i % 8 + "." + i;
+//      List<List<String>> measurementsList = new ArrayList<List<String>>();
+//      List<List<TSDataType>> typesList = new ArrayList<List<TSDataType>>();
+//      List<List<Object>> valuesList = new ArrayList<List<Object>>();
+//      List<Long> times = new ArrayList<Long>();
+//      List<String> deviceIds = new ArrayList<String>();
+
+      MeasurementSchema mes = new MeasurementSchema("s1", TSDataType.FLOAT);
+      MeasurementSchema mes1 = new MeasurementSchema("is_true", TSDataType.BOOLEAN);
+
+      List<IMeasurementSchema> schemas = new ArrayList<>();
+      schemas.add(mes);
+//      schemas.add(mes1);
+      int rowSize = 10080;
+//      int rowSize = 5080;
+      Tablet ta = new Tablet(deviceId, schemas, rowSize);
+      ta.rowSize = rowSize;
+      for (int t = 0; t < ta.rowSize; t++) {
+//					Random r=new Random();
+//					 List<String> measurement = new ArrayList<>();
+//					List<Object> values = new ArrayList<>(3);
+//		            List<TSDataType> types = new ArrayList<>(3);
+//		            times.add(c.getTimeInMillis());
+//		            values.add(-2+6*r.nextFloat());
+//		            types.add(TSDataType.FLOAT);
+//		            values.add(true);
+//		            types.add(TSDataType.BOOLEAN);
+//		            measurement.add("s1");
+//		            measurement.add("is_true");
+//		            typesList.add(types);
+//		            valuesList.add(values);
+//		            deviceIds.add(deviceId);
+//		            measurementsList.add(measurement);
+//					c.add(Calendar.MINUTE,+i);
+
+//					 List<String> measurement = new ArrayList<>();
+//					List<Object> values = new ArrayList<>(3);
+//		            List<TSDataType> types = new ArrayList<>(3);
+//		           
+//		            values.add(-2+6*r.nextFloat());
+//		            types.add(TSDataType.FLOAT);
+//		            values.add(true);
+//		            types.add(TSDataType.BOOLEAN);
+//		            measurement.add("s1");
+//		            measurement.add("is_true");
+//		            typesList.add(types);
+//		            valuesList.add(values);
+//		            deviceIds.add(deviceId);
+//		            measurementsList.add(measurement);
+//        ta.addTimestamp(t, c.getTimeInMillis());
+        ta.addTimestamp(t, t);
+//        ta.addValue("is_true", t, true);
+//        ta.addValue("s1", t, -2 + 6 * r.nextFloat());
+        ta.addValue("s1", t, -2 + 6 * 0.5f);
+//        c.add(Calendar.MINUTE, +1);
+      }
+      long st = System.nanoTime();
+      session.insertTablet(ta, true);
+      insertCost += (System.nanoTime() - st);
+      //session.insertRecords(deviceIds, times, measurementsList, typesList, valuesList);
+    }
+    session.close();
+    Date d1 = new Date();
+    System.out.println(d1.getTime() - d.getTime());
+    System.out.println(insertCost / 1000_000);
+
+
+  }
+
+}