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 2020/06/28 06:55:30 UTC

[GitHub] [incubator-iotdb] qiaojialin commented on a change in pull request #1406: Update AlignByDeviceQuery Doc

qiaojialin commented on a change in pull request #1406:
URL: https://github.com/apache/incubator-iotdb/pull/1406#discussion_r446604705



##########
File path: docs/zh/SystemDesign/DataQuery/AlignByDeviceQuery.md
##########
@@ -74,20 +78,85 @@ SELECT s1, "1", *, s2, s5 FROM root.sg.d1, root.sg.* WHERE time = 1 AND s1 < 25
 
 **该阶段所做的主要工作为生成查询对应的** `AlignByDevicePlan`,**填充其中的变量信息。**
 
-首先解释一下 `transformQuery()` 方法中一些重要字段的含义(与 AlignByDevicePlan 中重复的字段见上文):
-
-- prefixPaths, suffixPaths:前者为 FROM 子句中的前缀路径,示例中为 `[root.sg.d1, root.sg.*]`; 后者为 SELECT 子句中的后缀路径,示例中为 `[s1, "1", *, s2, s5]`.
-- devices:对前缀路径去通配符和设备去重后得到的设备列表,示例中为 `[root.sg.d1, root.sg.d2]`。
-- measurementSetOfGivenSuffix:中间变量,记录某一 suffix 对应的 measurement,示例中,对于后缀 \*, `measurementSetOfGivenSuffix = {s1,s2}`,对于后缀 s1, `measurementSetOfGivenSuffix = {s1}`;
-
-接下来介绍 AlignByDevicePlan 的计算过程:
+其主要将 SELECT 语句中得到的后缀路径与 FROM 子句中的前缀路径进行拼接,从而计算出查询的 Measurement 及其类型、数据类型,计算流程如下:
 
-1. 检查查询类型是否为 groupByTimePlan, fillQueryPlan, aggregationPlan 这三类查询中的一种,如果是则对相应的变量进行赋值,并更改 `AlignByDevicePlan` 的查询类型。
-2. 遍历 SELECT 后缀路径,对每一个后缀路径设置一个中间变量为 `measurementSetOfGivenSuffix`,用来记录该后缀路径对应的所有 measurement。如果后缀路径以单引号或双引号开头,则直接在 `measurements` 中增加该值,并记录其类型为 `Constant` 类型。
-3. 否则将设备列表与该后缀路径拼接,得到完整的路径,如果拼接后的路径不存在,需要进一步判断该 measurement 是否在其它设备中存在,如果都没有则暂时识别为 `NonExist`,如果后续出现设备存在该 measurement,则覆盖 `NonExist` 值为 `Exist`。
-4. 如果拼接后路径存在,则证明 measurement 是 `Exist` 类型,需要检验数据类型的一致性,不满足返回错误信息,满足则记录下该 Measurement,对 `measurementSetOfGivenSuffix` 等进行更新。
-5. 在一层 suffix 循环结束后,将该层循环中出现的 `measurementSetOfGivenSuffix` 加入 `measurements` 中。在整个循环结束后,将循环中得到的变量信息赋值到 AlignByDevicePlan 中。此处得到的 measurements 列表是未经过去重的,在生成 `ColumnHeader` 时将进行去重。
-6. 最后调用 `concatFilterByDevice()` 方法计算 `deviceToFilterMap`,得到将每个设备分别拼接后对应的 Filter 信息。
+```java
+  // 首先遍历后缀路径
+  for (int i = 0; i < suffixPaths.size(); i++) {
+    Path suffixPath = suffixPaths.get(i);
+    // 用于记录某一后缀路径对应的 measurement,示例见下文

Review comment:
       ```suggestion
       // 用于记录此后缀路径对应的所有 measurement,示例见下文
   ```




----------------------------------------------------------------
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.

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