Class LocalSchemaProcessor
- java.lang.Object
-
- org.apache.iotdb.db.metadata.LocalSchemaProcessor
-
public class LocalSchemaProcessor extends java.lang.ObjectThis class takes the responsibility of serialization of all the metadata info and persistent it into files. This class contains all the interfaces to modify the metadata for 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:
- SchemaProcessor Singleton
- Interfaces and Implementation of Operating PhysicalPlans of Metadata
- Interfaces and Implementation for Timeseries operation
- Interfaces and Implementation for StorageGroup and TTL operation
- Interfaces for metadata info Query
- Interfaces for metadata count
- Interfaces for level Node info Query
- Interfaces for StorageGroup and TTL info Query
- Interfaces for Entity/Device info Query
- Interfaces for timeseries, measurement and schema info Query
- Interfaces and methods for MNode query
- Interfaces for alias and tag/attribute operations
- Interfaces only for Cluster module usage
- Interfaces for lastCache operations
- Interfaces and Implementation for InsertPlan process
- Interfaces and Implementation for Template operations
- Interfaces for Trigger
- TestOnly Interfaces
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLocalSchemaProcessor.StorageGroupFilterStorageGroupFilter filters unsatisfied storage groups in metadata queries to speed up and deduplicate.
-
Field Summary
Fields Modifier and Type Field Description protected static IoTDBConfigconfig
-
Constructor Summary
Constructors Modifier Constructor Description protectedLocalSchemaProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttributes(java.util.Map<java.lang.String,java.lang.String> attributesMap, org.apache.iotdb.commons.path.PartialPath fullPath)add new attributes key-value for the timeseriesvoidaddTags(java.util.Map<java.lang.String,java.lang.String> tagsMap, org.apache.iotdb.commons.path.PartialPath fullPath)add new tags key-value for the timeseriesvoidappendSchemaTemplate(AppendTemplatePlan plan)voidcacheMeta(org.apache.iotdb.commons.path.PartialPath path, IMeasurementMNode measurementMNode, boolean needSetFullPath)if the path is in local mtree, nothing needed to do (because mtree is in the memory); Otherwise cache the path to mRemoteSchemaCachevoidchangeAlias(org.apache.iotdb.commons.path.PartialPath path, java.lang.String alias)booleancheckStorageGroupByPath(org.apache.iotdb.commons.path.PartialPath path)Check whether the given path contains a storage groupintcountMeasurementsInTemplate(java.lang.String templateName)voidcreateAlignedTimeSeries(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)voidcreateAlignedTimeSeries(CreateAlignedTimeSeriesPlan plan)create aligned timeseriesvoidcreateSchemaTemplate(CreateTemplatePlan plan)voidcreateTimeseries(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)Add one timeseries to metadata tree, if the timeseries already exists, throw exceptionvoidcreateTimeseries(CreateTimeSeriesPlan plan)voidcreateTimeseries(CreateTimeSeriesPlan plan, long offset)voiddeleteLastCacheByDevice(org.apache.iotdb.commons.path.PartialPath deviceId)delete all the last cache value of any timeseries or aligned timeseries under the devicevoiddeleteLastCacheByDevice(org.apache.iotdb.commons.path.PartialPath deviceId, org.apache.iotdb.commons.path.PartialPath originalPath, long startTime, long endTime)delete the last cache value of timeseries or subMeasurement of some aligned timeseries, which is under the device and matching the originalPathvoiddeleteStorageGroups(java.util.List<org.apache.iotdb.commons.path.PartialPath> storageGroups)Delete storage groups of given paths from MTree.java.lang.StringdeleteTimeseries(org.apache.iotdb.commons.path.PartialPath pathPattern)Delete all timeseries matching the given path pattern, may cross different storage groupjava.lang.StringdeleteTimeseries(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)Delete all timeseries matching the given path pattern, may cross different storage group.voiddropSchemaTemplate(DropTemplatePlan plan)voiddropTagsOrAttributes(java.util.Set<java.lang.String> keySet, org.apache.iotdb.commons.path.PartialPath fullPath)drop tags or attributes of the timeseriesvoidforceMlog()java.util.List<MeasurementPath>getAllMeasurementByDevicePath(org.apache.iotdb.commons.path.PartialPath devicePath)java.util.List<IStorageGroupMNode>getAllStorageGroupNodes()Get all storage group MNodesjava.util.List<org.apache.iotdb.commons.path.PartialPath>getAllStorageGroupPaths()Get all storage group pathsjava.util.Set<java.lang.String>getAllTemplates()intgetAllTimeseriesCount(org.apache.iotdb.commons.path.PartialPath pathPattern)To calculate the count of timeseries matching given path.intgetAllTimeseriesCount(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)To calculate the count of timeseries matching given path.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.org.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.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.java.lang.StringgetDeviceId(org.apache.iotdb.commons.path.PartialPath devicePath)To reduce the String number in memory, use the deviceId from SchemaProcessor instead of the deviceId read from diskIMNodegetDeviceNode(org.apache.iotdb.commons.path.PartialPath path)intgetDevicesNum(org.apache.iotdb.commons.path.PartialPath pathPattern)To calculate the count of devices for given path pattern.intgetDevicesNum(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch)To calculate the count of devices for given path pattern.static LocalSchemaProcessorgetInstance()we should not use this function in other place, but only in IoTDB classorg.apache.iotdb.tsfile.read.TimeValuePairgetLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath)Get the last cache value of time series of given seriesPath.org.apache.iotdb.tsfile.read.TimeValuePairgetLastCache(IMeasurementMNode node)Get the last cache value in given MeasurementMNode.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.java.util.List<ShowDevicesResult>getMatchedDevices(ShowDevicesPlan plan)Get all device paths and according storage group paths as ShowDevicesResult.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.java.util.Map<org.apache.iotdb.commons.path.PartialPath,java.lang.Integer>getMeasurementCountGroupByLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int level, boolean isPrefixMatch)IMeasurementMNodegetMeasurementMNode(org.apache.iotdb.commons.path.PartialPath fullPath)protected IMeasurementMNodegetMeasurementMNode(IMNode deviceMNode, java.lang.String measurementName)Invoked during insertPlan process.java.util.List<MeasurementPath>getMeasurementPaths(org.apache.iotdb.commons.path.PartialPath pathPattern)Return all measurement paths for given path if the path is abstract.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.java.util.List<java.lang.String>getMeasurementsInTemplate(java.lang.String templateName, java.lang.String path)java.lang.StringgetMetadataInString()Get metadata in stringIMNodegetMNodeForTrigger(org.apache.iotdb.commons.path.PartialPath fullPath)intgetNodesCountInGivenLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int level)To calculate the count of nodes in the given level for given path pattern.intgetNodesCountInGivenLevel(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)Get all nodes matching the given path pattern in the given level.java.util.List<org.apache.iotdb.commons.path.PartialPath>getNodesListInGivenLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int nodeLevel, LocalSchemaProcessor.StorageGroupFilter filter)java.util.Set<java.lang.String>getPathsSetTemplate(java.lang.String templateName)Get all paths set designated templatejava.util.Set<java.lang.String>getPathsUsingTemplate(java.lang.String templateName)java.util.List<org.apache.iotdb.tsfile.utils.Pair<java.lang.String,org.apache.iotdb.tsfile.write.schema.IMeasurementSchema>>getSchemasInTemplate(java.lang.String templateName, java.lang.String path)org.apache.iotdb.tsfile.write.schema.IMeasurementSchemagetSeriesSchema(org.apache.iotdb.commons.path.PartialPath fullPath)Get schema of paritialPathIMNodegetSeriesSchemasAndReadLockDevice(InsertPlan plan)get schema for device.org.apache.iotdb.tsfile.file.metadata.enums.TSDataTypegetSeriesType(org.apache.iotdb.commons.path.PartialPath fullPath)Get series type for given seriesPath.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<org.apache.iotdb.commons.path.PartialPath,java.lang.Long>getStorageGroupsTTL()get all storageGroups ttlTemplategetTemplate(java.lang.String templateName)longgetTotalSeriesNumber()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.booleanisMeasurementInTemplate(java.lang.String templateName, java.lang.String path)booleanisPathExist(org.apache.iotdb.commons.path.PartialPath path)Check whether the path exists.booleanisPathExistsInTemplate(java.lang.String templateName, java.lang.String path)booleanisStorageGroup(org.apache.iotdb.commons.path.PartialPath path)Check if the given path is storage group or not.voidoperation(PhysicalPlan plan)voidpruneSchemaTemplate(PruneTemplatePlan plan)voidreleaseMNodeAfterDropTrigger(IMNode imNode)voidrenameTagOrAttributeKey(java.lang.String oldKey, java.lang.String newKey, org.apache.iotdb.commons.path.PartialPath fullPath)rename the tag or attribute's key of the timeseriesvoidresetLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath)Reset the last cache value of time series of given seriesPath.voidsetSchemaTemplate(SetTemplatePlan plan)voidsetStorageGroup(org.apache.iotdb.commons.path.PartialPath storageGroup)Set storage group of the given path to MTree.voidsetTagsOrAttributesValue(java.util.Map<java.lang.String,java.lang.String> alterMap, org.apache.iotdb.commons.path.PartialPath fullPath)set/change the values of tags or attributesvoidsetTTL(org.apache.iotdb.commons.path.PartialPath storageGroup, long dataTTL)voidsetUsingSchemaTemplate(ActivateTemplatePlan plan)java.util.List<ShowTimeSeriesResult>showTimeseries(ShowTimeSeriesPlan plan, QueryContext context)voidunsetSchemaTemplate(UnsetTemplatePlan plan)voidupdateLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath, org.apache.iotdb.tsfile.read.TimeValuePair timeValuePair, boolean highPriorityUpdate, java.lang.Long latestFlushedTime)Update the last cache value of time series of given seriesPath.voidupdateLastCache(IMeasurementMNode node, org.apache.iotdb.tsfile.read.TimeValuePair timeValuePair, boolean highPriorityUpdate, java.lang.Long latestFlushedTime)Update the last cache value in given MeasurementMNode.voidupsertTagsAndAttributes(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.
-
-
-
Field Detail
-
config
protected static IoTDBConfig config
-
-
Method Detail
-
getInstance
public static LocalSchemaProcessor getInstance()
we should not use this function in other place, but only in IoTDB class
-
operation
public void operation(PhysicalPlan plan) throws java.io.IOException, org.apache.iotdb.commons.exception.MetadataException
- Throws:
java.io.IOExceptionorg.apache.iotdb.commons.exception.MetadataException
-
createTimeseries
public void createTimeseries(CreateTimeSeriesPlan plan) 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
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
createTimeseries
public void 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) throws org.apache.iotdb.commons.exception.MetadataExceptionAdd one timeseries to metadata tree, if the timeseries already exists, throw exception- Parameters:
path- the timeseries pathdataType- the dateTypeDataTypeof the timeseriesencoding- the encoding functionEncodingof the timeseriescompressor- the compressor functionCompressorof the time series- 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
-
createAlignedTimeSeries
public void createAlignedTimeSeries(CreateAlignedTimeSeriesPlan plan) throws org.apache.iotdb.commons.exception.MetadataException
create aligned timeseries- Parameters:
plan- CreateAlignedTimeSeriesPlan- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
deleteTimeseries
public java.lang.String deleteTimeseries(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch) throws org.apache.iotdb.commons.exception.MetadataExceptionDelete all timeseries matching the given path pattern, may cross different storage group. 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 deletedisPrefixMatch- if true, the path pattern is used to match prefix path- Returns:
- deletion failed Timeseries
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
deleteTimeseries
public java.lang.String deleteTimeseries(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionDelete all timeseries matching the given path pattern, may cross different storage group- Parameters:
pathPattern- path to be deleted- Returns:
- deletion failed Timeseries
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setStorageGroup
public void setStorageGroup(org.apache.iotdb.commons.path.PartialPath storageGroup) throws org.apache.iotdb.commons.exception.MetadataExceptionSet storage group of the given path to MTree.- Parameters:
storageGroup- root.node.(node)*- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
deleteStorageGroups
public void deleteStorageGroups(java.util.List<org.apache.iotdb.commons.path.PartialPath> storageGroups) throws org.apache.iotdb.commons.exception.MetadataExceptionDelete storage groups of given paths from MTree.- Parameters:
storageGroups- list of paths to be deleted.- 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- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.io.IOException
-
isPathExist
public boolean isPathExist(org.apache.iotdb.commons.path.PartialPath path)
Check whether the path exists.- Parameters:
path- a full path or a prefix path
-
getMetadataInString
public java.lang.String getMetadataInString()
Get metadata in string
-
getAllTimeseriesCount
public int getAllTimeseriesCount(org.apache.iotdb.commons.path.PartialPath pathPattern, boolean isPrefixMatch) throws org.apache.iotdb.commons.exception.MetadataExceptionTo 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
public int getAllTimeseriesCount(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionTo calculate the count of timeseries matching given path. The path could be a pattern of 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.MetadataExceptionTo 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
-
getDevicesNum
public int getDevicesNum(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionTo calculate the count of devices for given path pattern.- 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.MetadataExceptionTo 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.- 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.MetadataExceptionTo 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 pathlevel- 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
-
getNodesCountInGivenLevel
public int getNodesCountInGivenLevel(org.apache.iotdb.commons.path.PartialPath pathPattern, int level) throws org.apache.iotdb.commons.exception.MetadataExceptionTo calculate the count of nodes in the given level for given path pattern.- Parameters:
pathPattern- a path pattern or a full pathlevel- the level should match the level of the 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- 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) throws org.apache.iotdb.commons.exception.MetadataExceptionGet all nodes matching the given path pattern in the given level. The level of the path should match the nodeLevel. 1. The given level equals the path level without **, e.g. give path root.*.d.* and the level should be 4. 2. The given level is greater than path level with **, e.g. give path root.** and the level could be 2 or 3.- Parameters:
pathPattern- can be a pattern of a full path.nodeLevel- the level should match the level of the path- Returns:
- A List instance which stores all node at given level
- 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, LocalSchemaProcessor.StorageGroupFilter filter) throws org.apache.iotdb.commons.exception.MetadataException- 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.MetadataExceptionGet 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
public java.util.Set<java.lang.String> getChildNodeNameInNextLevel(org.apache.iotdb.commons.path.PartialPath pathPattern) throws org.apache.iotdb.commons.exception.MetadataExceptionGet 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
-
isStorageGroup
public boolean isStorageGroup(org.apache.iotdb.commons.path.PartialPath path)
Check if the given path is storage group or not.- Parameters:
path- Format: root.node.(node)*
-
checkStorageGroupByPath
public boolean checkStorageGroupByPath(org.apache.iotdb.commons.path.PartialPath path)
Check whether the given path contains a storage group
-
getBelongedStorageGroup
public org.apache.iotdb.commons.path.PartialPath getBelongedStorageGroup(org.apache.iotdb.commons.path.PartialPath path) throws StorageGroupNotSetExceptionGet storage group name by pathe.g., root.sg1 is a storage group and path = root.sg1.d1, return root.sg1
- 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.MetadataExceptionGet 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.
- 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
-
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.MetadataExceptionGet 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.- 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()
Get all storage group paths
-
getStorageGroupsTTL
public java.util.Map<org.apache.iotdb.commons.path.PartialPath,java.lang.Long> getStorageGroupsTTL()
get all storageGroups ttl- Returns:
- key-> storageGroupPath, value->ttl
-
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.MetadataExceptionGet 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
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.MetadataExceptionGet 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
public java.util.List<ShowDevicesResult> 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.
- 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.- 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
-
getMeasurementPaths
public java.util.List<MeasurementPath> getMeasurementPaths(org.apache.iotdb.commons.path.PartialPath pathPattern) 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 '*'.- Parameters:
pathPattern- can be a pattern or a full path of timeseries.- 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.- Parameters:
isPrefixMatch- if true, the path pattern is used to match prefix path- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
showTimeseries
public java.util.List<ShowTimeSeriesResult> showTimeseries(ShowTimeSeriesPlan plan, QueryContext context) throws org.apache.iotdb.commons.exception.MetadataException
- 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.MetadataExceptionGet 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.MetadataExceptionGet schema of paritialPath- Parameters:
fullPath- (may be ParitialPath or AlignedPath)- Returns:
- MeasurementSchema
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getAllMeasurementByDevicePath
public java.util.List<MeasurementPath> getAllMeasurementByDevicePath(org.apache.iotdb.commons.path.PartialPath devicePath) throws PathNotExistException
- Throws:
PathNotExistException
-
getStorageGroupNodeByPath
public IStorageGroupMNode getStorageGroupNodeByPath(org.apache.iotdb.commons.path.PartialPath path) throws org.apache.iotdb.commons.exception.MetadataException
Get storage group node by path. the give path don't need to be storage group path.- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getAllStorageGroupNodes
public java.util.List<IStorageGroupMNode> getAllStorageGroupNodes()
Get all storage group MNodes
-
getDeviceNode
public IMNode getDeviceNode(org.apache.iotdb.commons.path.PartialPath path) throws org.apache.iotdb.commons.exception.MetadataException
- 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
- 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, java.io.IOException- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.io.IOException
-
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.IOExceptionupsert 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 aliastagsMap- newly added tags mapattributesMap- newly added attributes mapfullPath- timeseries- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.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.IOExceptionadd new attributes key-value for the timeseries- Parameters:
attributesMap- newly added attributes mapfullPath- timeseries- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.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.IOExceptionadd new tags key-value for the timeseries- Parameters:
tagsMap- newly added tags mapfullPath- timeseries- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.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.IOExceptiondrop tags or attributes of the timeseries- Parameters:
keySet- tags key or attributes keyfullPath- timeseries path- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.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.IOExceptionset/change the values of tags or attributes- Parameters:
alterMap- the new tags or attributes key-valuefullPath- timeseries- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.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.IOExceptionrename the tag or attribute's key of the timeseries- Parameters:
oldKey- old key of tag or attributenewKey- new key of tag or attributefullPath- timeseries- Throws:
org.apache.iotdb.commons.exception.MetadataExceptionjava.io.IOException
-
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.MetadataExceptionFor 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.**")
- Parameters:
path- can be a path pattern or a full path.- Returns:
- StorageGroupName-FullPath pairs
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
cacheMeta
public void cacheMeta(org.apache.iotdb.commons.path.PartialPath path, IMeasurementMNode measurementMNode, boolean needSetFullPath)if the path is in local mtree, nothing needed to do (because mtree is in the memory); Otherwise cache the path to mRemoteSchemaCache
-
updateLastCache
public void updateLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath, org.apache.iotdb.tsfile.read.TimeValuePair timeValuePair, boolean highPriorityUpdate, java.lang.Long latestFlushedTime)Update the last cache value of time series of given seriesPath.SchemaProcessor will use the seriesPath to search the node first and then process the lastCache in the MeasurementMNode
Invoking scenario: (1) after executing insertPlan (2) after reading last value from file during last Query
- Parameters:
seriesPath- the PartialPath of full path from root to MeasurementtimeValuePair- the latest point valuehighPriorityUpdate- the last value from insertPlan is high prioritylatestFlushedTime- latest flushed time
-
updateLastCache
public void updateLastCache(IMeasurementMNode node, org.apache.iotdb.tsfile.read.TimeValuePair timeValuePair, boolean highPriorityUpdate, java.lang.Long latestFlushedTime)
Update the last cache value in given MeasurementMNode. work.Invoking scenario: (1) after executing insertPlan (2) after reading last value from file during last Query
- Parameters:
node- the measurementMNode holding the lastCachetimeValuePair- the latest point valuehighPriorityUpdate- the last value from insertPlan is high prioritylatestFlushedTime- latest flushed time
-
getLastCache
public org.apache.iotdb.tsfile.read.TimeValuePair getLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath)
Get the last cache value of time series of given seriesPath. SchemaProcessor will use the seriesPath to search the node.Invoking scenario: last cache read during last Query
- Parameters:
seriesPath- the PartialPath of full path from root to Measurement- Returns:
- the last cache value
-
getLastCache
public org.apache.iotdb.tsfile.read.TimeValuePair getLastCache(IMeasurementMNode node)
Get the last cache value in given MeasurementMNode.Invoking scenario: last cache read during last Query
- Parameters:
node- the measurementMNode holding the lastCache- Returns:
- the last cache value
-
resetLastCache
public void resetLastCache(org.apache.iotdb.commons.path.PartialPath seriesPath)
Reset the last cache value of time series of given seriesPath. SchemaProcessor will use the seriesPath to search the node.- Parameters:
seriesPath- the PartialPath of full path from root to Measurement
-
deleteLastCacheByDevice
public void deleteLastCacheByDevice(org.apache.iotdb.commons.path.PartialPath deviceId) throws org.apache.iotdb.commons.exception.MetadataExceptiondelete all the last cache value of any timeseries or aligned timeseries under the deviceInvoking scenario (1) after upload tsfile
- Parameters:
deviceId- path of device- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
deleteLastCacheByDevice
public void deleteLastCacheByDevice(org.apache.iotdb.commons.path.PartialPath deviceId, org.apache.iotdb.commons.path.PartialPath originalPath, long startTime, long endTime) throws org.apache.iotdb.commons.exception.MetadataExceptiondelete the last cache value of timeseries or subMeasurement of some aligned timeseries, which is under the device and matching the originalPathInvoking scenario (1) delete timeseries
- Parameters:
deviceId- path of deviceoriginalPath- origin timeseries pathstartTime- startTimeendTime- endTime- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getSeriesSchemasAndReadLockDevice
public 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.MetadataExceptionjava.io.IOException
-
createSchemaTemplate
public void createSchemaTemplate(CreateTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
appendSchemaTemplate
public void appendSchemaTemplate(AppendTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
pruneSchemaTemplate
public void pruneSchemaTemplate(PruneTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
countMeasurementsInTemplate
public int countMeasurementsInTemplate(java.lang.String templateName) throws org.apache.iotdb.commons.exception.MetadataException- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
isMeasurementInTemplate
public boolean isMeasurementInTemplate(java.lang.String templateName, java.lang.String path) throws org.apache.iotdb.commons.exception.MetadataException- Parameters:
templateName- name of template to checkpath- full path to check- Returns:
- if path correspond to a measurement in template
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
isPathExistsInTemplate
public boolean isPathExistsInTemplate(java.lang.String templateName, java.lang.String path) throws org.apache.iotdb.commons.exception.MetadataException- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getMeasurementsInTemplate
public java.util.List<java.lang.String> getMeasurementsInTemplate(java.lang.String templateName, java.lang.String path) throws org.apache.iotdb.commons.exception.MetadataException- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getSchemasInTemplate
public java.util.List<org.apache.iotdb.tsfile.utils.Pair<java.lang.String,org.apache.iotdb.tsfile.write.schema.IMeasurementSchema>> getSchemasInTemplate(java.lang.String templateName, java.lang.String path) throws org.apache.iotdb.commons.exception.MetadataException- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
getAllTemplates
public java.util.Set<java.lang.String> getAllTemplates()
-
getPathsSetTemplate
public java.util.Set<java.lang.String> getPathsSetTemplate(java.lang.String templateName) throws org.apache.iotdb.commons.exception.MetadataExceptionGet 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
public 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
-
dropSchemaTemplate
public void dropSchemaTemplate(DropTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setSchemaTemplate
public void setSchemaTemplate(SetTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
unsetSchemaTemplate
public void unsetSchemaTemplate(UnsetTemplatePlan plan) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
setUsingSchemaTemplate
public void setUsingSchemaTemplate(ActivateTemplatePlan plan) 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
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
releaseMNodeAfterDropTrigger
public void releaseMNodeAfterDropTrigger(IMNode imNode) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
forceMlog
public void forceMlog()
-
getTotalSeriesNumber
public long getTotalSeriesNumber()
-
getDeviceId
public java.lang.String getDeviceId(org.apache.iotdb.commons.path.PartialPath devicePath)
To reduce the String number in memory, use the deviceId from SchemaProcessor instead of the deviceId read from disk- Parameters:
devicePath- read from disk- Returns:
- deviceId
-
getTemplate
public Template getTemplate(java.lang.String templateName) throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
-