private void prepareDeviceInfos() throws IOException {
    boolean canCacheDeviceInfo = resource.getStatus() != TsFileResourceStatus.UNCLOSED;
    if (deviceTimeIndex == null && compactionScheduleContext != null) {
      // get device info from cache
      deviceTimeIndex = compactionScheduleContext.getResourceDeviceInfo(this.resource);
    }
    if (deviceTimeIndex != null) {
      hasDetailedDeviceInfo = true;
      return;
    }
    ITimeIndex timeIndex = resource.getTimeIndex();
    if (timeIndex instanceof ArrayDeviceTimeIndex) {
      if (resource.isClosed()) {
        deviceTimeIndex = (ArrayDeviceTimeIndex) timeIndex;
      } else {
        deviceTimeIndex = new ArrayDeviceTimeIndex();
        for (IDeviceID device : ((ArrayDeviceTimeIndex) timeIndex).getDevices()) {
          deviceTimeIndex.updateStartTime(device, timeIndex.getStartTime(device).get());
          deviceTimeIndex.updateEndTime(device, timeIndex.getEndTime(device).get());
        }
      }
    } else {
      // deserialize resource file
      resource.readLock();
      try {
        // deleted file with degraded time index
        if (!resource.resourceFileExists()) {
          hasDetailedDeviceInfo = false;
          deviceTimeIndex = new ArrayDeviceTimeIndex();
          return;
        }
        deviceTimeIndex = CompactionUtils.buildDeviceTimeIndex(resource);
      } finally {
        resource.readUnlock();
      }
    }
    hasDetailedDeviceInfo = true;
    if (compactionScheduleContext != null && canCacheDeviceInfo) {
      compactionScheduleContext.addResourceDeviceTimeIndex(this.resource, deviceTimeIndex);
    }
  }
The TsFile is unsealed means there may be more data which will be inserted into this file.

@return Whether the TsFile is unsealed.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/utils/TsFileResourceCandidate.java