Interface ISchemaRegion

  • All Known Implementing Classes:
    SchemaRegionMemoryImpl, SchemaRegionSchemaFileImpl

    public interface ISchemaRegion
    This interface defines all interfaces and behaviours that one SchemaRegion should support and implement.

    The interfaces are divided as following:

    1. Interfaces for initialization、recover and clear
    2. Interfaces for schema region Info query and operation
    3. Interfaces 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 for InsertPlan process
    9. Interfaces for Template operations
    10. Interfaces for Trigger
    • Method Detail

      • init

        void init()
           throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • clear

        void clear()
        clear all metadata components of this schemaRegion
      • forceMlog

        void forceMlog()
      • getSchemaRegionId

        org.apache.iotdb.commons.consensus.SchemaRegionId getSchemaRegionId()
      • getStorageGroupFullPath

        java.lang.String getStorageGroupFullPath()
      • deleteSchemaRegion

        void deleteSchemaRegion()
                         throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • createSnapshot

        boolean createSnapshot​(java.io.File snapshotDir)
      • loadSnapshot

        void loadSnapshot​(java.io.File latestSnapshotRootDir)
      • createTimeseries

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

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

        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.
        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
      • autoCreateDeviceMNode

        void autoCreateDeviceMNode​(AutoCreateDeviceMNodePlan plan)
                            throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • isPathExist

        boolean isPathExist​(org.apache.iotdb.commons.path.PartialPath path)
                     throws org.apache.iotdb.commons.exception.MetadataException
        Check whether the path exists.
        Parameters:
        path - a full path or a prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        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.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getAllTimeseriesCount

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementCountGroupByLevel

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementCountGroupByLevel

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDevicesNum

        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.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getNodesCountInGivenLevel

        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.
        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
      • getNodesListInGivenLevel

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getChildNodePathInNextLevel

        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]

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

        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]

        Returns:
        All child nodes of given seriesPath.
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getBelongedDevices

        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.
        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

        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.
        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

        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.
        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

        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.
        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

        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.
        Parameters:
        isPrefixMatch - if true, the path pattern is used to match prefix path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • fetchSchema

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • showTimeseries

        org.apache.iotdb.tsfile.utils.Pair<java.util.List<ShowTimeSeriesResult>,​java.lang.Integer> showTimeseries​(ShowTimeSeriesPlan plan,
                                                                                                                        QueryContext context)
                                                                                                                 throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getDeviceNode

        IMNode getDeviceNode​(org.apache.iotdb.commons.path.PartialPath path)
                      throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMeasurementMNode

        IMeasurementMNode getMeasurementMNode​(org.apache.iotdb.commons.path.PartialPath fullPath)
                                       throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • changeAlias

        void changeAlias​(org.apache.iotdb.commons.path.PartialPath path,
                         java.lang.String alias)
                  throws org.apache.iotdb.commons.exception.MetadataException,
                         java.io.IOException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • upsertTagsAndAttributes

        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.
        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

        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
        Parameters:
        attributesMap - newly added attributes map
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • addTags

        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
        Parameters:
        tagsMap - newly added tags map
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • dropTagsOrAttributes

        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
        Parameters:
        keySet - tags key or attributes key
        fullPath - timeseries path
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • setTagsOrAttributesValue

        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
        Parameters:
        alterMap - the new tags or attributes key-value
        fullPath - timeseries
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • renameTagOrAttributeKey

        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
        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

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

        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
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsSetTemplate

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

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

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

        void setSchemaTemplate​(SetTemplatePlan plan)
                        throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • unsetSchemaTemplate

        void unsetSchemaTemplate​(UnsetTemplatePlan plan)
                          throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • setUsingSchemaTemplate

        void setUsingSchemaTemplate​(ActivateTemplatePlan plan)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • activateSchemaTemplate

        void activateSchemaTemplate​(ActivateTemplateInClusterPlan plan,
                                    Template template)
                             throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getPathsUsingTemplate

        java.util.List<java.lang.String> getPathsUsingTemplate​(int templateId)
                                                        throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • getMNodeForTrigger

        IMNode getMNodeForTrigger​(org.apache.iotdb.commons.path.PartialPath fullPath)
                           throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • releaseMNodeAfterDropTrigger

        void releaseMNodeAfterDropTrigger​(IMNode node)
                                   throws org.apache.iotdb.commons.exception.MetadataException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException