Class StorageGroupSchemaManager

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkStorageGroupByPath​(org.apache.iotdb.commons.path.PartialPath path)
      Check whether the given path contains a storage group
      void clear()  
      void deleteStorageGroup​(org.apache.iotdb.commons.path.PartialPath storageGroup)
      Delete storage groups of given paths from MTree.
      IStorageGroupMNode ensureStorageGroupByStorageGroupPath​(org.apache.iotdb.commons.path.PartialPath storageGroup)
      Different with LocalConfigNode.ensureStorageGroup, this method won't init storageGroup resources and the input is the target storage group path.
      void forceLog()  
      java.util.List<IStorageGroupMNode> getAllStorageGroupNodes()
      Get all storage group MNodes
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getAllStorageGroupPaths()
      Get all storage group paths
      org.apache.iotdb.commons.path.PartialPath getBelongedStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
      Get storage group name by path
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getBelongedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get the storage group that given path pattern matches or belongs to.
      org.apache.iotdb.tsfile.utils.Pair<java.util.Set<java.lang.String>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodeNameInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get child node path in the next level of the given path pattern.
      org.apache.iotdb.tsfile.utils.Pair<java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodePathInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get child node path in the next level of the given path pattern.
      static StorageGroupSchemaManager getInstance()  
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getInvolvedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)  
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getMatchedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get all storage group matching given path pattern.
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.commons.path.PartialPath>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getNodesListInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, LocalSchemaProcessor.StorageGroupFilter filter)
      To collect nodes in the given level for given path pattern.
      IStorageGroupMNode getStorageGroupNodeByPath​(org.apache.iotdb.commons.path.PartialPath path)
      Get storage group node by path.
      int getStorageGroupNum​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      To calculate the count of storage group for given path pattern.
      java.util.Map<java.lang.String,​java.util.List<org.apache.iotdb.commons.path.PartialPath>> groupPathByStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
      For a path, infer all storage groups it may belong to.
      void init()  
      boolean isStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
      Check if the given path is storage group or not.
      boolean isStorageGroupAlreadySet​(org.apache.iotdb.commons.path.PartialPath path)
      Check whether the storage group of given path is set.
      void recoverLog()  
      void setStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
      Set storage group of the given path to MTree.
      void setTTL​(org.apache.iotdb.commons.path.PartialPath storageGroup, long dataTTL)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

        public void init()
                  throws org.apache.iotdb.commons.exception.MetadataException,
                         java.io.IOException
        Specified by:
        init in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • recoverLog

        public void recoverLog()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setStorageGroup

        public void setStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Set storage group of the given path to MTree.
        Specified by:
        setStorageGroup in interface IStorageGroupSchemaManager
        Parameters:
        path - storage group path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • ensureStorageGroupByStorageGroupPath

        public IStorageGroupMNode ensureStorageGroupByStorageGroupPath​(org.apache.iotdb.commons.path.PartialPath storageGroup)
                                                                throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Different with LocalConfigNode.ensureStorageGroup, this method won't init storageGroup resources and the input is the target storage group path.
        Specified by:
        ensureStorageGroupByStorageGroupPath in interface IStorageGroupSchemaManager
        Parameters:
        storageGroup - storage group path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • deleteStorageGroup

        public void deleteStorageGroup​(org.apache.iotdb.commons.path.PartialPath storageGroup)
                                throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Delete storage groups of given paths from MTree. Log format: "delete_storage_group,sg1,sg2,sg3"
        Specified by:
        deleteStorageGroup in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setTTL

        public void setTTL​(org.apache.iotdb.commons.path.PartialPath storageGroup,
                           long dataTTL)
                    throws org.apache.iotdb.commons.exception.MetadataException,
                           java.io.IOException
        Specified by:
        setTTL in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • getBelongedStorageGroups

        public java.util.List<org.apache.iotdb.commons.path.PartialPath> getBelongedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                                           throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Get the storage group that given path pattern matches or belongs to.

        Suppose we have (root.sg1.d1.s1, root.sg2.d2.s2), refer the following cases: 1. given path "root.sg1", ("root.sg1") will be returned. 2. given path "root.*", ("root.sg1", "root.sg2") will be returned. 3. given path "root.*.d1.s1", ("root.sg1", "root.sg2") will be returned.

        Specified by:
        getBelongedStorageGroups in interface IStorageGroupSchemaManager
        Parameters:
        pathPattern - a path pattern or a full path
        Returns:
        a list contains all storage groups related to given path pattern
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getInvolvedStorageGroups

        public java.util.List<org.apache.iotdb.commons.path.PartialPath> getInvolvedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                  boolean isPrefixMatch)
                                                                                           throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getInvolvedStorageGroups in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMatchedStorageGroups

        public java.util.List<org.apache.iotdb.commons.path.PartialPath> getMatchedStorageGroups​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                 boolean isPrefixMatch)
                                                                                          throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Get all storage group matching given path pattern. If using prefix match, the path pattern is used to match prefix path. All timeseries start with the matched prefix path will be collected.
        Specified by:
        getMatchedStorageGroups in interface IStorageGroupSchemaManager
        Parameters:
        pathPattern - a pattern of a full path
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Returns:
        A ArrayList instance which stores storage group paths matching given path pattern.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • groupPathByStorageGroup

        public java.util.Map<java.lang.String,​java.util.List<org.apache.iotdb.commons.path.PartialPath>> groupPathByStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
                                                                                                                                throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        For a path, infer all storage groups it may belong to. The path can have wildcards. Resolve the path or path pattern into StorageGroupName-FullPath pairs that FullPath matches the given path.

        Consider the path into two parts: (1) the sub path which can not contain a storage group name and (2) the sub path which is substring that begin after the storage group name.

        (1) Suppose the part of the path can not contain a storage group name (e.g., "root".contains("root.sg") == false), then: For each one level wildcard *, only one level will be inferred and the wildcard will be removed. For each multi level wildcard **, then the inference will go on until the storage groups are found and the wildcard will be kept. (2) Suppose the part of the path is a substring that begin after the storage group name. (e.g., For "root.*.sg1.a.*.b.*" and "root.x.sg1" is a storage group, then this part is "a.*.b.*"). For this part, keep what it is.

        Assuming we have three SGs: root.group1, root.group2, root.area1.group3 Eg1: for input "root.**", returns ("root.group1", "root.group1.**"), ("root.group2", "root.group2.**") ("root.area1.group3", "root.area1.group3.**") Eg2: for input "root.*.s1", returns ("root.group1", "root.group1.s1"), ("root.group2", "root.group2.s1")

        Eg3: for input "root.area1.**", returns ("root.area1.group3", "root.area1.group3.**")

        Specified by:
        groupPathByStorageGroup in interface IStorageGroupSchemaManager
        Parameters:
        path - can be a path pattern or a full path.
        Returns:
        StorageGroupName-FullPath pairs
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getStorageGroupNum

        public int getStorageGroupNum​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                      boolean isPrefixMatch)
                               throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        To calculate the count of storage group for given path pattern. If using prefix match, the path pattern is used to match prefix path. All timeseries start with the matched prefix path will be counted.
        Specified by:
        getStorageGroupNum in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getStorageGroupNodeByPath

        public IStorageGroupMNode getStorageGroupNodeByPath​(org.apache.iotdb.commons.path.PartialPath path)
                                                     throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Get storage group node by path. the give path don't need to be storage group path.
        Specified by:
        getStorageGroupNodeByPath in interface IStorageGroupSchemaManager
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isStorageGroupAlreadySet

        public boolean isStorageGroupAlreadySet​(org.apache.iotdb.commons.path.PartialPath path)
        Description copied from interface: IStorageGroupSchemaManager
        Check whether the storage group of given path is set. The path may be a prefix path of some storage group. Besides, the given path may be also beyond the MTreeAboveSG scope, then return true if the covered part exists, which means there's storage group on this path. The rest part will be checked by certain storage group subTree.
        Specified by:
        isStorageGroupAlreadySet in interface IStorageGroupSchemaManager
        Parameters:
        path - a full path or a prefix path
      • getNodesListInGivenLevel

        public org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.commons.path.PartialPath>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getNodesListInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                                                                                                                     int nodeLevel,
                                                                                                                                                                                                     boolean isPrefixMatch,
                                                                                                                                                                                                     LocalSchemaProcessor.StorageGroupFilter filter)
                                                                                                                                                                                              throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        To collect nodes in the given level for given path pattern. If using prefix match, the path pattern is used to match prefix path. All nodes start with the matched prefix path will be collected. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be collected by certain SchemaRegion. The involved storage groups will be collected to fetch schemaRegion.
        Specified by:
        getNodesListInGivenLevel in interface IStorageGroupSchemaManager
        Parameters:
        pathPattern - a path pattern or a full path
        nodeLevel - the level should match the level of the path
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getChildNodePathInNextLevel

        public org.apache.iotdb.tsfile.utils.Pair<java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodePathInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                                                                                                                                                     throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Get child node path in the next level of the given path pattern. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be counted by certain Storage Group.

        give pathPattern and the child nodes is those matching pathPattern.*

        e.g., MTree has [root.a.sg1.d1.s1, root.b.sg1.d1.s2, root.c.sg1.d2.s1] given path = root return [root.a, root.b]

        Specified by:
        getChildNodePathInNextLevel in interface IStorageGroupSchemaManager
        Parameters:
        pathPattern - The given path
        Returns:
        All child nodes' seriesPath(s) of given seriesPath.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getChildNodeNameInNextLevel

        public org.apache.iotdb.tsfile.utils.Pair<java.util.Set<java.lang.String>,​java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodeNameInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                                                                                                                       throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IStorageGroupSchemaManager
        Get child node path in the next level of the given path pattern. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be counted by certain Storage Group.

        give pathPattern and the child nodes is those matching pathPattern.*

        e.g., MTree has [root.a.sg1.d1.s1, root.b.sg1.d1.s2, root.c.sg1.d2.s1] given path = root return [a, b]

        Specified by:
        getChildNodeNameInNextLevel in interface IStorageGroupSchemaManager
        Parameters:
        pathPattern - The given path
        Returns:
        All child nodes' seriesPath(s) of given seriesPath.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException