You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/10/13 12:54:04 UTC

[GitHub] [iotdb] noorall commented on a change in pull request #4090: [IOTDB-1810]Compatibility of Apache IoTDB with InfluxDB - Compatibility scheme

noorall commented on a change in pull request #4090:
URL: https://github.com/apache/iotdb/pull/4090#discussion_r728030185



##########
File path: docs/zh/UserGuide/API/InfluxDB-Protocol.md
##########
@@ -33,3 +33,128 @@ InfluxDB influxDB = InfluxDBFactory.connect(openurl, username, password);
 InfluxDB influxDB = IoTDBInfluxDBFactory.connect(openurl, username, password);
 ```
 
+## 2.方案设计
+
+### 2.1 InfluxDB-Protocol适配器
+
+适配器是一个继承至InfluxDB基类的子类,实现了InfluxDB接口的所有方法,从而使InfluxDB原有的操作函数没有改变,但是会以IoTDB的协议写入IoTDB数据库中。
+
+![architecture-design](https://github.com/apache/iotdb-bin-resources/blob/main/docs/UserGuide/API/IoTDB-InfluxDB/architecture-design.png?raw=true)
+
+![class-diagram](https://github.com/apache/iotdb-bin-resources/blob/main/docs/UserGuide/API/IoTDB-InfluxDB/class-diagram.png?raw=true)
+
+
+### 2.2 数据格式转换
+
+#### 2.2.1 InfluxDB数据格式
+
+1. database: 数据库名。
+2. measurement: 测量指标名。
+3. tags : 各种有索引的属性。
+4. fields : 各种记录值(没有索引的属性)。
+
+![influxdb-data](https://github.com/apache/iotdb-bin-resources/blob/main/docs/UserGuide/API/IoTDB-InfluxDB/influxdb-data.png?raw=true)
+
+#### 2.2.2 IoTDB数据格式
+
+1. storage group: 存储组。
+2. path(time series ID):存储路径。
+3. measurement: 物理量。
+
+![iotdb-data](https://github.com/apache/iotdb-bin-resources/blob/main/docs/UserGuide/API/IoTDB-InfluxDB/iotdb-data.png?raw=true)
+
+#### 2.2.3 两者映射关系
+
+1. InfluxDB中的database和measurement可以看做IoTDB中的storage group。
+2. InfluxDB中的tags可以看做IoTDB中的path。
+3. InfluxDB中的fields可以看做IoTDB中measurement。
+
+![influxdb-vs-iotdb-data](https://github.com/apache/iotdb-bin-resources/blob/main/docs/UserGuide/API/IoTDB-InfluxDB/influxdb-vs-iotdb-data.png?raw=true)
+
+#### 2.2.4 转换中的问题
+1. 问题:InfluxDB中Tag的顺序不敏感,而在IoTDB中是敏感的。
+2. 关键点:需要记录每个tag对应的顺序,确保InfluxDB中label顺序不同的同一条时序对应到IoTDB中也是一条时序。
+3. 需要解决的事情:
+    1. 怎样映射tag key和它对应的order
+    2. 在不知道所有的label key的情况下,怎么维护他们之间的顺序
+
+### 2.3 解决方案
+
+#### 2.3.1 主要思想
+
+1. 内存中Map <Measurement, Map <Tag Key, Order> > table结构维护Tag之间的顺序
+2. InfluxDB中时序根据label顺序对应到IoTDB
+
+   | `root.TAG_INFO.database_name` | `root.TAG_INFO.measurement_name` | `root.TAG_INFO.tag_name` | `root.TAG_INFO.tag_order` |
+            | :---------------------------- | :------------------------------- | :----------------------- | :------------------------ |
+   | database                      | student                          | name                     | 0                         |
+   | database                      | student                          | phone                    | 1                         |
+   | database                      | student                          | sex                      | 2                         |
+   | database                      | student                          | address                  | 3                         |
+
+#### 2.3.2 实例
+
+a. 插入数据
+
+1. InfluxDB时序(database=database):
+
+   (1)student tags:{name=A,phone=B,sex=C} fields:{score=99}
+
+   (2)student tags:{address=D} fields:{score=98}
+
+   (3))student tags:{name=A,phone=B,sex=C,address=D} fields:{score=97}
+
+2. 简单对上述InfluxDB的时序进行解释,database是database;measurement是student;tag分别是name,phone、sex和address;field是score。

Review comment:
       databse=database可以换一下数据库的名称,例如database=xxx,不然后面的解释dattabase是database有点拗口




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org