-
Notifications
You must be signed in to change notification settings - Fork 974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IOTDB-536] Process about nonExistMeasurement and ConstantMeasurement in AlignByDevice is complex and not intuitive #874
Conversation
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
Outdated
Show resolved
Hide resolved
// update measurementSetOfGivenSuffix and measurement location | ||
if (measurementSetOfGivenSuffix.add(measurementChecked)) { | ||
loc++; | ||
// update measurementSetOfGivenSuffix and Normal measurement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the pathForDataType to pathWithAggregation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry? Apparently it may without aggregation.
* The data type is considered as String and the value is considered is the same with measurement name. | ||
*/ | ||
public enum measurementType { | ||
Normal, NonExist, Const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normal, NonExist, Const; | |
Exist, NonExist, Constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* Const: the measurements that have quotation mark. e.g. "abc",'11'. | ||
* The data type is considered as String and the value is considered is the same with measurement name. | ||
*/ | ||
public enum measurementType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public enum measurementType { | |
public enum MeasurementType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
…nByDevicePlan.java Co-Authored-By: Jialin Qiao <qjl16@mails.tsinghua.edu.cn>
…tdb into AlignByDeviceLogic
|
||
## 设计原理 | ||
|
||
按设备对齐查询其实现原理主要是计算出查询中每个设备对应的映射值和过滤条件,然后将查询按设备分别进行,最后将结果集拼装并返回。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
什么是映射值?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
|
||
首先解释一下 AlignByDevicePlan 中一些重要字段的含义: | ||
- measurements:查询中出现的 measurement 列表。 | ||
- dataTypeMapping: 该变量继承自基类 QueryPlan,其主要作用是在计算每个设备的执行路径时,提供此次查询的 paths 对应的数据类型。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把定义加上吧,比如map啥的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
- dataTypeMapping: 该变量继承自基类 QueryPlan,其主要作用是在计算每个设备的执行路径时,提供此次查询的 paths 对应的数据类型。 | ||
- deviceToMeasurementsMap, deviceToFilterMap: 这两个字段分别用来存储设备对应的测点和过滤条件。 | ||
- measurementDataTypeMap:AlignByDevicePlan 要求不同设备的同名 sensor 数据类型一致,该字段是一个 `measurementName -> dataType` 的 Map 结构,用来验证同名 sensor 的数据类型一致性。如 `root.sg.d1.s1` 和 `root.sg.d2.s1` 应该是同一数据类型。 | ||
- measurementType:记录三种 measurement 类型。在任何设备中都不存在的 measurement 为 `NonExist` 类型;有单引号或双引号的 measurement 为 `Constant` 类型;不属于以上两种的正常 measurement 为 `Exist` 类型。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- measurementType:记录三种 measurement 类型。在任何设备中都不存在的 measurement 为 `NonExist` 类型;有单引号或双引号的 measurement 为 `Constant` 类型;不属于以上两种的正常 measurement 为 `Exist` 类型。 | |
- measurementType:记录三种 measurement 类型。在任何设备中都不存在的 measurement 为 `NonExist` 类型;有单引号或双引号的 measurement 为 `Constant` 类型;存在的 measurement 为 `Exist` 类型。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work and crystal code. Detailed docs make me looking forward to try this feature.
2. 新建一个添加了时间戳的 `RowRecord`,向其中加入设备列,先根据 `executeColumns` 与得到的结果建立一个由 `measurementName -> Field` 的 Map 结构 `currentColumnMap`. | ||
3. 之后只需要遍历去重后的 `measurements` 列表,判断其类型,如果类型为 `Exist` 则根据 measurementName 从 `currentColumnMap` 中取得其对应的结果,如果没有则设为 `null`;如果是 `NonExist`类型,则直接设为 `null`; 如果是 `Constant` 类型,则将 `measureName` 作为该列的值。 | ||
|
||
在根据变换后的 `RowRecord` 写入输出数据流后,即可将结果集返回。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
再根据变换后的 RowRecord
写入输出数据流后
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。
Optimize the process about nonExistMeasurement and ConstantMeasurement in AlignByDeviceQuery. Modify the data structure to a map recording the kind of measurement, which trim about 150 lines of code in AlignByDeviceQuery.