Class CachedMTreeStore
- java.lang.Object
-
- org.apache.iotdb.db.metadata.mtree.store.CachedMTreeStore
-
- All Implemented Interfaces:
IMTreeStore
public class CachedMTreeStore extends java.lang.Object implements IMTreeStore
-
-
Constructor Summary
Constructors Constructor Description CachedMTreeStore(org.apache.iotdb.commons.path.PartialPath rootPath, int schemaRegionId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMNodeaddChild(IMNode parent, java.lang.String childName, IMNode child)voidclear()clear all the data of MTreeStore in memory and disk.booleancreateSnapshot(java.io.File snapshotDir)voiddeleteChild(IMNode parent, java.lang.String childName)This method will delete a node from MTree, which means the corresponding subTree will be deleted.IMNodegetChild(IMNode parent, java.lang.String name)Get the target child node from parent.IMNodeIteratorgetChildrenIterator(IMNode parent)IMNodegetRoot()booleanhasChild(IMNode parent, java.lang.String name)voidpin(IMNode node)Currently, this method is only used for pin node get from mNodeCache.voidsetAlias(IMeasurementMNode measurementMNode, java.lang.String alias)IEntityMNodesetToEntity(IMNode node)IMNodesetToInternal(IEntityMNode entityMNode)voidunPin(IMNode node)UnPin MNode release the node from this thread/task's usage.voidunPinPath(IMNode node)voidupdateMNode(IMNode node)The upside modification on node in MTree or MManager should be sync to MTreeStore explicitly.
-
-
-
Method Detail
-
getRoot
public IMNode getRoot()
- Specified by:
getRootin interfaceIMTreeStore
-
hasChild
public boolean hasChild(IMNode parent, java.lang.String name) throws org.apache.iotdb.commons.exception.MetadataException
- Specified by:
hasChildin interfaceIMTreeStore- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getChild
public IMNode getChild(IMNode parent, java.lang.String name) throws org.apache.iotdb.commons.exception.MetadataException
Get the target child node from parent. The parent must be pinned before invoking this method. The method will try to get child node from cache. If there's no matched node in cache or the node is not cached, which means it has been evicted, then this method will retrieve child node from schemaFile The returned child node will be pinned. If there's no matched child with the given name, this method will return null.- Specified by:
getChildin interfaceIMTreeStore- Parameters:
parent- parent nodename- the name or alias of the target child- Returns:
- the pinned child node
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getChildrenIterator
public IMNodeIterator getChildrenIterator(IMNode parent) throws org.apache.iotdb.commons.exception.MetadataException
- Specified by:
getChildrenIteratorin interfaceIMTreeStore- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
addChild
public IMNode addChild(IMNode parent, java.lang.String childName, IMNode child)
- Specified by:
addChildin interfaceIMTreeStore
-
deleteChild
public void deleteChild(IMNode parent, java.lang.String childName) throws org.apache.iotdb.commons.exception.MetadataException
This method will delete a node from MTree, which means the corresponding subTree will be deleted. Before deletion, the measurementMNode in this subtree should be collected for updating statistics in MManager. The deletion will delete subtree in schemaFile first and then delete the node from memory. The target node and its ancestors should be pinned before invoking this problem.- Specified by:
deleteChildin interfaceIMTreeStore- Parameters:
parent- the parent node of the target nodechildName- the name of the target node- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
updateMNode
public void updateMNode(IMNode node) throws org.apache.iotdb.commons.exception.MetadataException
The upside modification on node in MTree or MManager should be sync to MTreeStore explicitly. Must pin the node first before update- Specified by:
updateMNodein interfaceIMTreeStore- Parameters:
node- the modified node- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setToEntity
public IEntityMNode setToEntity(IMNode node) throws org.apache.iotdb.commons.exception.MetadataException
- Specified by:
setToEntityin interfaceIMTreeStore- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setToInternal
public IMNode setToInternal(IEntityMNode entityMNode) throws org.apache.iotdb.commons.exception.MetadataException
- Specified by:
setToInternalin interfaceIMTreeStore- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setAlias
public void setAlias(IMeasurementMNode measurementMNode, java.lang.String alias) throws org.apache.iotdb.commons.exception.MetadataException
- Specified by:
setAliasin interfaceIMTreeStore- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
pin
public void pin(IMNode node) throws org.apache.iotdb.commons.exception.MetadataException
Currently, this method is only used for pin node get from mNodeCache. Pin MNode in memory makes the pinned node and its ancestors not be evicted during cache eviction. The pinned MNode will occupy memory resource, thus this method will check the memory status which may trigger cache eviction or flushing.- Specified by:
pinin interfaceIMTreeStore- Parameters:
node-- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
unPin
public void unPin(IMNode node)
UnPin MNode release the node from this thread/task's usage. If none thread/task is using this node or pinning this node, it will be able to evict this node from memory. Since unpin changes the node's status, the memory status will be checked and cache eviction and flushing may be tirgger.- Specified by:
unPinin interfaceIMTreeStore- Parameters:
node-
-
unPinPath
public void unPinPath(IMNode node)
- Specified by:
unPinPathin interfaceIMTreeStore
-
clear
public void clear()
clear all the data of MTreeStore in memory and disk.- Specified by:
clearin interfaceIMTreeStore
-
createSnapshot
public boolean createSnapshot(java.io.File snapshotDir)
- Specified by:
createSnapshotin interfaceIMTreeStore
-
-