...
private PartialPath path; // 前缀路径 private long startTime; // 开始时间 private long endTime; // 结束时间 |
3. FileIndex
// 获得与查询相关的FileIndexEntries Map<tsFilePath, TimeIndexEntry[]> filterByPath(PartialPath path, Filter timeFilter) // 为路径增加索引,适用场景:(1)文件刷盘封口;(2)版本升级 void createIndexForFiles(FileIndexEntries fileIndexEntries) // 为路径删除索引,适用场景:(1)删除文件;(2)根据TTL标记失效的文件 void deleteIndexOfFiles(FileIndexEntries fileIndexEntries) |
4. FileIndexManager
public class FileIndexManager { private Map<PartialPath, FileIndex> seqIndices; private Map<PartialPath, FileIndex> unseqIndices; private final ReentrantReadWriteLock lock; private static class FileIndexManagerHolder { private FileIndexManagerHolder() { private static final FileIndexManager INSTANCE = new FileIndexManager(); public static FileIndexManager getInstance() { private FileIndexManager() { public boolean init() {...} public void addSeqIndexer(PartialPath storageGroup, FileIndex fileTimeIndexer) { ... } public void addUnseqIndexer(PartialPath storageGroup, FileIndex fileTimeIndexer) { ... } public void deleteSeqIndexer(PartialPath storageGroup) { ... } public void deleteUnseqIndexer(PartialPath storageGroup) { ... } public FileIndex getSeqIndexer(PartialPath storageGroup) { ... } public FileIndex getUnseqIndexer(PartialPath storageGroup) { ... } // 将TsFileResource转化为FileIndexEntries,用于版本升级 public static FileIndexEntries convertFromTsFileResource(TsFileResource resource) {... } } |
4. 第二步的修改(后续)涉及到【封口文件句柄SealedTsfileResource】和【未封口文件句柄UnsealedTsfileResource】
...
(1) 第一步接口化(本次)的修改中,可以从TsFileResource中转移走的字段:
protected long[] startTimes; // 开始时间列表 protected long[] endTimes; // 结束时间列表,未封口则为 Long.MIN_VALUE protected Map<String, Integer> deviceToIndex; // device设备名 => 开始 / 结束时间列表index |
(2) 目前TsFileResource文件句柄保留的功能和字段:
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 Set<Long> historicalVersions // for tracking the merge history of a TsFile 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 |
三、涉及到使用文件索引的操作
【数据的插入和批量插入】
...