Class StorageGroupSchemaManager
- java.lang.Object
-
- org.apache.iotdb.db.metadata.storagegroup.StorageGroupSchemaManager
-
- All Implemented Interfaces:
IStorageGroupSchemaManager
public class StorageGroupSchemaManager extends java.lang.Object implements IStorageGroupSchemaManager
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckStorageGroupByPath(org.apache.iotdb.commons.path.PartialPath path)Check whether the given path contains a storage groupvoidclear()voiddeleteStorageGroup(org.apache.iotdb.commons.path.PartialPath storageGroup)Delete storage groups of given paths from MTree.IStorageGroupMNodeensureStorageGroupByStorageGroupPath(org.apache.iotdb.commons.path.PartialPath storageGroup)Different with LocalConfigNode.ensureStorageGroup, this method won't init storageGroup resources and the input is the target storage group path.voidforceLog()java.util.List<IStorageGroupMNode>getAllStorageGroupNodes()Get all storage group MNodesjava.util.List<org.apache.iotdb.commons.path.PartialPath>getAllStorageGroupPaths()Get all storage group pathsorg.apache.iotdb.commons.path.PartialPathgetBelongedStorageGroup(org.apache.iotdb.commons.path.PartialPath path)Get storage group name by pathjava.util.List<org.apache.iotdb.commons.path.PartialPath>getBelongedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern)Get the storage group that given path pattern matches or belongs to.org.apache.iotdb.tsfile.utils.Pair<java.util.Set<java.lang.String>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>>getChildNodeNameInNextLevel(org.apache.iotdb.commons.path.PartialPath pathPattern)Get child node path in the next level of the given path pattern.org.apache.iotdb.tsfile.utils.Pair<java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>>getChildNodePathInNextLevel(org.apache.iotdb.commons.path.PartialPath pathPattern)Get child node path in the next level of the given path pattern.static StorageGroupSchemaManagergetInstance()java.util.List<org.apache.iotdb.commons.path.PartialPath>getInvolvedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)java.util.List<org.apache.iotdb.commons.path.PartialPath>getMatchedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)Get all storage group matching given path pattern.org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.commons.path.PartialPath>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>>getNodesListInGivenLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, LocalSchemaProcessor.StorageGroupFilter filter)To collect nodes in the given level for given path pattern.IStorageGroupMNodegetStorageGroupNodeByPath(org.apache.iotdb.commons.path.PartialPath path)Get storage group node by path.intgetStorageGroupNum(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)To calculate the count of storage group for given path pattern.java.util.Map<java.lang.String,java.util.List<org.apache.iotdb.commons.path.PartialPath>>groupPathByStorageGroup(org.apache.iotdb.commons.path.PartialPath path)For a path, infer all storage groups it may belong to.voidinit()booleanisStorageGroup(org.apache.iotdb.commons.path.PartialPath path)Check if the given path is storage group or not.booleanisStorageGroupAlreadySet(org.apache.iotdb.commons.path.PartialPath path)Check whether the storage group of given path is set.voidrecoverLog()voidsetStorageGroup(org.apache.iotdb.commons.path.PartialPath path)Set storage group of the given path to MTree.voidsetTTL(org.apache.iotdb.commons.path.PartialPath storageGroup, long dataTTL)
-
-
-
Method Detail
-
getInstance
public static StorageGroupSchemaManager getInstance()
-
init
public void init() throws org.apache.iotdb.commons.exception.MetadataException, java.io.IOException- Specified by:
initin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.io.IOException
-
recoverLog
public void recoverLog() throws java.io.IOException- Throws:
java.io.IOException
-
forceLog
public void forceLog()
- Specified by:
forceLogin interfaceIStorageGroupSchemaManager
-
clear
public void clear() throws java.io.IOException- Specified by:
clearin interfaceIStorageGroupSchemaManager- Throws:
java.io.IOException
-
setStorageGroup
public void setStorageGroup(org.apache.iotdb.commons.path.PartialPath path) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerSet storage group of the given path to MTree.- Specified by:
setStorageGroupin interfaceIStorageGroupSchemaManager- Parameters:
path- storage group path- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
ensureStorageGroupByStorageGroupPath
public IStorageGroupMNode ensureStorageGroupByStorageGroupPath(org.apache.iotdb.commons.path.PartialPath storageGroup) throws org.apache.iotdb.commons.exception.MetadataException
Description copied from interface:IStorageGroupSchemaManagerDifferent with LocalConfigNode.ensureStorageGroup, this method won't init storageGroup resources and the input is the target storage group path.- Specified by:
ensureStorageGroupByStorageGroupPathin interfaceIStorageGroupSchemaManager- Parameters:
storageGroup- storage group path- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
deleteStorageGroup
public void deleteStorageGroup(org.apache.iotdb.commons.path.PartialPath storageGroup) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerDelete storage groups of given paths from MTree. Log format: "delete_storage_group,sg1,sg2,sg3"- Specified by:
deleteStorageGroupin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setTTL
public void setTTL(org.apache.iotdb.commons.path.PartialPath storageGroup, long dataTTL) throws org.apache.iotdb.commons.exception.MetadataException, java.io.IOException- Specified by:
setTTLin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.io.IOException
-
isStorageGroup
public boolean isStorageGroup(org.apache.iotdb.commons.path.PartialPath path)
Description copied from interface:IStorageGroupSchemaManagerCheck if the given path is storage group or not.- Specified by:
isStorageGroupin interfaceIStorageGroupSchemaManager
-
checkStorageGroupByPath
public boolean checkStorageGroupByPath(org.apache.iotdb.commons.path.PartialPath path)
Description copied from interface:IStorageGroupSchemaManagerCheck whether the given path contains a storage group- Specified by:
checkStorageGroupByPathin interfaceIStorageGroupSchemaManager
-
getBelongedStorageGroup
public org.apache.iotdb.commons.path.PartialPath getBelongedStorageGroup(org.apache.iotdb.commons.path.PartialPath path) throws StorageGroupNotSetExceptionDescription copied from interface:IStorageGroupSchemaManagerGet storage group name by pathe.g., root.sg1 is a storage group and path = root.sg1.d1, return root.sg1
- Specified by:
getBelongedStorageGroupin interfaceIStorageGroupSchemaManager- Parameters:
path- only full path, cannot be path pattern- Returns:
- storage group in the given path
- Throws:
StorageGroupNotSetException
-
getBelongedStorageGroups
public java.util.List<org.apache.iotdb.commons.path.PartialPath> getBelongedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerGet the storage group that given path pattern matches or belongs to.Suppose we have (root.sg1.d1.s1, root.sg2.d2.s2), refer the following cases: 1. given path "root.sg1", ("root.sg1") will be returned. 2. given path "root.*", ("root.sg1", "root.sg2") will be returned. 3. given path "root.*.d1.s1", ("root.sg1", "root.sg2") will be returned.
- Specified by:
getBelongedStorageGroupsin interfaceIStorageGroupSchemaManager- Parameters:
pathPattern- a path pattern or a full path- Returns:
- a list contains all storage groups related to given path pattern
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getInvolvedStorageGroups
public java.util.List<org.apache.iotdb.commons.path.PartialPath> getInvolvedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch) throws org.apache.iotdb.commons.exception.MetadataException- Specified by:
getInvolvedStorageGroupsin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getMatchedStorageGroups
public java.util.List<org.apache.iotdb.commons.path.PartialPath> getMatchedStorageGroups(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerGet all storage group matching given path pattern. If using prefix match, the path pattern is used to match prefix path. All timeseries start with the matched prefix path will be collected.- Specified by:
getMatchedStorageGroupsin interfaceIStorageGroupSchemaManager- Parameters:
pathPattern- a pattern of a full pathisPrefixMatch- if true, the path pattern is used to match prefix path- Returns:
- A ArrayList instance which stores storage group paths matching given path pattern.
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getAllStorageGroupPaths
public java.util.List<org.apache.iotdb.commons.path.PartialPath> getAllStorageGroupPaths()
Description copied from interface:IStorageGroupSchemaManagerGet all storage group paths- Specified by:
getAllStorageGroupPathsin interfaceIStorageGroupSchemaManager
-
groupPathByStorageGroup
public java.util.Map<java.lang.String,java.util.List<org.apache.iotdb.commons.path.PartialPath>> groupPathByStorageGroup(org.apache.iotdb.commons.path.PartialPath path) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerFor a path, infer all storage groups it may belong to. The path can have wildcards. Resolve the path or path pattern into StorageGroupName-FullPath pairs that FullPath matches the given path.Consider the path into two parts: (1) the sub path which can not contain a storage group name and (2) the sub path which is substring that begin after the storage group name.
(1) Suppose the part of the path can not contain a storage group name (e.g., "root".contains("root.sg") == false), then: For each one level wildcard *, only one level will be inferred and the wildcard will be removed. For each multi level wildcard **, then the inference will go on until the storage groups are found and the wildcard will be kept. (2) Suppose the part of the path is a substring that begin after the storage group name. (e.g., For "root.*.sg1.a.*.b.*" and "root.x.sg1" is a storage group, then this part is "a.*.b.*"). For this part, keep what it is.
Assuming we have three SGs: root.group1, root.group2, root.area1.group3 Eg1: for input "root.**", returns ("root.group1", "root.group1.**"), ("root.group2", "root.group2.**") ("root.area1.group3", "root.area1.group3.**") Eg2: for input "root.*.s1", returns ("root.group1", "root.group1.s1"), ("root.group2", "root.group2.s1")
Eg3: for input "root.area1.**", returns ("root.area1.group3", "root.area1.group3.**")
- Specified by:
groupPathByStorageGroupin interfaceIStorageGroupSchemaManager- Parameters:
path- can be a path pattern or a full path.- Returns:
- StorageGroupName-FullPath pairs
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getStorageGroupNum
public int getStorageGroupNum(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerTo calculate the count of storage group for given path pattern. If using prefix match, the path pattern is used to match prefix path. All timeseries start with the matched prefix path will be counted.- Specified by:
getStorageGroupNumin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getStorageGroupNodeByPath
public IStorageGroupMNode getStorageGroupNodeByPath(org.apache.iotdb.commons.path.PartialPath path) throws org.apache.iotdb.commons.exception.MetadataException
Description copied from interface:IStorageGroupSchemaManagerGet storage group node by path. the give path don't need to be storage group path.- Specified by:
getStorageGroupNodeByPathin interfaceIStorageGroupSchemaManager- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getAllStorageGroupNodes
public java.util.List<IStorageGroupMNode> getAllStorageGroupNodes()
Description copied from interface:IStorageGroupSchemaManagerGet all storage group MNodes- Specified by:
getAllStorageGroupNodesin interfaceIStorageGroupSchemaManager
-
isStorageGroupAlreadySet
public boolean isStorageGroupAlreadySet(org.apache.iotdb.commons.path.PartialPath path)
Description copied from interface:IStorageGroupSchemaManagerCheck whether the storage group of given path is set. The path may be a prefix path of some storage group. Besides, the given path may be also beyond the MTreeAboveSG scope, then return true if the covered part exists, which means there's storage group on this path. The rest part will be checked by certain storage group subTree.- Specified by:
isStorageGroupAlreadySetin interfaceIStorageGroupSchemaManager- Parameters:
path- a full path or a prefix path
-
getNodesListInGivenLevel
public org.apache.iotdb.tsfile.utils.Pair<java.util.List<org.apache.iotdb.commons.path.PartialPath>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getNodesListInGivenLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, boolean isPrefixMatch, LocalSchemaProcessor.StorageGroupFilter filter) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerTo collect nodes in the given level for given path pattern. If using prefix match, the path pattern is used to match prefix path. All nodes start with the matched prefix path will be collected. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be collected by certain SchemaRegion. The involved storage groups will be collected to fetch schemaRegion.- Specified by:
getNodesListInGivenLevelin interfaceIStorageGroupSchemaManager- Parameters:
pathPattern- a path pattern or a full pathnodeLevel- the level should match the level of the pathisPrefixMatch- if true, the path pattern is used to match prefix path- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getChildNodePathInNextLevel
public org.apache.iotdb.tsfile.utils.Pair<java.util.Set<org.apache.iotdb.common.rpc.thrift.TSchemaNode>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodePathInNextLevel(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerGet child node path in the next level of the given path pattern. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be counted by certain Storage Group.give pathPattern and the child nodes is those matching pathPattern.*
e.g., MTree has [root.a.sg1.d1.s1, root.b.sg1.d1.s2, root.c.sg1.d2.s1] given path = root return [root.a, root.b]
- Specified by:
getChildNodePathInNextLevelin interfaceIStorageGroupSchemaManager- Parameters:
pathPattern- The given path- Returns:
- All child nodes' seriesPath(s) of given seriesPath.
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getChildNodeNameInNextLevel
public org.apache.iotdb.tsfile.utils.Pair<java.util.Set<java.lang.String>,java.util.Set<org.apache.iotdb.commons.path.PartialPath>> getChildNodeNameInNextLevel(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionDescription copied from interface:IStorageGroupSchemaManagerGet child node path in the next level of the given path pattern. This method only count in nodes above storage group. Nodes below storage group, including storage group node will be counted by certain Storage Group.give pathPattern and the child nodes is those matching pathPattern.*
e.g., MTree has [root.a.sg1.d1.s1, root.b.sg1.d1.s2, root.c.sg1.d2.s1] given path = root return [a, b]
- Specified by:
getChildNodeNameInNextLevelin interfaceIStorageGroupSchemaManager- Parameters:
pathPattern- The given path- Returns:
- All child nodes' seriesPath(s) of given seriesPath.
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
-