Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

类名

职责

StorageGroupProccessor

与MManager进行交互,在数据插入、数据删除以及上传新tsfile的时候清空对应序列的lastCache

LastQueryExecutor

Last查询执行类,调用MManager进行lastCache操作

MManager

  1. 对IoTDB的其他模块提供lastCache的操作接口
  2. 为LastCacheManager提供node查找功能

IEntityMNode与EntityMNode

实体节点,存储由物理量模板所表示的时间序列的lastCache,即Map<String, ILastCacheContainer>

IMeasurementMNode与MeasurementMNode

物理量节点,手动创建时间序列时产生,存储其表示的时间序列的lastCache

LastCacheManager

封装所有的lastCache处理逻辑,并向mmanager提供lastCache操作接口

ILastCacheContainer

最新点缓存项接口,声明最新点缓存的操作接口,该接口未来可向多条value缓存扩展

LastCacheContainer

实现ILastCacheContainer,定义对于一个最新点缓存值的基本操作

ILastCacheValue

最新点缓存值接口,声明

UnaryLastCacheValue

一元序列的最新点缓存值

VectorLastCacheValue

多元序列的最新点缓存值,存储各分量对应的最新点的时间戳与数值


MManager对外接口

功能接口解释


更新lastCache
public void updateLastCache(
PartialPath seriesPath,
TimeValuePair timeValuePair,
boolean highPriorityUpdate,
Long latestFlushedTime)

接收seriesPath作为参数,

可用于更新一元序列或多元序列分量的lastCache,

需传入一元序列全路径或多元序列分量的全路径

public void updateLastCache(
IMeasurementMNode node,
TimeValuePair timeValuePair,
boolean highPriorityUpdate,
Long latestFlushedTime)

接收单个MeasurementMNode作为参数,

用于更新一元序列的lastCache

public void updateLastCache(
IMeasurementMNode node,
String subMeasurement,
TimeValuePair timeValuePair,
boolean highPriorityUpdate,
Long latestFlushedTime)

接收MeasurementMNode、subMeasurement作为参数,

用于更新多元序列分量的lastCache

获取lastCache
public TimeValuePair getLastCache(PartialPath seriesPath)

接收seriesPath作为参数,

可用于获取一元序列或多元序列分量的lastCache,

需传入一元序列全路径或多元序列分量的全路径

public TimeValuePair getLastCache(IMeasurementMNode node)

接收单个MeasurementMNode作为参数,

用于获取一元序列的lastCache

public TimeValuePair getLastCache(
IMeasurementMNode node,
String subMeasurement)

接收MeasurementMNode、subMeasurement作为参数,

用于获取多元序列分量的lastCache

删除lastCache
public void resetLastCache(PartialPath seriesPath)

接收seriesPath作为参数,

可用于清除一元序列或多元序列分量的lastCache,

需传入一元序列全路径或多元序列分量的全路径

public void deleteLastCacheByDevice(PartialPath deviceId)
用于清除一个device下所有序列的lastCache
public void deleteLastCacheByDevice(
PartialPath deviceId,
PartialPath originalPath,
long startTime,
long endTime)
由于清除一个device下匹配originalPath的、且last值在startTime和endTime之间的所有序列的lastCache

3. 调用场景及执行过程

3.1. last cache查询

...

  1. LastCacheAccessor通过调用MManager.getNodeByPath(PartialPath path)获取序列对应的MeasurementMNode
    1. 如果是普通一元序列,则正常返回MeasurementMNode
    2. 如果是template表示的序列,则将对应的序列schema与封装为临时的MeasurementMNode返回
    3. 如果是多元序列,则传入的路径应是目标分量的全路径,返回该多元序列对应的MeasurementMNode如果是多元序列,返回该多元序列对应的MeasurementMNode
    4. 如果是template表示的多元序列,则结合b和c两种处理方式,b中封装的schema将为VectorMeasurementSchema
  2. LastCacheAccessor调用MManager.getLastCache
    1. 若1中的操作成功,则可传入node,避免MManager对measurementMNode的二次查找,并且多元序列场景中path需额外传入具体的目标分量。
    2. 若1中节点获取失败,则尝试仅基于path查找lastCache结果,此时MManager会基于path进行MeasurementMNode查找
  3. MManager调用LastCacheMManager的getLastCache接口
    1. 判断是否为template表示的序列,即判断传入的measurementMNode的parent EntityMNode是否有对应的子节点,若无则从EntityMNode中获取到LastCacheContainer并赋予该measurementMNode
    2. 如果是一元序列,获取measurementMNode中的lastCacheContainer后获取其持有的lastCacheValue
    3. 如果是多元序列,先获取分量名,再从schema中获取分量的index然后再从lastCacheContainer获取lastCacheValue

...