Class MTreeBelowSGCachedImpl

  • All Implemented Interfaces:
    IMTreeBelowSG

    public class MTreeBelowSGCachedImpl
    extends java.lang.Object
    implements IMTreeBelowSG
    The hierarchical struct of the Metadata Tree is implemented in this class.

    Since there are too many interfaces and methods in this class, we use code region to help manage code. The code region starts with //region and ends with //endregion. When using Intellij Idea to develop, it's easy to fold the code region and see code region overview by collapsing all.

    The codes are divided into the following code regions:

    1. MTree initialization, clear and serialization
    2. Timeseries operation, including create and delete
    3. Entity/Device operation
    4. Interfaces and Implementation for metadata info Query
      1. Interfaces for Device info Query
      2. Interfaces for timeseries, measurement and schema info Query
      3. Interfaces for Level Node info Query
      4. Interfaces and Implementation for metadata count
    5. Interfaces and Implementation for MNode Query
    6. Interfaces and Implementation for Template check
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkIsTemplateCompatibleWithChild​(IMNode node, Template template)  
      IMNode checkTemplateAlignmentWithMountedNode​(IMNode mountedNode, Template template)
      Check route 1: If template has no direct measurement, just pass the check.
      void checkTemplateInUseOnLowerNode​(IMNode node)  
      void checkTemplateOnPath​(org.apache.iotdb.commons.path.PartialPath path)
      check whether there is template on given path and the subTree has template return true, otherwise false
      void clear()  
      java.util.List<IMeasurementMNode> createAlignedTimeseries​(org.apache.iotdb.commons.path.PartialPath devicePath, java.util.List<java.lang.String> measurements, java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.TSDataType> dataTypes, java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding> encodings, java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.CompressionType> compressors, java.util.List<java.lang.String> aliasList)
      Create aligned timeseries with full paths from root to one leaf node.
      IMeasurementMNode createTimeseries​(org.apache.iotdb.commons.path.PartialPath path, org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType, org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding encoding, org.apache.iotdb.tsfile.file.metadata.enums.CompressionType compressor, java.util.Map<java.lang.String,​java.lang.String> props, java.lang.String alias)  
      IMeasurementMNode createTimeseriesWithPinnedReturn​(org.apache.iotdb.commons.path.PartialPath path, org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType, org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding encoding, org.apache.iotdb.tsfile.file.metadata.enums.CompressionType compressor, java.util.Map<java.lang.String,​java.lang.String> props, java.lang.String alias)
      Create a timeseries with a full path from root to leaf node.
      org.apache.iotdb.tsfile.utils.Pair<org.apache.iotdb.commons.path.PartialPath,​IMeasurementMNode> deleteTimeseriesAndReturnEmptyStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
      Delete path.
      java.util.List<IMeasurementMNode> getAllMeasurementMNode()  
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.tsfile.utils.Pair<org.apache.iotdb.commons.path.PartialPath,​java.lang.String[]>>,​java.lang.Integer> getAllMeasurementSchema​(ShowTimeSeriesPlan plan, QueryContext queryContext)
      Get all measurement schema matching the given path pattern
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get the count of timeseries matching the given path.
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get the count of timeseries matching the given path.
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch, java.util.List<java.lang.String> timeseries, boolean hasTag)
      Get the count of timeseries matching the given path by tag.
      IMNode getChildFromPinnedMNode​(IMNode parent, java.lang.String measurement)  
      java.util.Set<java.lang.String> getChildNodeNameInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get child node in the next level of the given path.
      java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode> getChildNodePathInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get child node path in the next level of the given path pattern.
      IMNode getDeviceNodeWithAutoCreating​(org.apache.iotdb.commons.path.PartialPath deviceId)
      Add an interval path to MTree.
      java.util.Set<org.apache.iotdb.commons.path.PartialPath> getDevices​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get all devices matching the given path pattern.
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowDevicesResult>,​java.lang.Integer> getDevices​(ShowDevicesPlan plan)  
      java.util.Set<org.apache.iotdb.commons.path.PartialPath> getDevicesByTimeseries​(org.apache.iotdb.commons.path.PartialPath timeseries)  
      int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get the count of devices matching the given path.
      int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get the count of devices matching the given path.
      java.util.Map<org.apache.iotdb.commons.path.PartialPath,​java.lang.Integer> getMeasurementCountGroupByLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int level, boolean isPrefixMatch)  
      java.util.Map<org.apache.iotdb.commons.path.PartialPath,​java.lang.Integer> getMeasurementCountGroupByLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int level, boolean isPrefixMatch, java.util.List<java.lang.String> timeseries, boolean hasTag)  
      IMeasurementMNode getMeasurementMNode​(org.apache.iotdb.commons.path.PartialPath path)  
      java.util.List<MeasurementPath> getMeasurementPaths​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Get all measurement paths matching the given path pattern
      java.util.List<MeasurementPath> getMeasurementPaths​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get all measurement paths matching the given path pattern.
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<MeasurementPath>,​java.lang.Integer> getMeasurementPathsWithAlias​(org.apache.iotdb.commons.path.PartialPath pathPattern, int limit, int offset, boolean isPrefixMatch)
      Get all measurement paths matching the given path pattern If using prefix match, the path pattern is used to match prefix path.
      int getMountedNodeIndexOnMeasurementPath​(org.apache.iotdb.commons.path.PartialPath devicePath, java.lang.String[] measurements)
      Check measurement path and return the mounted node index on path.
      IMNode getNodeByPath​(org.apache.iotdb.commons.path.PartialPath path)
      Get node by the path
      int getNodesCountInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int level, boolean isPrefixMatch)
      Get the count of nodes in the given level matching the given path.
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getNodesListInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, LocalSchemaProcessor.StorageGroupFilter filter)
      Get all paths from root to the given level
      java.util.List<java.lang.String> getPathsSetOnTemplate​(java.lang.String templateName)  
      java.util.List<java.lang.String> getPathsUsingTemplate​(java.lang.String templateName)  
      java.lang.String getTemplateOnPath​(org.apache.iotdb.commons.path.PartialPath path)
      Get template name on give path if any node of it has been set a template
      boolean isEmptyInternalMNode​(IMNode node)  
      boolean isPathExist​(org.apache.iotdb.commons.path.PartialPath path)
      Check whether the given path exists.
      boolean isPathExistsWithinTemplate​(org.apache.iotdb.commons.path.PartialPath path)
      Note that template and MTree cannot have overlap paths.
      boolean isTemplateAppendable​(Template tarTemplate, java.util.List<java.lang.String> appendMeasurements)
      Check that each node set with tarTemplate and its descendants have overlapping nodes with appending measurements
      void pinMNode​(IMNode node)
      Currently, this method is only used for pin node get from mNodeCache
      void setAlias​(IMeasurementMNode measurementMNode, java.lang.String alias)  
      IEntityMNode setToEntity​(IMNode node)  
      void unPinMNode​(IMNode node)  
      void updateMNode​(IMNode node)  
      • Methods inherited from class java.lang.Object

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

      • MTreeBelowSGCachedImpl

        public MTreeBelowSGCachedImpl​(IStorageGroupMNode storageGroupMNode,
                                      int schemaRegionId)
                               throws org.apache.iotdb.commons.exception.MetadataException,
                                      java.io.IOException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
    • Method Detail

      • createTimeseries

        public IMeasurementMNode createTimeseries​(org.apache.iotdb.commons.path.PartialPath path,
                                                  org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType,
                                                  org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding encoding,
                                                  org.apache.iotdb.tsfile.file.metadata.enums.CompressionType compressor,
                                                  java.util.Map<java.lang.String,​java.lang.String> props,
                                                  java.lang.String alias)
                                           throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        createTimeseries in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createTimeseriesWithPinnedReturn

        public IMeasurementMNode createTimeseriesWithPinnedReturn​(org.apache.iotdb.commons.path.PartialPath path,
                                                                  org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType,
                                                                  org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding encoding,
                                                                  org.apache.iotdb.tsfile.file.metadata.enums.CompressionType compressor,
                                                                  java.util.Map<java.lang.String,​java.lang.String> props,
                                                                  java.lang.String alias)
                                                           throws org.apache.iotdb.commons.exception.MetadataException
        Create a timeseries with a full path from root to leaf node. Before creating a timeseries, the storage group should be set first, throw exception otherwise
        Parameters:
        path - timeseries path
        dataType - data type
        encoding - encoding
        compressor - compressor
        props - props
        alias - alias of measurement
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createAlignedTimeseries

        public java.util.List<IMeasurementMNode> createAlignedTimeseries​(org.apache.iotdb.commons.path.PartialPath devicePath,
                                                                         java.util.List<java.lang.String> measurements,
                                                                         java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.TSDataType> dataTypes,
                                                                         java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding> encodings,
                                                                         java.util.List<org.apache.iotdb.tsfile.file.metadata.enums.CompressionType> compressors,
                                                                         java.util.List<java.lang.String> aliasList)
                                                                  throws org.apache.iotdb.commons.exception.MetadataException
        Create aligned timeseries with full paths from root to one leaf node. Before creating timeseries, the * storage group should be set first, throw exception otherwise
        Specified by:
        createAlignedTimeseries in interface IMTreeBelowSG
        Parameters:
        devicePath - device path
        measurements - measurements list
        dataTypes - data types list
        encodings - encodings list
        compressors - compressor
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • deleteTimeseriesAndReturnEmptyStorageGroup

        public org.apache.iotdb.tsfile.utils.Pair<org.apache.iotdb.commons.path.PartialPath,​IMeasurementMNode> deleteTimeseriesAndReturnEmptyStorageGroup​(org.apache.iotdb.commons.path.PartialPath path)
                                                                                                                                                         throws org.apache.iotdb.commons.exception.MetadataException
        Delete path. The path should be a full path from root to leaf node
        Specified by:
        deleteTimeseriesAndReturnEmptyStorageGroup in interface IMTreeBelowSG
        Parameters:
        path - Format: root.node(.node)+
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isEmptyInternalMNode

        public boolean isEmptyInternalMNode​(IMNode node)
                                     throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        isEmptyInternalMNode in interface IMTreeBelowSG
        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 IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDeviceNodeWithAutoCreating

        public IMNode getDeviceNodeWithAutoCreating​(org.apache.iotdb.commons.path.PartialPath deviceId)
                                             throws org.apache.iotdb.commons.exception.MetadataException
        Add an interval path to MTree. This is only used for automatically creating schema

        e.g., get root.sg.d1, get or create all internal nodes and return the node of d1

        Specified by:
        getDeviceNodeWithAutoCreating in interface IMTreeBelowSG
        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 IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isPathExist

        public boolean isPathExist​(org.apache.iotdb.commons.path.PartialPath path)
                            throws org.apache.iotdb.commons.exception.MetadataException
        Check whether the given path exists.
        Specified by:
        isPathExist in interface IMTreeBelowSG
        Parameters:
        path - a full path or a prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevices

        public java.util.Set<org.apache.iotdb.commons.path.PartialPath> getDevices​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                   boolean isPrefixMatch)
                                                                            throws org.apache.iotdb.commons.exception.MetadataException
        Get all devices matching the given path pattern. If isPrefixMatch, then the devices under the paths matching given path pattern will be collected too.
        Specified by:
        getDevices in interface IMTreeBelowSG
        Returns:
        a list contains all distinct devices names
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevices

        public org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowDevicesResult>,​java.lang.Integer> getDevices​(ShowDevicesPlan plan)
                                                                                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getDevices in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevicesByTimeseries

        public java.util.Set<org.apache.iotdb.commons.path.PartialPath> getDevicesByTimeseries​(org.apache.iotdb.commons.path.PartialPath timeseries)
                                                                                        throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getDevicesByTimeseries in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementPaths

        public java.util.List<MeasurementPath> getMeasurementPaths​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                   boolean isPrefixMatch)
                                                            throws org.apache.iotdb.commons.exception.MetadataException
        Get all measurement paths matching the 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 and return.
        Specified by:
        getMeasurementPaths in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard.
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementPaths

        public java.util.List<MeasurementPath> getMeasurementPaths​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                            throws org.apache.iotdb.commons.exception.MetadataException
        Get all measurement paths matching the given path pattern
        Specified by:
        getMeasurementPaths in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementPathsWithAlias

        public org.apache.iotdb.tsfile.utils.Pair<java.util.List<MeasurementPath>,​java.lang.Integer> getMeasurementPathsWithAlias​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                                                        int limit,
                                                                                                                                        int offset,
                                                                                                                                        boolean isPrefixMatch)
                                                                                                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Get all measurement paths matching the 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 and return.
        Specified by:
        getMeasurementPathsWithAlias in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Returns:
        Pair.left contains all the satisfied paths Pair.right means the current offset or zero if we don't set offset.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllMeasurementSchema

        public org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.tsfile.utils.Pair<org.apache.iotdb.commons.path.PartialPath,​java.lang.String[]>>,​java.lang.Integer> getAllMeasurementSchema​(ShowTimeSeriesPlan plan,
                                                                                                                                                                                                                          QueryContext queryContext)
                                                                                                                                                                                                                   throws org.apache.iotdb.commons.exception.MetadataException
        Get all measurement schema matching the given path pattern

        result: [name, alias, storage group, dataType, encoding, compression, offset] and the current offset

        Specified by:
        getAllMeasurementSchema in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getChildNodePathInNextLevel

        public java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode> getChildNodePathInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                                                  throws org.apache.iotdb.commons.exception.MetadataException
        Get child node path in the next level of the given path pattern.

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

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

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

        public java.util.Set<java.lang.String> getChildNodeNameInNextLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                    throws org.apache.iotdb.commons.exception.MetadataException
        Get child node in the next level of the given path.

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

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

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

        public java.util.List<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
        Get all paths from root to the given level
        Specified by:
        getNodesListInGivenLevel in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        public int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                         boolean isPrefixMatch)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        Get the count of timeseries matching the given path.
        Specified by:
        getAllTimeseriesCount in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        public int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        Get the count of timeseries matching the given path.
        Specified by:
        getAllTimeseriesCount in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        public int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                         boolean isPrefixMatch,
                                         java.util.List<java.lang.String> timeseries,
                                         boolean hasTag)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: IMTreeBelowSG
        Get the count of timeseries matching the given path by tag.
        Specified by:
        getAllTimeseriesCount in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevicesNum

        public int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                 boolean isPrefixMatch)
                          throws org.apache.iotdb.commons.exception.MetadataException
        Get the count of devices matching the given path. 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:
        getDevicesNum in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevicesNum

        public int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                          throws org.apache.iotdb.commons.exception.MetadataException
        Get the count of devices matching the given path.
        Specified by:
        getDevicesNum in interface IMTreeBelowSG
        Parameters:
        pathPattern - a path pattern or a full path, may contain wildcard
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getNodesCountInGivenLevel

        public int getNodesCountInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                             int level,
                                             boolean isPrefixMatch)
                                      throws org.apache.iotdb.commons.exception.MetadataException
        Get the count of nodes in the given level matching the given path. 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:
        getNodesCountInGivenLevel in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementCountGroupByLevel

        public java.util.Map<org.apache.iotdb.commons.path.PartialPath,​java.lang.Integer> getMeasurementCountGroupByLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                                                int level,
                                                                                                                                boolean isPrefixMatch)
                                                                                                                         throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getMeasurementCountGroupByLevel in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementCountGroupByLevel

        public java.util.Map<org.apache.iotdb.commons.path.PartialPath,​java.lang.Integer> getMeasurementCountGroupByLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                                                int level,
                                                                                                                                boolean isPrefixMatch,
                                                                                                                                java.util.List<java.lang.String> timeseries,
                                                                                                                                boolean hasTag)
                                                                                                                         throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getMeasurementCountGroupByLevel in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getNodeByPath

        public IMNode getNodeByPath​(org.apache.iotdb.commons.path.PartialPath path)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Get node by the path
        Specified by:
        getNodeByPath in interface IMTreeBelowSG
        Returns:
        last node in given seriesPath
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementMNode

        public IMeasurementMNode getMeasurementMNode​(org.apache.iotdb.commons.path.PartialPath path)
                                              throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getMeasurementMNode in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllMeasurementMNode

        public java.util.List<IMeasurementMNode> getAllMeasurementMNode()
                                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getAllMeasurementMNode in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • checkTemplateOnPath

        public void checkTemplateOnPath​(org.apache.iotdb.commons.path.PartialPath path)
                                 throws org.apache.iotdb.commons.exception.MetadataException
        check whether there is template on given path and the subTree has template return true, otherwise false
        Specified by:
        checkTemplateOnPath in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • checkTemplateAlignmentWithMountedNode

        public IMNode checkTemplateAlignmentWithMountedNode​(IMNode mountedNode,
                                                            Template template)
                                                     throws org.apache.iotdb.commons.exception.MetadataException
        Check route 1: If template has no direct measurement, just pass the check.

        Check route 2: If template has direct measurement and mounted node is Internal, it should be set to Entity.

        Check route 3: If template has direct measurement and mounted node is Entity,

          route 3.1: mounted node has no measurement child, then its alignment will be set as the template.

          route 3.2: mounted node has measurement child, then alignment of it and template should be identical, otherwise cast a exception.

        Specified by:
        checkTemplateAlignmentWithMountedNode in interface IMTreeBelowSG
        Returns:
        return the node competent to be mounted.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • checkIsTemplateCompatibleWithChild

        public void checkIsTemplateCompatibleWithChild​(IMNode node,
                                                       Template template)
                                                throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        checkIsTemplateCompatibleWithChild in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • checkTemplateInUseOnLowerNode

        public void checkTemplateInUseOnLowerNode​(IMNode node)
                                           throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        checkTemplateInUseOnLowerNode in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isTemplateAppendable

        public boolean isTemplateAppendable​(Template tarTemplate,
                                            java.util.List<java.lang.String> appendMeasurements)
                                     throws org.apache.iotdb.commons.exception.MetadataException
        Check that each node set with tarTemplate and its descendants have overlapping nodes with appending measurements
        Specified by:
        isTemplateAppendable in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isPathExistsWithinTemplate

        public boolean isPathExistsWithinTemplate​(org.apache.iotdb.commons.path.PartialPath path)
                                           throws org.apache.iotdb.commons.exception.MetadataException
        Note that template and MTree cannot have overlap paths.
        Specified by:
        isPathExistsWithinTemplate in interface IMTreeBelowSG
        Returns:
        true iff path corresponding to a measurement inside a template, whether using or not.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMountedNodeIndexOnMeasurementPath

        public int getMountedNodeIndexOnMeasurementPath​(org.apache.iotdb.commons.path.PartialPath devicePath,
                                                        java.lang.String[] measurements)
                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Check measurement path and return the mounted node index on path. The node could have not created yet. The result is used for getDeviceNodeWithAutoCreate, which return corresponding IMNode on MTree.
        Specified by:
        getMountedNodeIndexOnMeasurementPath in interface IMTreeBelowSG
        Returns:
        index on full path of the node which matches all measurements path with its upperTemplate.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsSetOnTemplate

        public java.util.List<java.lang.String> getPathsSetOnTemplate​(java.lang.String templateName)
                                                               throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getPathsSetOnTemplate in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsUsingTemplate

        public java.util.List<java.lang.String> getPathsUsingTemplate​(java.lang.String templateName)
                                                               throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getPathsUsingTemplate in interface IMTreeBelowSG
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getTemplateOnPath

        public java.lang.String getTemplateOnPath​(org.apache.iotdb.commons.path.PartialPath path)
                                           throws org.apache.iotdb.commons.exception.MetadataException
        Get template name on give path if any node of it has been set a template
        Specified by:
        getTemplateOnPath in interface IMTreeBelowSG
        Returns:
        null if no template has been set on path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • pinMNode

        public void pinMNode​(IMNode node)
                      throws org.apache.iotdb.commons.exception.MetadataException
        Currently, this method is only used for pin node get from mNodeCache
        Parameters:
        node -
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • unPinMNode

        public void unPinMNode​(IMNode node)
      • updateMNode

        public void updateMNode​(IMNode node)
                         throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getChildFromPinnedMNode

        public IMNode getChildFromPinnedMNode​(IMNode parent,
                                              java.lang.String measurement)
                                       throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException