You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

1. 现有lastCache实现

1.1. 存储方式

在MeasurementMNode中存储一个TimeValuePair;

由MeasurementMNode提供操作接口。

1.2. lastCache触发时机

  1. insertPlan执行完后updateLastCache
  2. last查询,先从缓存中查找,若miss则从文件获取数据后updateLastCache
  3. delete数据时,根据删除数据的起始时间清空lastCache
  4. upload Tsfile时,由于数据更新,lastCache可能失效,故清空

1.3. lastCache操作执行过程

  1. getLastCache:首先通过调用getNodeByPath,获取指定路径/序列对应的 MeasurementMNode,template对应的序列会封装一个临时节点对象,调用MeasurementMNode的get接口
  2. updateLastCache:与getLastCache类似
  3. resetCache:storageGroupProccessor通过device获取子节点,调用子节点的reset接口

2. 适配Template

2.1. Template的lastCache失败原因

获取template中序列对应的measurementMNode时,仅返回临时变量,对临时MeasurementMNode中lastCache的操作并未保存回MTree。

2.2. 适配方案

由于Template由EntityMNode进行使用,故在EntityMNode中增加Map<String, ILastCacheEntry>字段,用于存储template中schema对应的lastCache。

对MeasurementMNode中的lastCache进行操作时,先判断该节点是否是为了template而创建的临时节点,如果是,则先拿到entityMNode中的lastCache引用,然后再进行操作。

3. 适配Vector

3.1. Vector的lastCache失败原因

  1. MeasurementMNode中简单的TimeValuePair无法满足多元分量的lastCache的存储。
  2. LastQueryPlan的执行过程中,path被转化为vectorPartiaPath之后,仅到vector层,未基于subsensorPath进行lastCache查找
  3. insertPlan执行过程中,对于aligned plan不进行lastCache的更新

3.2. 适配方案

  1. 建立VectorLastCacheValue,存储多元时间序列的lastCache;由于目前last查找是查找最新的不为空值的时间点,故不同分量的LastCache时间可能不同,得存多个timestamp和 TsPrimitiveValue。
  2. 修改LastQueryExecutor中seriesPath的使用,使其用到subsensor层
  3. 实现insertPlan过程的vector lastCache跟新

4. LastCache方案详情

4.1. 类设计

  1. 为了提升功能代码的内聚性,将LastCache功能与MNode解耦,设计ILastCacheEntry接口,由LasCacheEntry进行实现并封装lastCache数据,同时提供简单的lastCacheValue操作
  2. 新建LastCacheManager,将MManager中与lastCache相关的操作代码尽可能迁移至 LastCacheManager,MManager中仅保留必要的mtree调用以及mnode获取操作。
  3. EntityMNode在增加用于template序列lastCache存储的Map<String, ILastCacheEntry>字段,MeasurementMNode中将原来的TimeValuePair替换为ILastCacheEntry


4.2. LastCache扩展方向

  1. LastCache缓存多条数据,LastCacheEntry向BatchedLastCacheEntry扩展
  2. 底层实现重写,如lastCache存储Memtable中最新的批量数据
  • No labels