Class SchemaRegionSchemaFileImpl

  • All Implemented Interfaces:
    ISchemaRegion

    public class SchemaRegionSchemaFileImpl
    extends java.lang.Object
    implements ISchemaRegion
    This class takes the responsibility of serialization of all the metadata info of one certain schema region and persistent it into files. This class contains the interfaces to modify the metadata in schema region for delta system. All the operations will be inserted into the logs temporary in case the downtime of the delta system.

    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. Interfaces and Implementation for initialization、recover and clear
    2. Interfaces and Implementation for schema region Info query and operation
    3. Interfaces and Implementation for Timeseries operation
    4. Interfaces for auto create device
    5. Interfaces for metadata info Query
      1. Interfaces for metadata count
      2. Interfaces for level Node info Query
      3. Interfaces for Entity/Device info Query
      4. Interfaces for timeseries, measurement and schema info Query
    6. Interfaces and methods for MNode query
    7. Interfaces for alias and tag/attribute operations
    8. Interfaces and Implementation for InsertPlan process
    9. Interfaces and Implementation for Template operations
    10. Interfaces for Trigger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static IoTDBConfig config  
    • Constructor Summary

      Constructors 
      Constructor Description
      SchemaRegionSchemaFileImpl​(org.apache.iotdb.commons.path.PartialPath storageGroup, org.apache.iotdb.commons.consensus.SchemaRegionId schemaRegionId, IStorageGroupMNode storageGroupMNode, org.apache.iotdb.external.api.ISeriesNumerLimiter seriesNumerLimiter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateSchemaTemplate​(ActivateTemplateInClusterPlan plan, Template template)  
      void addAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributesMap, org.apache.iotdb.commons.path.PartialPath fullPath)
      add new attributes key-value for the timeseries
      void addTags​(java.util.Map<java.lang.String,​java.lang.String> tagsMap, org.apache.iotdb.commons.path.PartialPath fullPath)
      add new tags key-value for the timeseries
      void autoCreateDeviceMNode​(AutoCreateDeviceMNodePlan plan)  
      void changeAlias​(org.apache.iotdb.commons.path.PartialPath path, java.lang.String alias)  
      void clear()
      function for clearing metadata components of one schema region
      void createAlignedTimeSeries​(org.apache.iotdb.commons.path.PartialPath prefixPath, 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)  
      void createAlignedTimeSeries​(CreateAlignedTimeSeriesPlan plan)
      create aligned timeseries
      boolean createSnapshot​(java.io.File snapshotDir)  
      void createTimeseries​(CreateTimeSeriesPlan plan)  
      void createTimeseries​(CreateTimeSeriesPlan plan, long offset)  
      void deleteSchemaRegion()  
      org.apache.iotdb.tsfile.utils.Pair<java.lang.Integer,​java.util.Set<java.lang.String>> deleteTimeseries​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      Delete all timeseries matching the given path pattern
      org.apache.iotdb.tsfile.utils.Pair<java.lang.Integer,​java.util.Set<java.lang.String>> deleteTimeseries​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Delete all timeseries matching the given path pattern.
      void dropTagsOrAttributes​(java.util.Set<java.lang.String> keySet, org.apache.iotdb.commons.path.PartialPath fullPath)
      drop tags or attributes of the timeseries
      java.util.List<MeasurementPath> fetchSchema​(org.apache.iotdb.commons.path.PartialPath pathPattern, java.util.Map<java.lang.Integer,​Template> templateMap)  
      void forceMlog()  
      java.util.List<MeasurementPath> getAllMeasurementByDevicePath​(org.apache.iotdb.commons.path.PartialPath devicePath)  
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      To calculate the count of timeseries matching given path.
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch, java.lang.String key, java.lang.String value, boolean isContains)  
      int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern, java.util.Map<java.lang.Integer,​Template> templateMap, boolean isPrefixMatch)  
      java.util.Set<org.apache.iotdb.commons.path.PartialPath> getBelongedDevices​(org.apache.iotdb.commons.path.PartialPath timeseries)
      Get all devices that one of the timeseries, matching the given timeseries path pattern, belongs to.
      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 pattern.
      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 getDeviceNode​(org.apache.iotdb.commons.path.PartialPath path)  
      DeviceSchemaInfo getDeviceSchemaInfoWithAutoCreate​(org.apache.iotdb.commons.path.PartialPath devicePath, java.lang.String[] measurements, java.util.function.Function<java.lang.Integer,​org.apache.iotdb.tsfile.file.metadata.enums.TSDataType> getDataType, boolean aligned)  
      int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern)
      To calculate the count of devices for given path pattern.
      int getDevicesNum​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      To calculate the count of devices for given path pattern.
      java.util.Set<org.apache.iotdb.commons.path.PartialPath> getMatchedDevices​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Get all device paths matching the path pattern.
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowDevicesResult>,​java.lang.Integer> getMatchedDevices​(ShowDevicesPlan plan)
      Get all device paths and according storage group paths as ShowDevicesResult.
      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.lang.String key, java.lang.String value, boolean isContains)  
      IMeasurementMNode getMeasurementMNode​(org.apache.iotdb.commons.path.PartialPath fullPath)  
      protected IMeasurementMNode getMeasurementMNode​(IMNode deviceMNode, java.lang.String measurementName)
      Invoked during insertPlan process.
      java.util.List<MeasurementPath> getMeasurementPaths​(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)
      Return all measurement paths for given path if the path is abstract.
      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)
      Similar to method getMeasurementPaths(), but return Path with alias and filter the result by limit and offset.
      IMNode getMNodeForTrigger​(org.apache.iotdb.commons.path.PartialPath fullPath)  
      int getNodesCountInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int level, boolean isPrefixMatch)
      To calculate the count of nodes in the given level for given path pattern.
      java.util.List<org.apache.iotdb.commons.path.PartialPath> getNodesListInGivenLevel​(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, LocalSchemaProcessor.StorageGroupFilter filter)  
      java.util.Set<java.lang.String> getPathsSetTemplate​(java.lang.String templateName)
      Get all paths set designated template
      java.util.List<java.lang.String> getPathsUsingTemplate​(int templateId)  
      java.util.Set<java.lang.String> getPathsUsingTemplate​(java.lang.String templateName)  
      org.apache.iotdb.commons.consensus.SchemaRegionId getSchemaRegionId()  
      org.apache.iotdb.tsfile.write.schema.IMeasurementSchema getSeriesSchema​(org.apache.iotdb.commons.path.PartialPath fullPath)
      Get schema of paritialPath
      IMNode getSeriesSchemasAndReadLockDevice​(InsertPlan plan)
      get schema for device.
      org.apache.iotdb.tsfile.file.metadata.enums.TSDataType getSeriesType​(org.apache.iotdb.commons.path.PartialPath fullPath)
      Get series type for given seriesPath.
      java.lang.String getStorageGroupFullPath()  
      void init()  
      boolean isPathExist​(org.apache.iotdb.commons.path.PartialPath path)
      Check whether the path exists.
      boolean isTemplateAppendable​(Template template, java.util.List<java.lang.String> measurements)  
      void loadSnapshot​(java.io.File latestSnapshotRootDir)  
      void recoverAlignedTimeSeries​(CreateAlignedTimeSeriesPlan plan)  
      void recoverTimeseries​(CreateTimeSeriesPlan plan, long offset)  
      void releaseMNodeAfterDropTrigger​(IMNode node)  
      void renameTagOrAttributeKey​(java.lang.String oldKey, java.lang.String newKey, org.apache.iotdb.commons.path.PartialPath fullPath)
      rename the tag or attribute's key of the timeseries
      void setSchemaTemplate​(SetTemplatePlan plan)  
      void setTagsOrAttributesValue​(java.util.Map<java.lang.String,​java.lang.String> alterMap, org.apache.iotdb.commons.path.PartialPath fullPath)
      set/change the values of tags or attributes
      IMNode setUsingSchemaTemplate​(IMNode node)  
      void setUsingSchemaTemplate​(ActivateTemplatePlan plan)  
      org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowTimeSeriesResult>,​java.lang.Integer> showTimeseries​(ShowTimeSeriesPlan plan, QueryContext context)  
      void unsetSchemaTemplate​(UnsetTemplatePlan plan)  
      void upsertTagsAndAttributes​(java.lang.String alias, java.util.Map<java.lang.String,​java.lang.String> tagsMap, java.util.Map<java.lang.String,​java.lang.String> attributesMap, org.apache.iotdb.commons.path.PartialPath fullPath)
      upsert tags and attributes key-value for the timeseries if the key has existed, just use the new value to update it.
      • Methods inherited from class java.lang.Object

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

      • SchemaRegionSchemaFileImpl

        public SchemaRegionSchemaFileImpl​(org.apache.iotdb.commons.path.PartialPath storageGroup,
                                          org.apache.iotdb.commons.consensus.SchemaRegionId schemaRegionId,
                                          IStorageGroupMNode storageGroupMNode,
                                          org.apache.iotdb.external.api.ISeriesNumerLimiter seriesNumerLimiter)
                                   throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
    • Method Detail

      • init

        public void init()
                  throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        init in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • clear

        public void clear()
        function for clearing metadata components of one schema region
        Specified by:
        clear in interface ISchemaRegion
      • getSchemaRegionId

        public org.apache.iotdb.commons.consensus.SchemaRegionId getSchemaRegionId()
        Specified by:
        getSchemaRegionId in interface ISchemaRegion
      • deleteSchemaRegion

        public void deleteSchemaRegion()
                                throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        deleteSchemaRegion in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createSnapshot

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

        public void loadSnapshot​(java.io.File latestSnapshotRootDir)
        Specified by:
        loadSnapshot in interface ISchemaRegion
      • createTimeseries

        public void createTimeseries​(CreateTimeSeriesPlan plan)
                              throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • recoverTimeseries

        public void recoverTimeseries​(CreateTimeSeriesPlan plan,
                                      long offset)
                               throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createTimeseries

        public void createTimeseries​(CreateTimeSeriesPlan plan,
                                     long offset)
                              throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        createTimeseries in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createAlignedTimeSeries

        public void createAlignedTimeSeries​(org.apache.iotdb.commons.path.PartialPath prefixPath,
                                            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)
                                     throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • recoverAlignedTimeSeries

        public void recoverAlignedTimeSeries​(CreateAlignedTimeSeriesPlan plan)
                                      throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createAlignedTimeSeries

        public void createAlignedTimeSeries​(CreateAlignedTimeSeriesPlan plan)
                                     throws org.apache.iotdb.commons.exception.MetadataException
        create aligned timeseries
        Specified by:
        createAlignedTimeSeries in interface ISchemaRegion
        Parameters:
        plan - CreateAlignedTimeSeriesPlan
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • deleteTimeseries

        public org.apache.iotdb.tsfile.utils.Pair<java.lang.Integer,​java.util.Set<java.lang.String>> deleteTimeseries​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                                                            boolean isPrefixMatch)
                                                                                                                     throws org.apache.iotdb.commons.exception.MetadataException
        Delete all timeseries 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 deleted.
        Specified by:
        deleteTimeseries in interface ISchemaRegion
        Parameters:
        pathPattern - path to be deleted
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Returns:
        deletion failed Timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • deleteTimeseries

        public org.apache.iotdb.tsfile.utils.Pair<java.lang.Integer,​java.util.Set<java.lang.String>> deleteTimeseries​(org.apache.iotdb.commons.path.PartialPath pathPattern)
                                                                                                                     throws org.apache.iotdb.commons.exception.MetadataException
        Delete all timeseries matching the given path pattern
        Parameters:
        pathPattern - path to be deleted
        Returns:
        deletion failed Timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isPathExist

        public boolean isPathExist​(org.apache.iotdb.commons.path.PartialPath path)
        Check whether the path exists.
        Specified by:
        isPathExist in interface ISchemaRegion
        Parameters:
        path - a full path or a prefix path
      • getAllTimeseriesCount

        public int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                         boolean isPrefixMatch)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        To calculate the count of timeseries matching given path. The path could be a pattern of a full path, may contain wildcard. 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:
        getAllTimeseriesCount in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

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

        public int getAllTimeseriesCount​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                         boolean isPrefixMatch,
                                         java.lang.String key,
                                         java.lang.String value,
                                         boolean isContains)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getAllTimeseriesCount in interface ISchemaRegion
        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
        To calculate the count of devices 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:
        getDevicesNum in interface ISchemaRegion
        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
        To calculate the count of devices for given path pattern.
        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
        To calculate the count of 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 counted.
        Specified by:
        getNodesCountInGivenLevel in interface ISchemaRegion
        Parameters:
        pathPattern - a path pattern or a full path
        level - 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
      • 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 ISchemaRegion
        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.lang.String key,
                                                                                                                                java.lang.String value,
                                                                                                                                boolean isContains)
                                                                                                                         throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getMeasurementCountGroupByLevel in interface ISchemaRegion
        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
        Specified by:
        getNodesListInGivenLevel in interface ISchemaRegion
        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 ISchemaRegion
        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 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 [d1, d2] given path = root.sg.d1 return [s1,s2]

        Specified by:
        getChildNodeNameInNextLevel in interface ISchemaRegion
        Returns:
        All child nodes of given seriesPath.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getBelongedDevices

        public java.util.Set<org.apache.iotdb.commons.path.PartialPath> getBelongedDevices​(org.apache.iotdb.commons.path.PartialPath timeseries)
                                                                                    throws org.apache.iotdb.commons.exception.MetadataException
        Get all devices that one of the timeseries, matching the given timeseries path pattern, belongs to.
        Specified by:
        getBelongedDevices in interface ISchemaRegion
        Parameters:
        timeseries - a path pattern of the target timeseries
        Returns:
        A HashSet instance which stores devices paths.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMatchedDevices

        public java.util.Set<org.apache.iotdb.commons.path.PartialPath> getMatchedDevices​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                                                          boolean isPrefixMatch)
                                                                                   throws org.apache.iotdb.commons.exception.MetadataException
        Get all device paths matching the 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:
        getMatchedDevices in interface ISchemaRegion
        Parameters:
        pathPattern - the pattern of the target devices.
        isPrefixMatch - if true, the path pattern is used to match prefix path.
        Returns:
        A HashSet instance which stores devices paths matching the given path pattern.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMatchedDevices

        public org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowDevicesResult>,​java.lang.Integer> getMatchedDevices​(ShowDevicesPlan plan)
                                                                                                                        throws org.apache.iotdb.commons.exception.MetadataException
        Get all device paths and according storage group paths as ShowDevicesResult.
        Specified by:
        getMatchedDevices in interface ISchemaRegion
        Parameters:
        plan - ShowDevicesPlan which contains the path pattern and restriction params.
        Returns:
        ShowDevicesResult and the current offset of this region after traverse.
        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
        Return all measurement paths for given path if the path is abstract. Or return the path itself. Regular expression in this method is formed by the amalgamation of seriesPath and the character '*'. 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:
        getMeasurementPaths in interface ISchemaRegion
        Parameters:
        pathPattern - can be a pattern or a full path of timeseries.
        isPrefixMatch - if true, the path pattern is used to match prefix path
        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
        Similar to method getMeasurementPaths(), but return Path with alias and filter the result by limit and offset. 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:
        getMeasurementPathsWithAlias in interface ISchemaRegion
        Parameters:
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • fetchSchema

        public java.util.List<MeasurementPath> fetchSchema​(org.apache.iotdb.commons.path.PartialPath pathPattern,
                                                           java.util.Map<java.lang.Integer,​Template> templateMap)
                                                    throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        fetchSchema in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getSeriesType

        public org.apache.iotdb.tsfile.file.metadata.enums.TSDataType getSeriesType​(org.apache.iotdb.commons.path.PartialPath fullPath)
                                                                             throws org.apache.iotdb.commons.exception.MetadataException
        Get series type for given seriesPath.
        Parameters:
        fullPath - full path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getSeriesSchema

        public org.apache.iotdb.tsfile.write.schema.IMeasurementSchema getSeriesSchema​(org.apache.iotdb.commons.path.PartialPath fullPath)
                                                                                throws org.apache.iotdb.commons.exception.MetadataException
        Get schema of paritialPath
        Parameters:
        fullPath - (may be ParitialPath or AlignedPath)
        Returns:
        MeasurementSchema
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDeviceNode

        public IMNode getDeviceNode​(org.apache.iotdb.commons.path.PartialPath path)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getDeviceNode in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementMNode

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

        protected IMeasurementMNode getMeasurementMNode​(IMNode deviceMNode,
                                                        java.lang.String measurementName)
                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Invoked during insertPlan process. Get target MeasurementMNode from given EntityMNode. If the result is not null and is not MeasurementMNode, it means a timeseries with same path cannot be created thus throw PathAlreadyExistException.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • changeAlias

        public void changeAlias​(org.apache.iotdb.commons.path.PartialPath path,
                                java.lang.String alias)
                         throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        changeAlias in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • upsertTagsAndAttributes

        public void upsertTagsAndAttributes​(java.lang.String alias,
                                            java.util.Map<java.lang.String,​java.lang.String> tagsMap,
                                            java.util.Map<java.lang.String,​java.lang.String> attributesMap,
                                            org.apache.iotdb.commons.path.PartialPath fullPath)
                                     throws org.apache.iotdb.commons.exception.MetadataException,
                                            java.io.IOException
        upsert tags and attributes key-value for the timeseries if the key has existed, just use the new value to update it.
        Specified by:
        upsertTagsAndAttributes in interface ISchemaRegion
        Parameters:
        alias - newly added alias
        tagsMap - newly added tags map
        attributesMap - newly added attributes map
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • addAttributes

        public void addAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributesMap,
                                  org.apache.iotdb.commons.path.PartialPath fullPath)
                           throws org.apache.iotdb.commons.exception.MetadataException,
                                  java.io.IOException
        add new attributes key-value for the timeseries
        Specified by:
        addAttributes in interface ISchemaRegion
        Parameters:
        attributesMap - newly added attributes map
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • addTags

        public void addTags​(java.util.Map<java.lang.String,​java.lang.String> tagsMap,
                            org.apache.iotdb.commons.path.PartialPath fullPath)
                     throws org.apache.iotdb.commons.exception.MetadataException,
                            java.io.IOException
        add new tags key-value for the timeseries
        Specified by:
        addTags in interface ISchemaRegion
        Parameters:
        tagsMap - newly added tags map
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • dropTagsOrAttributes

        public void dropTagsOrAttributes​(java.util.Set<java.lang.String> keySet,
                                         org.apache.iotdb.commons.path.PartialPath fullPath)
                                  throws org.apache.iotdb.commons.exception.MetadataException,
                                         java.io.IOException
        drop tags or attributes of the timeseries
        Specified by:
        dropTagsOrAttributes in interface ISchemaRegion
        Parameters:
        keySet - tags key or attributes key
        fullPath - timeseries path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • setTagsOrAttributesValue

        public void setTagsOrAttributesValue​(java.util.Map<java.lang.String,​java.lang.String> alterMap,
                                             org.apache.iotdb.commons.path.PartialPath fullPath)
                                      throws org.apache.iotdb.commons.exception.MetadataException,
                                             java.io.IOException
        set/change the values of tags or attributes
        Specified by:
        setTagsOrAttributesValue in interface ISchemaRegion
        Parameters:
        alterMap - the new tags or attributes key-value
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • renameTagOrAttributeKey

        public void renameTagOrAttributeKey​(java.lang.String oldKey,
                                            java.lang.String newKey,
                                            org.apache.iotdb.commons.path.PartialPath fullPath)
                                     throws org.apache.iotdb.commons.exception.MetadataException,
                                            java.io.IOException
        rename the tag or attribute's key of the timeseries
        Specified by:
        renameTagOrAttributeKey in interface ISchemaRegion
        Parameters:
        oldKey - old key of tag or attribute
        newKey - new key of tag or attribute
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • getSeriesSchemasAndReadLockDevice

        public IMNode getSeriesSchemasAndReadLockDevice​(InsertPlan plan)
                                                 throws org.apache.iotdb.commons.exception.MetadataException,
                                                        java.io.IOException
        get schema for device. Attention!!! Only support insertPlan
        Specified by:
        getSeriesSchemasAndReadLockDevice in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • getDeviceSchemaInfoWithAutoCreate

        public DeviceSchemaInfo getDeviceSchemaInfoWithAutoCreate​(org.apache.iotdb.commons.path.PartialPath devicePath,
                                                                  java.lang.String[] measurements,
                                                                  java.util.function.Function<java.lang.Integer,​org.apache.iotdb.tsfile.file.metadata.enums.TSDataType> getDataType,
                                                                  boolean aligned)
                                                           throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getDeviceSchemaInfoWithAutoCreate in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsSetTemplate

        public java.util.Set<java.lang.String> getPathsSetTemplate​(java.lang.String templateName)
                                                            throws org.apache.iotdb.commons.exception.MetadataException
        Get all paths set designated template
        Specified by:
        getPathsSetTemplate in interface ISchemaRegion
        Parameters:
        templateName - designated template name, blank string for any template exists
        Returns:
        paths set
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsUsingTemplate

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

        public boolean isTemplateAppendable​(Template template,
                                            java.util.List<java.lang.String> measurements)
                                     throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        isTemplateAppendable in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setSchemaTemplate

        public void setSchemaTemplate​(SetTemplatePlan plan)
                               throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        setSchemaTemplate in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • unsetSchemaTemplate

        public void unsetSchemaTemplate​(UnsetTemplatePlan plan)
                                 throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        unsetSchemaTemplate in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setUsingSchemaTemplate

        public void setUsingSchemaTemplate​(ActivateTemplatePlan plan)
                                    throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        setUsingSchemaTemplate in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsUsingTemplate

        public java.util.List<java.lang.String> getPathsUsingTemplate​(int templateId)
                                                               throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getPathsUsingTemplate in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setUsingSchemaTemplate

        public IMNode setUsingSchemaTemplate​(IMNode node)
                                      throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMNodeForTrigger

        public IMNode getMNodeForTrigger​(org.apache.iotdb.commons.path.PartialPath fullPath)
                                  throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        getMNodeForTrigger in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • releaseMNodeAfterDropTrigger

        public void releaseMNodeAfterDropTrigger​(IMNode node)
                                          throws org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        releaseMNodeAfterDropTrigger in interface ISchemaRegion
        Throws:
        org.apache.iotdb.commons.exception.MetadataException