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 2022/04/08 04:26:17 UTC
[iotdb] 03/03: doc
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch numpy_type_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0c957f5ae02cd16c0b86203434a122c7a4f3ffeb
Author: HTHou <hh...@outlook.com>
AuthorDate: Fri Apr 8 12:25:44 2022 +0800
doc
---
client-py/README.md | 19 ++++++++++---------
client-py/SessionExample.py | 14 +++++++-------
docs/UserGuide/API/Programming-Python-Native-API.md | 19 ++++++++++---------
.../zh/UserGuide/API/Programming-Python-Native-API.md | 18 +++++++++---------
4 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/client-py/README.md b/client-py/README.md
index 6c0acd62e7..0bc94b1ddc 100644
--- a/client-py/README.md
+++ b/client-py/README.md
@@ -182,8 +182,9 @@ Comparing with Tablet, Numpy Tablet is using [numpy.ndarray](https://numpy.org/d
With less memory footprint and time cost of serialization, the insert performance will be better.
**Notice**
-1. time and numerical value columns in Tablet is ndarray
-2. ndarray should be big-endian, see the example below
+1. time and value columns in Tablet are ndarray.
+2. it's better to use the specific dtypes to each ndarray, see the example below
+(if not, the default dtypes are also ok).
```python
data_types_ = [
@@ -195,14 +196,14 @@ data_types_ = [
TSDataType.TEXT,
]
np_values_ = [
- np.array([False, True, False, True], np.dtype(">?")),
- np.array([10, 100, 100, 0], np.dtype(">i4")),
- np.array([11, 11111, 1, 0], np.dtype(">i8")),
- np.array([1.1, 1.25, 188.1, 0], np.dtype(">f4")),
- np.array([10011.1, 101.0, 688.25, 6.25], np.dtype(">f8")),
- np.array(["test01", "test02", "test03", "test04"]),
+ np.array([False, True, False, True], TSDataType.BOOLEAN.np_dtype()),
+ np.array([10, 100, 100, 0], TSDataType.INT32.np_dtype()),
+ np.array([11, 11111, 1, 0], TSDataType.INT64.np_dtype()),
+ np.array([1.1, 1.25, 188.1, 0], TSDataType.FLOAT.np_dtype()),
+ np.array([10011.1, 101.0, 688.25, 6.25], TSDataType.DOUBLE.np_dtype()),
+ np.array(["test01", "test02", "test03", "test04"], TSDataType.TEXT.np_dtype()),
]
-np_timestamps_ = np.array([1, 2, 3, 4], np.dtype(">i8"))
+np_timestamps_ = np.array([1, 2, 3, 4], TSDataType.INT64.np_dtype())
np_tablet_ = NumpyTablet(
"root.sg_test_01.d_02", measurements_, data_types_, np_values_, np_timestamps_
)
diff --git a/client-py/SessionExample.py b/client-py/SessionExample.py
index 75897a44fb..bbc9669527 100644
--- a/client-py/SessionExample.py
+++ b/client-py/SessionExample.py
@@ -185,14 +185,14 @@ session.insert_tablet(tablet_)
# insert one numpy tablet into the database.
np_values_ = [
- np.array([False, True, False, True], np.dtype(">?")),
- np.array([10, 100, 100, 0], np.dtype(">i4")),
- np.array([11, 11111, 1, 0], np.dtype(">i8")),
- np.array([1.1, 1.25, 188.1, 0], np.dtype(">f4")),
- np.array([10011.1, 101.0, 688.25, 6.25], np.dtype(">f8")),
- np.array(["test01", "test02", "test03", "test04"]),
+ np.array([False, True, False, True], TSDataType.BOOLEAN.np_dtype()),
+ np.array([10, 100, 100, 0], TSDataType.INT32.np_dtype()),
+ np.array([11, 11111, 1, 0], TSDataType.INT64.np_dtype()),
+ np.array([1.1, 1.25, 188.1, 0], TSDataType.FLOAT.np_dtype()),
+ np.array([10011.1, 101.0, 688.25, 6.25], TSDataType.DOUBLE.np_dtype()),
+ np.array(["test01", "test02", "test03", "test04"], TSDataType.TEXT.np_dtype()),
]
-np_timestamps_ = np.array([1, 2, 3, 4], np.dtype(">i8"))
+np_timestamps_ = np.array([1, 2, 3, 4], TSDataType.INT64.np_dtype())
np_tablet_ = NumpyTablet(
"root.sg_test_01.d_02", measurements_, data_types_, np_values_, np_timestamps_
)
diff --git a/docs/UserGuide/API/Programming-Python-Native-API.md b/docs/UserGuide/API/Programming-Python-Native-API.md
index eab4a477ac..d9d538dfda 100644
--- a/docs/UserGuide/API/Programming-Python-Native-API.md
+++ b/docs/UserGuide/API/Programming-Python-Native-API.md
@@ -161,7 +161,8 @@ With less memory footprint and time cost of serialization, the insert performanc
**Notice**
1. time and numerical value columns in Tablet is ndarray
-2. ndarray should be big-endian, see the example below
+2. it's better to use the specific dtypes to each ndarray, see the example below
+ (if not, the default dtypes are also ok).
```python
data_types_ = [
@@ -173,14 +174,14 @@ data_types_ = [
TSDataType.TEXT,
]
np_values_ = [
- np.array([False, True, False, True], np.dtype(">?")),
- np.array([10, 100, 100, 0], np.dtype(">i4")),
- np.array([11, 11111, 1, 0], np.dtype(">i8")),
- np.array([1.1, 1.25, 188.1, 0], np.dtype(">f4")),
- np.array([10011.1, 101.0, 688.25, 6.25], np.dtype(">f8")),
- np.array(["test01", "test02", "test03", "test04"]),
+ np.array([False, True, False, True], TSDataType.BOOLEAN.np_dtype()),
+ np.array([10, 100, 100, 0], TSDataType.INT32.np_dtype()),
+ np.array([11, 11111, 1, 0], TSDataType.INT64.np_dtype()),
+ np.array([1.1, 1.25, 188.1, 0], TSDataType.FLOAT.np_dtype()),
+ np.array([10011.1, 101.0, 688.25, 6.25], TSDataType.DOUBLE.np_dtype()),
+ np.array(["test01", "test02", "test03", "test04"], TSDataType.TEXT.np_dtype()),
]
-np_timestamps_ = np.array([1, 2, 3, 4], np.dtype(">i8"))
+np_timestamps_ = np.array([1, 2, 3, 4], TSDataType.INT64.np_dtype())
np_tablet_ = NumpyTablet(
"root.sg_test_01.d_02", measurements_, data_types_, np_values_, np_timestamps_
)
@@ -204,7 +205,7 @@ session.insert_record(device_id, timestamp, measurements_, data_types_, values_)
```python
session.insert_records(
device_ids_, time_list_, measurements_list_, data_type_list_, values_list_
- )
+)
```
* Insert multiple Records that belong to the same device.
diff --git a/docs/zh/UserGuide/API/Programming-Python-Native-API.md b/docs/zh/UserGuide/API/Programming-Python-Native-API.md
index 9cb92e74ed..d1356158eb 100644
--- a/docs/zh/UserGuide/API/Programming-Python-Native-API.md
+++ b/docs/zh/UserGuide/API/Programming-Python-Native-API.md
@@ -160,8 +160,8 @@ session.insert_tablet(tablet_)
内存占用和序列化耗时会降低很多,写入效率也会有很大提升。
**注意**
-1. Tablet 中的每一列值记录为一个 ndarray
-2. ndarray 需要为大端类型的数据类型,具体可参考下面的例子
+1. Tablet 中的每一列时间戳和值记录为一个 ndarray
+2. ndarray 最好使用如下面例子中的特定的 dtype,如果不使用也可以,不会影响正确性。
```python
data_types_ = [
@@ -173,14 +173,14 @@ data_types_ = [
TSDataType.TEXT,
]
np_values_ = [
- np.array([False, True, False, True], np.dtype(">?")),
- np.array([10, 100, 100, 0], np.dtype(">i4")),
- np.array([11, 11111, 1, 0], np.dtype(">i8")),
- np.array([1.1, 1.25, 188.1, 0], np.dtype(">f4")),
- np.array([10011.1, 101.0, 688.25, 6.25], np.dtype(">f8")),
- np.array(["test01", "test02", "test03", "test04"]),
+ np.array([False, True, False, True], TSDataType.BOOLEAN.np_dtype()),
+ np.array([10, 100, 100, 0], TSDataType.INT32.np_dtype()),
+ np.array([11, 11111, 1, 0], TSDataType.INT64.np_dtype()),
+ np.array([1.1, 1.25, 188.1, 0], TSDataType.FLOAT.np_dtype()),
+ np.array([10011.1, 101.0, 688.25, 6.25], TSDataType.DOUBLE.np_dtype()),
+ np.array(["test01", "test02", "test03", "test04"], TSDataType.TEXT.np_dtype()),
]
-np_timestamps_ = np.array([1, 2, 3, 4], np.dtype(">i8"))
+np_timestamps_ = np.array([1, 2, 3, 4], TSDataType.INT64.np_dtype())
np_tablet_ = NumpyTablet(
"root.sg_test_01.d_02", measurements_, data_types_, np_values_, np_timestamps_
)