一、TsFileResource及接口设计修改目标
1. 每个数据文件 TsFile 在内存中对应一个文件索引信息TsFileResource,供查询使用。
...
TsFileResource 的已有接口不变。后续“实现”的全部修改仅针对 ITimeIndex。
二、阶段1详细设计:新增和修改的数据结构
具体而言,涉及到数据结构如下:
1. DeviceTimeIndex (后续“实现”的全部修改仅针对 TimeIndex)
...
Map<String, String> cachedDevicePool // for reducing the String number in memory File file // tsfile TsFileProcessor processor 【未封口】 ModificationFile modFile // modification file boolean closed【未封口】 boolean deleted【未封口】 boolean isMerging TsFileLock tsFileLock List<ChunkMetadata> chunkMetadataList // 【未封口】chunk metadata list of unsealed tsfile. Only be set in a temporal TsFileResource in a query process. List<ReadOnlyMemChunk> readOnlyMemChunk // 【未封口】mem chunk data. Only be set in a temporal TsFileResource in a query process. TimeseriesMetadata timeSeriesMetadata // 【未封口】get TimeseriesMetadata of unsealed file List<TsFileResource> upgradedResources // 【升级】generated upgraded TsFile ResourceList used for upgrading v0.9.x/v1 -> 0.10/v2 UpgradeTsFileResourceCallBack upgradeTsFileResourceCallBack // 【升级】load upgraded TsFile Resources to storage group processor used for upgrading v0.9.x/v1 → 0.10/v2 boolean isSeq // 【升级】indicate if this tsfile resource belongs to a sequence tsfile or not used for upgrading v0.9.x/v1 -> 0.10/v2 TsFileResource originTsFileResource // 【未封口】current tsfile resource is a snapshot of the originTsFileResource. When we want to used the lock, we should try to acquire the lock of originTsFileResource long maxPlanIndex // for cluster, max index of plans executed within this TsFile long minPlanIndex // for cluster, min index of plans executed within this TsFile |
4. TsFileResource 文件结构
VERSION_NUMBER = 1 (1 byte) timeIndexType = 0 FileTimeIndex / 1 DeviceTimeIndex (1 byte) timeIndex (ITimeIndex)
maxPlanIndex (long) minPlanIndex (long) modFileName (String) |