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 2019/08/21 08:04:48 UTC
[GitHub] [incubator-iotdb] LeiRui opened a new pull request #347: fix a bug
of TsFileResource updateTime
LeiRui opened a new pull request #347: fix a bug of TsFileResource updateTime
URL: https://github.com/apache/incubator-iotdb/pull/347
Bug Description:
When recovering a TsFile's `device -> start time` and `device -> end time` map and the TsFile's resource file happens not to exist, the TsFile itself will be read to update the start and end time map instead. It is implemented by `TsFileRecoverPerformer.recover` as follows:
```
for (TsDeviceMetadataIndex index : deviceMetadataIndexList) {
TsDeviceMetadata deviceMetadata = reader.readTsDeviceMetaData(index);
List<ChunkGroupMetaData> chunkGroupMetaDataList = deviceMetadata.getChunkGroupMetaDataList();
for (ChunkGroupMetaData chunkGroupMetaData : chunkGroupMetaDataList) {
for (ChunkMetaData chunkMetaData : chunkGroupMetaData.getChunkMetaDataList()) {
tsFileResource.updateTime(chunkGroupMetaData.getDeviceID(), chunkMetaData.getStartTime());
tsFileResource.updateTime(chunkGroupMetaData.getDeviceID(), chunkMetaData.getEndTime());
}
}
}
```
The `updateTime` function uses the first-coming value as the startTime:
```
public void updateTime(String deviceId, long time) {
startTimeMap.putIfAbsent(deviceId, time);
Long endTime = endTimeMap.get(deviceId);
if (endTime == null || endTime < time) {
endTimeMap.put(deviceId, time);
}
}
```
So when root.vehicle.d0 has a chunkgroup of chunkMetadata listed as:
s3: startTime=3000, endTime=10000;
s1: startTime=1000, endTime=10000;
s2: startTime=2000, endTime=10000;
By the current code, the updated start time will be the first coming 3000, which is not correct.
---
By the way, I also change `updateTime` in `LogReplayer.replayLogs` to `updateStartTime` and `updateEndTime`. If there is something I haven't noticed, please tell me.
----------------------------------------------------------------
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
With regards,
Apache Git Services