You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "citrusreticulata (via GitHub)" <gi...@apache.org> on 2023/06/17 16:53:03 UTC

[GitHub] [iotdb] citrusreticulata opened a new pull request, #10197: use Boolean for isAligned

citrusreticulata opened a new pull request, #10197:
URL: https://github.com/apache/iotdb/pull/10197

   修改了isAligned属性的存储方式,由原本的boolean改为Boolean,因此可以存储空值。 注意事项如下:
   
   ## 目的
   目的是将只含有视图的设备,其isAligned值显示为`null`。
   
   ### 修改范围
   只修改了MeasurementPath 和DeviceInfo中的存储值,其他地方是没变的。
   但其实为了达到目的,只需要改动DeviceInfo这部分;MeasurementPath是顺带改了,修改了成员变量,但对外获取isAligned的接口没变(详见下一小节)。
   
   ### 尽可能减少了对原有系统的冲击
   Measurement获取isUnderAlignedEntity时使用的函数返回值依旧为boolean,不可能为空,因为返回前做了判断;IDeviceMNode的isAligned接口保持不变,返回值依旧为boolean,同样是在返回前做了费控判断。
   **注意,为空时默认返回false**,这和原有系统行为一致,原本的纯视图设备isAligned返回false。
   
   ## 修改了序列化方法。
   新增readBoolObject用于读取Boolean类,写入则使用的是原有接口write。为了保证兼容性,true序列化为1,false序列化为0,空值序列化为2
   .需要注意的是,序列化Boolean时没有使用readObject或者write object这种接口,这是为了兼容旧系统。
    **没能找到对DeviceNode的反序列化方法,这里可能该漏了**,但实际测试时,重启时发现null值的保存是成功的。
   
   ## 关于isAligned的状态的转化。 
   不使用视图时,isAligned只可能为true或者false;
   创建视图并且自动创建了设备时,说明该设备之前没有measurement作为孩子,所以这个视图是第一个作为孩子的measurement,因此它的isAligned是null;删除一个设备下所有非视图序列并且保留视图时,isAligned自动转换为null。
   
   做了本地测试如下:
   
   d01、d03是非对齐设备,d02和d04是对齐设备。
   
   1. 在d01、d02创建时间序列显示正常
   ```
   IoTDB> create timeseries root.db.d01.s01 INT32 encoding=RLE;
   Msg: The statement is executed successfully.
   IoTDB> create timeseries root.db.d01.s02 INT32 encoding=RLE;
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> create aligned timeseries root.db.d02(s01 INT32 encoding=RLE, s02 INT32 encoding=RLE);
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> show devices;
   +-----------+---------+
   |     Device|IsAligned|
   +-----------+---------+
   |root.db.d01|    false|
   |root.db.d02|     true|
   +-----------+---------+
   Total line number = 2
   It costs 0.010s
   IoTDB>
   ```
   
   2. 在已有序列的设备d01、d02下创建视图都ok
   ```
   IoTDB> create view root.db.d01.s_view AS root.db.d01.s01;
   Msg: The statement is executed successfully.
   IoTDB> create view root.db.d02.s_view AS root.db.d02.s01;
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> show devices;
   +-----------+---------+
   |     Device|IsAligned|
   +-----------+---------+
   |root.db.d01|    false|
   |root.db.d02|     true|
   +-----------+---------+
   Total line number = 2
   It costs 0.013s
   IoTDB>
   ```
   
   3. 创建只含有视图的设备d03、d04,show device显示null
   ```
   IoTDB> create view root.db.d03.s_view AS root.db.d01.s01;
   Msg: The statement is executed successfully.
   IoTDB> create view root.db.d04.s_view AS root.db.d01.s01;
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> show devices;
   +-----------+---------+
   |     Device|IsAligned|
   +-----------+---------+
   |root.db.d01|    false|
   |root.db.d03|     null|
   |root.db.d02|     true|
   |root.db.d04|     null|
   +-----------+---------+
   Total line number = 4
   It costs 0.017s
   IoTDB>
   ```
   
   4. 在只含有视图的设备d03下创建非对齐时间序列,在只含有视图的设备d04下创建对齐时间序列
   ```
   IoTDB> create timeseries root.db.d03.s01 INT32 encoding=RLE;
   Msg: The statement is executed successfully.
   IoTDB> create aligned timeseries root.db.d04(s01 INT32 encoding=RLE);
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> show devices;
   +-----------+---------+
   |     Device|IsAligned|
   +-----------+---------+
   |root.db.d01|    false|
   |root.db.d03|    false|
   |root.db.d02|     true|
   |root.db.d04|     true|
   +-----------+---------+
   Total line number = 4
   It costs 0.015s
   IoTDB>
   ```
   
   5. 删除d03和d04下所有时间序列(不删除视图)
   ```
   IoTDB> delete timeseries root.db.d03.s01;
   Msg: The statement is executed successfully.
   IoTDB> delete timeseries root.db.d04.s01;
   Msg: The statement is executed successfully.
   IoTDB>
   IoTDB> show devices;
   +-----------+---------+
   |     Device|IsAligned|
   +-----------+---------+
   |root.db.d01|    false|
   |root.db.d03|     null|
   |root.db.d02|     true|
   |root.db.d04|     null|
   +-----------+---------+
   Total line number = 4
   It costs 0.017s
   IoTDB>
   
   ```
   


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


[GitHub] [iotdb] MarcosZyk merged pull request #10197: Support show isAligned as null when showing devices with no timeseries but view

Posted by "MarcosZyk (via GitHub)" <gi...@apache.org>.
MarcosZyk merged PR #10197:
URL: https://github.com/apache/iotdb/pull/10197


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