未验证 提交 e973893a 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

docs: reference docs in English (#12562)

* docs: reference doc in English

[TD-15603]

* docs: reference docs in English

[TD-15603]
上级 74e1564a
...@@ -32,7 +32,7 @@ tag_set 中的所有的数据自动转化为 nchar 数据类型,并不需要 ...@@ -32,7 +32,7 @@ tag_set 中的所有的数据自动转化为 nchar 数据类型,并不需要
在无模式写入数据行协议中,field_set 中的每个数据项都需要对自身的数据类型进行描述。具体来说: 在无模式写入数据行协议中,field_set 中的每个数据项都需要对自身的数据类型进行描述。具体来说:
- 如果两边有英文双引号,表示 BIANRY(32) 类型。例如 `"abc"` - 如果两边有英文双引号,表示 BINARY(32) 类型。例如 `"abc"`
- 如果两边有英文双引号而且带有 L 前缀,表示 NCHAR(32) 类型。例如 `L"报错信息"` - 如果两边有英文双引号而且带有 L 前缀,表示 NCHAR(32) 类型。例如 `L"报错信息"`
- 对空格、等号(=)、逗号(,)、双引号("),前面需要使用反斜杠(\)进行转义。(都指的是英文半角符号) - 对空格、等号(=)、逗号(,)、双引号("),前面需要使用反斜杠(\)进行转义。(都指的是英文半角符号)
- 数值类型将通过后缀来区分数据类型: - 数值类型将通过后缀来区分数据类型:
......
--- ---
title: 支持平台列表 title: List of supported platforms
description: "TDengine 服务端、客户端和连接器支持的平台列表" description: "List of platforms supported by TDengine server, client, and connector"
--- ---
## TDengine 服务端支持的平台列表 ## List of supported platforms for TDengine server
| | **CentOS 7/8** | **Ubuntu 16/18/20** | **Other Linux** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **华为 EulerOS** | | | **CentOS 7/8** | **Ubuntu 16/18/20** | **Other Linux** |
| ------------ | -------------- | ------------------- | --------------- | ------------ | ----------------- | ---------------- | ---------------- | | ------------ | -------------- | ------------------- | --------------- |
| X64 | ● | ● | | ○ | ● | ● | ● | | X64 | ● | ● | |
| 龙芯 MIPS64 | | | ● | | | | | | MIPS64 | | | ● |
| 鲲鹏 ARM64 | | ○ | ○ | | ● | | | | ARM64 | | ○ | ○ |
| 申威 Alpha64 | | | ○ | ● | | | | | Alpha64 | | | ○ |
| 飞腾 ARM64 | | ○ 优麒麟 | | | | | |
| 海光 X64 | ● | ● | ● | ○ | ● | ● | | Note: ● means officially tested and verified, ○ means unofficially tested and verified.
| 瑞芯微 ARM64 | | | ○ | | | | |
| 全志 ARM64 | | | ○ | | | | | ## List of supported platforms for TDengine clients and connectors
| 炬力 ARM64 | | | ○ | | | | |
| 华为云 ARM64 | | | | | | | ● | TDengine's connector can support a wide range of platforms, including X64/X86/ARM64/ARM32/MIPS/Alpha hardware platforms and Linux/Win64/Win32 development environments.
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。 The comparison matrix is as follows.
## TDengine 客户端和连接器支持的平台列表 | **CPU** | **X64 64bit** | | | **X86 32bit** | **ARM64** | **ARM32** | **MIPS** | **Alpha** |
| ----------- | ------------- | --------- | --------- | ------------- | --------- | --------- | --------- | --------- |
目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。 | **OS** | **Linux** | **Win64** | **Win32** | **Win32** | **Linux** | **Linux** | **Linux** | **Linux** |
| **C/C++** | ● | ● | ● | ○ | ● | ● | ● | ● |
对照矩阵如下: | **JDBC** | ● | ● | ● | ○ | ● | ● | ● | ● |
| **Python** | ● | ● | ● | ○ | ● | ● | ● | -- |
| **CPU** | **X64 64bit** | | | **X86 32bit** | **ARM64** | **ARM32** | **MIPS 龙芯** | **Alpha 申威** | **X64 海光** | | **Go** | ● | ● | ● | ○ | ● | ● | ○ | -- |
| ----------- | ------------- | --------- | --------- | ------------- | --------- | --------- | ------------- | -------------- | ------------ | | **NodeJs** | ● | ● | ○ | ○ | ● | ● | ○ | -- |
| **OS** | **Linux** | **Win64** | **Win32** | **Win32** | **Linux** | **Linux** | **Linux** | **Linux** | **Linux** | | **C#** | ● | ● | ○ | ○ | ○ | ○ | ○ | -- |
| **C/C++** | ● | ● | ● | ○ | ● | ● | ● | ● | ● | | **RESTful** | ● | ● | ● | ● | ● | ● | ● | ● |
| **JDBC** | ● | ● | ● | ○ | ● | ● | ● | ● | ● |
| **Python** | ● | ● | ● | ○ | ● | ● | ● | -- | ● | Note: ● means the official test is verified, ○ means the unofficial test is verified, -- means not verified.
| **Go** | ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
| **NodeJs** | ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
| **C#** | ● | ● | ○ | ○ | ○ | ○ | ○ | -- | -- |
| **RESTful** | ● | ● | ● | ● | ● | ● | ● | ● | ● |
注:● 表示官方测试验证通过,○ 表示非官方测试验证通过,-- 表示未经验证。
label: TDengine Docker 镜像 label: TDengine Docker images
\ No newline at end of file \ No newline at end of file
--- ---
title: 用 Docker 部署 TDengine title: Deploying TDengine with Docker
description: "本章主要介绍如何在容器中启动 TDengine 服务并访问它" Description: "This chapter focuses on starting the TDengine service in a container and accessing it."
--- ---
本章主要介绍如何在容器中启动 TDengine 服务并访问它。可以在 docker run 命令行中或者 docker-compose 文件中使用环境变量来控制容器中服务的行为。 This chapter describes how to start the TDengine service in a container and access it. Users can control the behavior of the service in the container by using environment variables on the docker run command line or in the docker-compose file.
## 启动 TDengine ## Starting TDengine
TDengine 镜像启动时默认激活 HTTP 服务,使用下列命令 The TDengine image starts with the HTTP service activated by default, using the following command:
```shell ```shell
docker run -d --name tdengine -p 6041:6041 tdengine/tdengine docker run -d --name tdengine -p 6041:6041 tdengine/tdengine
``` ```
以上命令启动了一个名为“tdengine”的容器,并把其中的 HTTP 服务的端 6041 映射到了主机端口 6041。使用如下命令可以验证该容器中提供的 HTTP 服务是否可用: The above command starts a container named "tdengine" and maps the HTTP service end 6041 to the host port 6041. You can verify that the HTTP service provided in this container is available using the following command.
```shell ```shell
curl -u root:taosdata -d "show databases" localhost:6041/rest/sql curl -u root:taosdata -d "show databases" localhost:6041/rest/sql
``` ```
使用如下命令可以在该容器中执行 TDengine 的客户端 taos 对 TDengine 进行访问: The TDengine client taos can be executed in this container to access TDengine using the following command.
```shell ```shell
$ docker exec -it tdengine taos $ docker exec -it tdengine taos
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0 Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. Copyright (c) 2020 by TAOS Data, Inc.
taos> show databases; taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | status precision | update | status |
==================================================================================================================================================================================================================================================================================== ================================================================================================================================== ================================================================================================================================== ================
log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready | log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
Query OK, 1 row(s) in set (0.002843s) Query OK, 1 row(s) in set (0.002843s)
``` ```
因为运行在容器中的 TDengine 服务端使用容器的 hostname 建立连接,使用 taos shell 或者各种连接器(例如 JDBC-JNI)从容器外访问容器内的 TDengine 比较复杂,所以上述方式是访问容器中 TDengine 服务的最简单的方法,适用于一些简单场景。如果在一些复杂场景下想要从容器化使用 taos shell 或者各种连接器访问容器中的 TDengine 服务,请参考下一节。 The TDengine server running in the container uses the container's hostname to establish a connection. Using TDengine CLI or various connectors (such as JDBC-JNI) to access the TDengine inside the container from outside the container is more complicated. So the above is the simplest way to access the TDengine service in the container and is suitable for some simple scenarios. Please refer to the next section if you want to access the TDengine service in the container from containerized using TDengine CLI or various connectors in some complex scenarios.
## 在 host 网络上启动 TDengine ## Start TDengine on the host network
```shell ```shell
docker run -d --name tdengine --network host tdengine/tdengine docker run -d --name tdengine --network host tdengine/tdengine
``` ```
上面的命令在 host 网络上启动 TDengine,并使用主机的 FQDN 建立连接而不是使用容器的 hostname 。这种方式和在主机上使用 `systemctl` 启动 TDengine 效果相同。在主机已安装 TDengine 客户端情况下,可以直接使用下面的命令访问它。 The above command starts TDengine on the host network and uses the host's FQDN to establish a connection instead of the container's hostname. It works too, like using `systemctl` to start TDengine on the host. If the TDengine client is already installed on the host, you can access it directly with the following command.
```shell ```shell
$ taos $ taos
Welcome to the TDengine shell from Linux, Client Version:2.4.0.0 Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. Copyright (c) 2020 by TAOS Data, Inc.
taos> show dnodes; taos> show dnodes;
id | end_point | vnodes | cores | status | role | create_time | offline reason | id | end_point | vnodes | cores | status | role | create_time | offline reason |
====================================================================================================================================== ================================================================================================================================== ====
1 | myhost:6030 | 1 | 8 | ready | any | 2022-01-17 22:10:32.619 | | 1 | myhost:6030 | 1 | 8 | ready | any | 2022-01-17 22:10:32.619 | |
Query OK, 1 row(s) in set (0.003233s) Query OK, 1 row(s) in set (0.003233s)
``` ```
## 以指定的 hostname 和 port 启动 TDengine ## Start TDengine with the specified hostname and port
利用 `TAOS_FQDN` 环境变量或者 `taos.cfg` 中的 `fqdn` 配置项可以使 TDengine 在指定的 hostname 上建立连接。这种方式可以为部署提供更大的灵活性。 The `TAOS_FQDN` environment variable or the `fqdn` configuration item in `taos.cfg` allows TDengine to establish a connection at the specified hostname. This approach provides greater flexibility for deployment.
```shell ```shell
docker run -d \ docker run -d \
...@@ -70,35 +70,35 @@ docker run -d \ ...@@ -70,35 +70,35 @@ docker run -d \
tdengine/tdengine tdengine/tdengine
``` ```
上面的命令在容器中启动一个 TDengine 服务,其所监听的 hostname 为 tdengine ,并将容器的 6030 到 6049 端口段映射到主机的 6030 到 6049 端口段 (tcp 和 udp 都需要映射)。如果主机上该端口段已经被占用,可以修改上述命令指定一个主机上空闲的端口段。如果 `rpcForceTcp` 被设置为 `1` ,可以只映射 tcp 协议。 The above command starts a TDengine service in the container, which listens to the hostname tdengine, and maps the container's port segment 6030 to 6049 to the host's port segment 6030 to 6049 (both TCP and UDP ports need to be mapped). If the port segment is already occupied on the host, you can modify the above command to specify a free port segment on the host. If `rpcForceTcp` is set to `1`, you can map only the TCP protocol.
接下来,要确保 "tdengine" 这个 hostname 在 `/etc/hosts` 中可解析。 Next, ensure the hostname "tdengine" is resolvable in `/etc/hosts`.
```shell ```shell
echo 127.0.0.1 tdengine |sudo tee -a /etc/hosts echo 127.0.0.1 tdengine |sudo tee -a /etc/hosts
``` ```
最后,可以从 taos shell 或者任意连接器以 "tdengine" 为服务端地址访问 TDengine 服务。 Finally, the TDengine service can be accessed from the taos shell or any connector with "tdengine" as the server address.
```shell ```shell
taos -h tdengine -P 6030 taos -h tdengine -P 6030
``` ```
如果 `TAOS_FQDN` 被设置为与所在主机名相同,则效果与 “在 host 网络上启动 TDengine” 相同。 If set `TAOS_FQDN` to the same hostname, the effect is the same as "Start TDengine on host network".
## 在指定网络上启动 TDengine ## Start TDengine on the specified network
也可以在指定的特定网络上启动 TDengine。下面是详细步骤: You can also start TDengine on a specific network.
1. 首先,创建一个 docker 网络,命名为 td-net 1. First, create a docker network named `td-net`
```shell ```shell
docker network create td-net docker network create td-net
``` ``` Create td-net
2. 启动 TDengine 2. Start TDengine
以下命令在 td-net 网络上启动 TDengine 服务 Start the TDengine service on the `td-net` network with the following command:
```shell ```shell
docker run -d --name tdengine --network td-net \ docker run -d --name tdengine --network td-net \
...@@ -106,17 +106,17 @@ taos -h tdengine -P 6030 ...@@ -106,17 +106,17 @@ taos -h tdengine -P 6030
tdengine/tdengine tdengine/tdengine
``` ```
3. 在同一网络上的另一容器中启动 TDengine 客户端 3. Start the TDengine client in another container on the same network
```shell ```shell
docker run --rm -it --network td-net -e TAOS_FIRST_EP=tdengine tdengine/tdengine taos docker run --rm -it --network td-net -e TAOS_FIRST_EP=tdengine tdengine/tdengine taos
# or # or
#docker run --rm -it --network td-net -e tdengine/tdengine taos -h tdengine # docker run --rm -it --network td-net -e tdengine/tdengine taos -h tdengine
``` ```
## 在容器中启动客户端应用 ## Launching a client application in a container
如果想在容器中启动自己的应用的话,需要将相应的对 TDengine 的依赖也要加入到镜像中,例如: If you want to start your application in a container, you need to add the corresponding dependencies on TDengine to the image as well, e.g.
```docker ```docker
FROM ubuntu:20.04 FROM ubuntu:20.04
...@@ -133,7 +133,7 @@ RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_ ...@@ -133,7 +133,7 @@ RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_
#CMD ["app"] #CMD ["app"]
``` ```
以下是一个 go 应用程序的示例: Here is an example GO program:
```go ```go
/* /*
...@@ -218,7 +218,7 @@ func checkErr(err error, prompt string) { ...@@ -218,7 +218,7 @@ func checkErr(err error, prompt string) {
} }
``` ```
如下是完整版本的 dockerfile Here is the full Dockerfile:
```docker ```docker
FROM golang:1.17.6-buster as builder FROM golang:1.17.6-buster as builder
......
--- ---
title: Schemaless 写入 title: Schemaless Writing
description: "Schemaless 写入方式,可以免于预先创建超级表/子表的步骤,随着数据写入接口能够自动创建与数据对应的存储结构" description: "The Schemaless write method eliminates the need to create super tables/sub tables in advance and automatically creates the storage structure corresponding to the data as it is written to the interface."
--- ---
在物联网应用中,常会采集比较多的数据项,用于实现智能控制、业务分析、设备监控等。由于应用逻辑的版本升级,或者设备自身的硬件调整等原因,数据采集项就有可能比较频繁地出现变动。为了在这种情况下方便地完成数据记录工作,TDengine In IoT applications, many data items are often collected for intelligent control, business analysis, device monitoring, etc. Due to the version upgrade of the application logic, or the hardware adjustment of the device itself, the data collection items may change more frequently. To facilitate the data logging work in such cases, TDengine
从 2.2.0.0 版本开始,提供调用 Schemaless 写入方式,可以免于预先创建超级表/子表的步骤,随着数据写入接口能够自动创建与数据对应的存储结构。并且在必要时,Schemaless Starting from version 2.2.0.0, it provides a call to the Schemaless write method, which eliminates the need to create super tables/sub tables in advance and automatically creates the storage structure corresponding to the data as the data is written to the interface. And when necessary, Schemaless
将自动增加必要的数据列,保证用户写入的数据可以被正确存储。 will automatically add the required columns to ensure that the data written by the user is stored correctly.
无模式写入方式建立的超级表及其对应的子表与通过 SQL 直接建立的超级表和子表完全没有区别,你也可以通过,SQL 语句直接向其中写入数据。需要注意的是,通过无模式写入方式建立的表,其表名是基于标签值按照固定的映射规则生成,所以无法明确地进行表意,缺乏可读性。 The schemaless write method creates super tables and their corresponding sub-tables completely indistinguishable from the super tables and sub-tables created directly via SQL. You can write data directly to them via SQL statements. Note that the table names of tables created by schema-free writing are based on fixed mapping rules for tag values, so they are not explicitly ideographic and lack readability.
## 无模式写入行协议 ## Schemaless Write Row Protocol
TDengine 的无模式写入的行协议兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议、OpenTSDB 的 JSON 格式协议。但是使用这三种协议的时候,需要在 API 中指定输入内容使用解析协议的标准。 TDengine's schemaless write line protocol is compatible with InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. However, when using these three protocols, you need to specify in the API the standard of the parsing protocol to be used for the input content.
对于 InfluxDB、OpenTSDB 的标准写入协议请参考各自的文档。下面首先以 InfluxDB 的行协议为基础,介绍 TDengine 扩展的协议内容,允许用户采用更加精细的方式控制(超级表)模式。 For the standard writing protocols of InfluxDB and OpenTSDB, please refer to the documentation of each protocol. The following is a description of TDengine's extended protocol content, based on InfluxDB's row protocol first. They allow users to control the (supertable) schema more granularly.
Schemaless 采用一个字符串来表达一个数据行(可以向写入 API 中一次传入多行字符串来实现多个数据行的批量写入),其格式约定如下: With the following formatting conventions, Schemaless uses a single string to express a data row (multiple rows can be passed into the write API at once to enable bulk writing of numerous rows).
```json ```json
measurement,tag_set field_set timestamp measurement,tag_set field_set timestamp
``` ```
其中: where :
- measurement 将作为数据表名。它与 tag_set 之间使用一个英文逗号来分隔。 - measurement will be used as the data table name. It will be separated from tag_set by a comma.
- tag_set 将作为标签数据,其格式形如 `<tag_key>=<tag_value>,<tag_key>=<tag_value>`,也即可以使用英文逗号来分隔多个标签数据。它与 field_set 之间使用一个半角空格来分隔。 - tag_set will be used as tag data in the format ``<tag_key>=<tag_value>,<tag_key>=<tag_value>``, i.e. multiple tag data can be separated by a comma. It is separated from field_set by a space.
- field_set 将作为普通列数据,其格式形如 `<field_key>=<field_value>,<field_key>=<field_value>`,同样是使用英文逗号来分隔多个普通列的数据。它与 timestamp 之间使用一个半角空格来分隔。 - field_set will be used as normal column data in the format of `<field_key>=<field_value>,<field_key>=<field_value>`, again using a comma to separate multiple normal columns of data. It is separated from the timestamp by a space.
- timestamp 即本行数据对应的主键时间戳。 - The timestamp is the timestamp of the primary key corresponding to the data in this row.
tag_set 中的所有的数据自动转化为 nchar 数据类型,并不需要使用双引号(")。 All data in tag_set is automatically converted to the nchar data type and does not require double quotes (").
在无模式写入数据行协议中,field_set 中的每个数据项都需要对自身的数据类型进行描述。具体来说: In the schemaless write data row protocol, each data item in the field_set needs to be described with its data type. Let's explain in detail:
- 如果两边有英文双引号,表示 BIANRY(32) 类型。例如 `"abc"` - If there are English double quotes on both sides, it indicates the BINARY(32) type. For example, `"abc"`.
- 如果两边有英文双引号而且带有 L 前缀,表示 NCHAR(32) 类型。例如 `L"报错信息"` - If there are double quotes on both sides and an L prefix, it means NCHAR(32) type. For example, `L "error message"`.
- 对空格、等号(=)、逗号(,)、双引号("),前面需要使用反斜杠(\)进行转义。(都指的是英文半角符号) - Spaces, equal signs (=), commas (,), and double quotes (") need to be escaped with a backslash (\) in front. (All refer to the English half-angle symbol)
- 数值类型将通过后缀来区分数据类型: - Numeric types will be distinguished from data types by the suffix.
| **序号** | **后缀** | **映射类型** | **大小(字节)** | | **Serial number** | **Postfix** | **Mapping type** | **Size (bytes)** |
| -------- | -------- | ------------ | -------------- | | -------- | -------- | ------------ | -------------- |
| 1 | 无或 f64 | double | 8 | | 1 | none or f64 | double | 8 |
| 2 | f32 | float | 4 | | 2 | f32 | float | 4 |
| 3 | i8 | TinyInt | 1 | | 3 | i8 | TinyInt | 1 |
| 4 | i16 | SmallInt | 2 | | 4 | i16 | SmallInt | 2 |
| 5 | i32 | Int | 4 | | 5 | i32 | Int | 4 |
| 6 | i64 或 i | Bigint | 8 | | 6 | i64 or i | Bigint | 8 |
- t, T, true, True, TRUE, f, F, false, False 将直接作为 BOOL 型来处理。 - t, T, true, True, TRUE, f, F, false, and False will be handled directly as BOOL types.
例如如下数据行表示:向名为 st 的超级表下的 t1 标签为 "3"(NCHAR)、t2 标签为 "4"(NCHAR)、t3 For example, the following data rows indicate that the t1 label is "3" (NCHAR), the t2 label is "4" (NCHAR), and the t3 label is "t3" to the super table named st
标签为 "t3"(NCHAR)的数据子表,写入 c1 列为 3(BIGINT)、c2 列为 false(BOOL)、c3 labeled "t3" (NCHAR), write c1 column as 3 (BIGINT), c2 column as false (BOOL), c3 column is "passit" (BINARY), c4 column is 4 (DOUBLE), and the primary key timestamp is 1626006833639000000 in one row.
列为 "passit"(BINARY)、c4 列为 4(DOUBLE)、主键时间戳为 1626006833639000000 的一行数据。
```json ```json
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
``` ```
需要注意的是,如果描述数据类型后缀时使用了错误的大小写,或者为数据指定的数据类型有误,均可能引发报错提示而导致数据写入失败。 Note that if the wrong case is used when describing the data type suffix, or if the wrong data type is specified for the data, it may cause an error message and cause the data to fail to be written.
## 无模式写入的主要处理逻辑 ## Main processing logic for schemaless writes
无模式写入按照如下原则来处理行数据: Schema-free writes process row data according to the following principles.
1. 将使用如下规则来生成子表名:首先将 measurement 的名称和标签的 key 和 value 组合成为如下的字符串 1. You can use the following rules to generate the sub-table names: first, combine the measurement name and the key and value of the label into the next string:
```json ```json
"measurement,tag_key1=tag_value1,tag_key2=tag_value2" "measurement,tag_key1=tag_value1,tag_key2=tag_value2"
``` ```
需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。 Note that tag_key1, tag_key2 are not the original order of the tags entered by the user but the result of using the tag names in ascending order of the strings. Therefore, tag_key1 is not the first tag entered in the line protocol.
排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t*” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。 The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t*" is a fixed prefix that every table generated by this mapping relationship has. 2.
2. 如果解析行协议获得的超级表不存在,则会创建这个超级表。 2. If the super table obtained by parsing the row protocol does not exist, this super table is created.
3. 如果解析行协议获得子表不存在,则 Schemaless 会按照步骤 1 或 2 确定的子表名来创建子表。 If the sub-table obtained by the parse row protocol does not exist, Schemaless creates the sub-table according to the sub-table name determined in steps 1 or 2. 4.
4. 如果数据行中指定的标签列或普通列不存在,则在超级表中增加对应的标签列或普通列(只增不减)。 4. If the specified tag or regular column in the data row does not exist, the corresponding tag or regular column is added to the super table (only incremental).
5. 如果超级表中存在一些标签列或普通列未在一个数据行中被指定取值,那么这些列的值在这一行中会被置为 5. If there are some tag columns or regular columns in the super table that are not specified to take values in a data row, then the values of these columns are set to NULL.
NULL。 6. For BINARY or NCHAR columns, if the length of the value provided in a data row exceeds the column type limit, the maximum length of characters allowed to be stored in the column is automatically increased (only incremented and not decremented) to ensure complete preservation of the data.
6. 对 BINARY 或 NCHAR 列,如果数据行中所提供值的长度超出了列类型的限制,自动增加该列允许存储的字符长度上限(只增不减),以保证数据的完整保存。 7. If the specified data sub-table already exists, and the specified tag column takes a value different from the saved value this time, the value in the latest data row overwrites the old tag column take value.
7. 如果指定的数据子表已经存在,而且本次指定的标签列取值跟已保存的值不一样,那么最新的数据行中的值会覆盖旧的标签列取值。 8. Errors encountered throughout the processing will interrupt the writing process and return an error code.
8. 整个处理过程中遇到的错误会中断写入过程,并返回错误代码。
:::tip :::tip
无模式所有的处理逻辑,仍会遵循 TDengine 对数据结构的底层限制,例如每行数据的总长度不能超过 All processing logic without mode will still follow TDengine's underlying restrictions on data structures, such as the total length of each row of data cannot exceed
16k 字节。这方面的具体限制约束请参见 [TAOS SQL 边界限制](/taos-sql/limit) 16k bytes. See [TAOS SQL Boundary Limits](/taos-sql/limit) for specific constraints in this area.
::: :::
## 时间分辨率识别 ## Time resolution recognition
无模式写入过程中支持三个指定的模式,具体如下 Three specified modes are supported in the schemaless write process, as follows:
| **序号** | **值** | **说明** | | **Serial** | **Value** | **Description** |
| -------- | ------------------- | ------------------------------- | | -------- | ------------------- | ------------------------------- |
| 1 | SML_LINE_PROTOCOL | InfluxDB 行协议(Line Protocol) | | 1 | SML_LINE_PROTOCOL | InfluxDB Line Protocol |
| 2 | SML_TELNET_PROTOCOL | OpenTSDB 文本行协议 | | 2 | SML_TELNET_PROTOCOL | OpenTSDB Text Line Protocol | | 2 | SML_TELNET_PROTOCOL | OpenTSDB Text Line Protocol
| 3 | SML_JSON_PROTOCOL | JSON 协议格式 | | 3 | SML_JSON_PROTOCOL | JSON protocol format |
在 SML_LINE_PROTOCOL 解析模式下,需要用户指定输入的时间戳的时间分辨率。可用的时间分辨率如下表所示: In the SML_LINE_PROTOCOL parsing mode, the user is required to specify the time resolution of the input timestamp. The available time resolutions are shown in the following table.
| **序号** | **时间分辨率定义** | **含义** | | **Serial Number** | **Time Resolution Definition** | **Meaning** |
| -------- | --------------------------------- | -------------- | | -------- | --------------------------------- | -------------- |
| 1 | TSDB_SML_TIMESTAMP_NOT_CONFIGURED | 未定义(无效) | | 1 | TSDB_SML_TIMESTAMP_NOT_CONFIGURED | Not defined (invalid) |
| 2 | TSDB_SML_TIMESTAMP_HOURS | 小时 | | 2 | TSDB_SML_TIMESTAMP_HOURS | hour |
| 3 | TSDB_SML_TIMESTAMP_MINUTES | 分钟 | | 3 | TSDB_SML_TIMESTAMP_MINUTES | MINUTES
| 4 | TSDB_SML_TIMESTAMP_SECONDS | 秒 | | 4 | TSDB_SML_TIMESTAMP_SECONDS | SECONDS
| 5 | TSDB_SML_TIMESTAMP_MILLI_SECONDS | 毫秒 | | 5 | TSDB_SML_TIMESTAMP_MILLI_SECONDS | milliseconds
| 6 | TSDB_SML_TIMESTAMP_MICRO_SECONDS | 微秒 | | 6 | TSDB_SML_TIMESTAMP_MICRO_SECONDS | microseconds
| 7 | TSDB_SML_TIMESTAMP_NANO_SECONDS | 纳秒 | | 7 | TSDB_SML_TIMESTAMP_NANO_SECONDS | nanoseconds |
在 SML_TELNET_PROTOCOL 和 SML_JSON_PROTOCOL 模式下,根据时间戳的长度来确定时间精度(与 OpenTSDB 标准操作方式相同),此时会忽略用户指定的时间分辨率。 In SML_TELNET_PROTOCOL and SML_JSON_PROTOCOL modes, the time precision is determined based on the length of the timestamp (in the same way as the OpenTSDB standard operation), and the user-specified time resolution is ignored at this point.
## 数据模式映射规则 ## Data mode mapping rules
本节将说明行协议的数据如何映射成为具有模式的数据。每个行协议中数据 measurement 映射为 This section describes how data for row protocols are mapped to data with a schema. The data measurement in each row protocol is mapped to
超级表名称。tag_set 中的 标签名称为 数据模式中的标签名,field_set 中的名称为列名称。以如下数据为例,说明映射规则: The tag name in tag_set is the name of the tag in the data schema, and the name in field_set is the column's name. The following data is used as an example to illustrate the mapping rules.
```json ```json
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
``` ```
该行数据映射生成一个超级表: st, 其包含了 3 个类型为 nchar 的标签,分别是:t1, t2, t3。五个数据列,分别是 ts(timestamp),c1 (bigint),c3(binary),c2 (bool), c4 (bigint)。映射成为如下 SQL 语句: The row data mapping generates a super table: st, which contains three labels of type nchar: t1, t2, t3. 5 data columns are ts (timestamp), c1 (bigint), c3 (binary), c2 (bool), c4 (bigint). The mapping becomes the following SQL statement.
```json ```json
create stable st (_ts timestamp, c1 bigint, c2 bool, c3 binary(6), c4 bigint) tags(t1 nchar(1), t2 nchar(1), t3 nchar(2)) create stable st (_ts timestamp, c1 bigint, c2 bool, c3 binary(6), c4 bigint) tags(t1 nchar(1), t2 nchar(1), t3 nchar(2))
``` ```
## 数据模式变更处理 ## Data pattern change handling
本节将说明不同行数据写入情况下,对于数据模式的影响。 This section describes the impact on the data pattern for different row data writing cases.
在使用行协议写入一个明确的标识的字段类型的时候,后续更改该字段的类型定义,会出现明确的数据模式错误,即会触发写入 API 报告错误。如下所示, When writing to an explicitly identified field type using the row protocol, subsequent changes to the field's type definition will result in an explicit data schema error, i.e., will trigger a write API report error. As shown below, the
```json ```json
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4 1626006833639000000 st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4 1626006833639000000
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4i 1626006833640000000 st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4i 1626006833640000000
``` ```
第一行的数据类型映射将 c4 列定义为 Double, 但是第二行的数据又通过数值后缀方式声明该列为 BigInt, 由此会触发无模式写入的解析错误。 The data type mapping in the first row defines column c4 as Double, but the data in the second row is declared as BigInt by the numeric suffix, which triggers a parsing error with no mode write.
如果列前面的行协议将数据列声明为了 binary, 后续的要求长度更长的 binary 长度,此时会触发超级表模式的变更。 If the row protocol before the column declares the data column as binary, the subsequent one requires a longer binary length, which triggers a super table schema change.
```json ```json
st,t1=3,t2=4,t3=t3 c1=3i64,c5="pass" 1626006833639000000 st,t1=3,t2=4,t3=t3 c1=3i64,c5="pass" 1626006833639000000
st,t1=3,t2=4,t3=t3 c1=3i64,c5="passit" 1626006833640000000 st,t1=3,t2=4,t3=t3 c1=3i64,c5="passit" 1626006833640000000
``` ```
第一行中行协议解析会声明 c5 列是一个 binary(4)的字段,第二次行数据写入会提取列 c5 仍然是 binary 列,但是其宽度为 6,此时需要将 binary 的宽度增加到能够容纳 新字符串的宽度。 The first line of the line protocol parsing will declare column c5 is a binary(4) field, the second line data write will extract column c5 is still a binary column. Still, its width is 6, then you need to increase the width of the binary to be able to accommodate the new string.
```json ```json
st,t1=3,t2=4,t3=t3 c1=3i64 1626006833639000000 st,t1=3,t2=4,t3=t3 c1=3i64 1626006833639000000
st,t1=3,t2=4,t3=t3 c1=3i64,c6="passit" 1626006833640000000 st,t1=3,t2=4,t3=t3 c1=3i64,c6="passit" 1626006833640000000
``` ```
第二行数据相对于第一行来说增加了一个列 c6,类型为 binary(6)。那么此时会自动增加一个列 c6, 类型为 binary(6)。 The second row of data has an additional column c6 of type binary(6) compared to the first row. Then a column c6 of type binary(6) is automatically added at this point.
## 写入完整性 ## Write integrity
TDengine 提供数据写入的幂等性保证,即您可以反复调用 API 进行出错数据的写入操作。但是不提供多行数据写入的原子性保证。即在多行数据一批次写入过程中,会出现部分数据写入成功,部分数据写入失败的情况。 TDengine provides idempotency guarantees for data writes, i.e., you can repeatedly call the API to write data with errors. However, it does not give atomicity guarantees for writing multiple rows of data. During the process of writing numerous rows of data in one batch, some data will be written successfully, and some data will fail.
## 错误码 ## Error code
如果是无模式写入过程中的数据本身错误,应用会得到 TSDB_CODE_TSC_LINE_SYNTAX_ERROR If it is an error in the data itself during the schemaless writing process, the application will get TSDB_CODE_TSC_LINE_SYNTAX_ERROR
错误信息,该错误信息表明错误发生在写入文本中。其他的错误码与原系统一致,可以通过 error message, which indicates that the error occurred in writing. The other error codes are consistent with the original system and can be obtained via the `taos_errstr(`) to get the specific cause of the error.
taos_errstr 获取具体的错误原因。
label: Schemaless 写入 label: Schemaless writing
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
title: Reference title: Reference
--- ---
参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。 The reference guide is the most detailed introduction to TDengine itself, TDengine's various language connectors, and the tools that come with it.
```mdx-code-block ```mdx-code-block
import DocCardList from '@theme/DocCardList'; import DocCardList from '@theme/DocCardList';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册