Class CachedMTreeStore

  • All Implemented Interfaces:
    IMTreeStore

    public class CachedMTreeStore
    extends java.lang.Object
    implements IMTreeStore
    • Constructor Detail

      • CachedMTreeStore

        public CachedMTreeStore​(org.apache.iotdb.commons.path.PartialPath rootPath,
                                int schemaRegionId)
                         throws org.apache.iotdb.commons.exception.MetadataException,
                                java.io.IOException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
    • Method Detail

      • hasChild

        public boolean hasChild​(IMNode parent,
                                java.lang.String name)
                         throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        hasChild in interface IMTreeStore
        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:
        getChild in interface IMTreeStore
        Parameters:
        parent - parent node
        name - 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:
        getChildrenIterator in interface IMTreeStore
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • 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:
        deleteChild in interface IMTreeStore
        Parameters:
        parent - the parent node of the target node
        childName - 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:
        updateMNode in interface IMTreeStore
        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:
        setToEntity in interface IMTreeStore
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setToInternal

        public IMNode setToInternal​(IEntityMNode entityMNode)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        setToInternal in interface IMTreeStore
        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:
        setAlias in interface IMTreeStore
        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:
        pin in interface IMTreeStore
        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:
        unPin in interface IMTreeStore
        Parameters:
        node -
      • clear

        public void clear()
        clear all the data of MTreeStore in memory and disk.
        Specified by:
        clear in interface IMTreeStore
      • createSnapshot

        public boolean createSnapshot​(java.io.File snapshotDir)
        Specified by:
        createSnapshot in interface IMTreeStore