Class PartialPath
- java.lang.Object
-
- org.apache.iotdb.tsfile.read.common.Path
-
- org.apache.iotdb.commons.path.PartialPath
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<org.apache.iotdb.tsfile.read.common.Path>
- Direct Known Subclasses:
AlignedPath,MeasurementPath
public class PartialPath extends org.apache.iotdb.tsfile.read.common.Path implements java.lang.Comparable<org.apache.iotdb.tsfile.read.common.Path>, java.lang.CloneableA prefix path, suffix path or fullPath generated from SQL. Usually used in the IoTDB server module- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]nodes
-
Constructor Summary
Constructors Constructor Description PartialPath()PartialPath(java.lang.String path)Construct the PartialPath using a String, will split the given String into String[] E.g., path = "root.sg.`d.1`.`s.1`" nodes = {"root", "sg", "`d.1`", "`s.1`"}PartialPath(java.lang.String[] partialNodes)PartialPath(java.lang.String path, boolean needSplit)only use this method in following situations: 1.PartialPath(java.lang.String device, java.lang.String measurement)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<PartialPath>alterPrefixPath(PartialPath prefix)Return the intersection of paths starting with the given prefix and paths matching this path pattern.PartialPathclone()intcompareTo(org.apache.iotdb.tsfile.read.common.Path path)PartialPathconcatNode(java.lang.String node)only use this method in following situations: 1.voidconcatPath(java.lang.String[] otherNodes)It will change nodes in this partial pathPartialPathconcatPath(PartialPath partialPath)it will return a new partial pathbooleancontainNode(java.lang.String otherNode)PartialPathcopy()static PartialPathdeserialize(java.nio.ByteBuffer byteBuffer)booleanequals(java.lang.Object obj)booleanequals(java.lang.String obj)static intestimateSize(PartialPath partialPath)PartialPath basic total, 52B Object header, 8B String[] reference + header + length, 8 + 4 + 8= 20B Path attributes' references, 8 * 3 = 24Bstatic java.util.List<PartialPath>fromStringList(java.util.List<java.lang.String> pathList)Convert a list of Strings to a list of PartialPaths, ignoring all illegal pathsjava.lang.StringgetDevice()PartialPathgetDevicePath()java.util.List<PartialPath>getDevicePathPattern()java.lang.StringgetFirstNode()java.lang.StringgetFullPath()java.lang.StringgetFullPathWithAlias()java.lang.StringgetMeasurement()java.lang.StringgetMeasurementAlias()org.apache.iotdb.tsfile.write.schema.IMeasurementSchemagetMeasurementSchema()intgetNodeLength()java.lang.String[]getNodes()org.apache.iotdb.tsfile.file.metadata.enums.TSDataTypegetSeriesType()java.lang.StringgetTailNode()inthashCode()booleanhasWildcard()booleaninclude(PartialPath rPath)Test if this path pattern includes input path pattern.booleanisMeasurementAliasExists()booleanmatchFullPath(PartialPath rPath)Test if current PartialPath matches a full path.booleanmatchPrefixPath(PartialPath prefixPath)Check if current pattern PartialPath can match 1 prefix path.booleanoverlapWith(PartialPath rPath)Test if this path pattern overlaps with input path pattern.booleanoverlapWithFullPathPrefix(PartialPath prefixFullPath)Test if this path pattern overlaps with input prefix full path.booleanprefixMatchFullPath(PartialPath rPath)Test if current PartialPath matches a full path's prefix.java.nio.ByteBufferserialize()voidserialize(java.io.OutputStream stream)voidserialize(java.nio.ByteBuffer byteBuffer)voidserialize(org.apache.iotdb.tsfile.utils.PublicBAOS stream)protected voidserializeWithoutType(java.io.OutputStream stream)protected voidserializeWithoutType(java.nio.ByteBuffer byteBuffer)voidsetMeasurementAlias(java.lang.String measurementAlias)booleanstartsWith(java.lang.String[] otherNodes)booleanstartWith(java.lang.String otherNode)java.lang.StringtoString()static java.util.List<java.lang.String>toStringList(java.util.List<PartialPath> pathList)org.apache.iotdb.tsfile.read.common.PathtoTSFilePath()PartialPathtransformToPartialPath()
-
-
-
Constructor Detail
-
PartialPath
public PartialPath()
-
PartialPath
public PartialPath(java.lang.String path) throws IllegalPathExceptionConstruct the PartialPath using a String, will split the given String into String[] E.g., path = "root.sg.`d.1`.`s.1`" nodes = {"root", "sg", "`d.1`", "`s.1`"}- Parameters:
path- a full String of a time series path- Throws:
IllegalPathException
-
PartialPath
public PartialPath(java.lang.String device, java.lang.String measurement) throws IllegalPathException- Throws:
IllegalPathException
-
PartialPath
public PartialPath(java.lang.String[] partialNodes)
- Parameters:
partialNodes- nodes of a time series path
-
PartialPath
public PartialPath(java.lang.String path, boolean needSplit)only use this method in following situations: 1. you are sure you do not want to split the path. 2. you are sure path is correct.- Parameters:
path- pathneedSplit- whether to split path to nodes, needSplit can only be false.
-
-
Method Detail
-
hasWildcard
public boolean hasWildcard()
-
concatPath
public PartialPath concatPath(PartialPath partialPath)
it will return a new partial path- Parameters:
partialPath- the path you want to concat- Returns:
- new partial path
-
concatPath
public void concatPath(java.lang.String[] otherNodes)
It will change nodes in this partial path- Parameters:
otherNodes- nodes
-
concatNode
public PartialPath concatNode(java.lang.String node)
only use this method in following situations: 1. you are sure node is allowed in syntax convention. 2. you are sure node needs not to be checked.
-
getNodes
public java.lang.String[] getNodes()
-
getNodeLength
public int getNodeLength()
-
getTailNode
public java.lang.String getTailNode()
-
alterPrefixPath
public java.util.List<PartialPath> alterPrefixPath(PartialPath prefix)
Return the intersection of paths starting with the given prefix and paths matching this path pattern.For example, minimizing "root.**.b.c" with prefix "root.a.b" produces "root.a.b.c", "root.a.b.b.c", "root.a.b.**.b.c", since the multi-level wildcard can match 'a', 'a.b', and any other sub paths start with 'a.b'.
The goal of this method is to reduce the search space when querying a database with a path with wildcard.
If this path or path pattern doesn't start with given prefix, return empty list. For example, "root.a.b.c".alterPrefixPath("root.b") or "root.a.**".alterPrefixPath("root.b") returns [].
- Parameters:
prefix- The prefix. Cannot be null and cannot contain any wildcard.
-
matchFullPath
public boolean matchFullPath(PartialPath rPath)
Test if current PartialPath matches a full path. Current partialPath acts as a full path pattern. rPath is supposed to be a full timeseries path without wildcards. e.g. "root.sg.device.*" matches path "root.sg.device.s1" whereas it does not match "root.sg.device" and "root.sg.vehicle.s1"- Parameters:
rPath- a plain full path of a timeseries- Returns:
- true if a successful match, otherwise return false
-
matchPrefixPath
public boolean matchPrefixPath(PartialPath prefixPath)
Check if current pattern PartialPath can match 1 prefix path.1) Current partialPath acts as a full path pattern.
2) Input parameter prefixPath is 1 prefix of time-series path.
For example:
1) Pattern "root.sg1.d1.*" can match prefix path "root.sg1.d1.s1", "root.sg1.d1", "root.sg1", "root" etc.
1) Pattern "root.sg1.d1.*" does not match prefix path "root.sg2", "root.sg1.d2".
- Parameters:
prefixPath-- Returns:
- true if a successful match, otherwise return false
-
prefixMatchFullPath
public boolean prefixMatchFullPath(PartialPath rPath)
Test if current PartialPath matches a full path's prefix. Current partialPath acts as a prefix path pattern. rPath is supposed to be a full time-series path without wildcards. e.g. Current PartialPath "root.sg" or "root.*" can match rPath "root.sg.device.s1", "root.sg.device" or "root.sg.vehicle.s1".- Parameters:
rPath- a plain full path of a time-series- Returns:
- true if a successful match, otherwise return false.
-
include
public boolean include(PartialPath rPath)
Test if this path pattern includes input path pattern. e.g. "root.**" includes "root.sg.**", "root.*.d.s" includes "root.sg.d.s", "root.sg.**" does not include "root.**.s", "root.*.d.s" does not include "root.sg.d1.*"- Parameters:
rPath- a pattern path of a timeseries- Returns:
- true if this path pattern includes input path pattern, otherwise return false
-
overlapWith
public boolean overlapWith(PartialPath rPath)
Test if this path pattern overlaps with input path pattern. Overlap means the result sets generated by two path pattern share some common elements. e.g. "root.sg.**" overlaps with "root.**", "root.*.d.s" overlaps with "root.sg.d.s", "root.sg.**" overlaps with "root.**.s", "root.*.d.s" doesn't overlap with "root.sg.d1.*"- Parameters:
rPath- a pattern path of a timeseries- Returns:
- true if overlapping otherwise return false
-
overlapWithFullPathPrefix
public boolean overlapWithFullPathPrefix(PartialPath prefixFullPath)
Test if this path pattern overlaps with input prefix full path. Overlap means the result sets generated by two path pattern share some common elements. e.g.- "root.sg.**" overlaps with prefix full path "root" because "root.sg.**" share some common element "root.sg.d" with "root.**"
- "root.*.d*.s" overlaps with prefix full path "root.sg" because "root.*.d*.s" share some common element "root.sg.d1.s" with "root.sg.**"
- "root.*.d.s" doesn't overlap with prefix full path "root.sg.d1" because there is no common element between "root.*.d.s" and "root.sg.d1.**"
- Parameters:
prefixFullPath- prefix full path- Returns:
- true if overlapping otherwise return false
-
getFullPath
public java.lang.String getFullPath()
- Overrides:
getFullPathin classorg.apache.iotdb.tsfile.read.common.Path
-
copy
public PartialPath copy()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classorg.apache.iotdb.tsfile.read.common.Path
-
equals
public boolean equals(java.lang.String obj)
- Overrides:
equalsin classorg.apache.iotdb.tsfile.read.common.Path
-
hashCode
public int hashCode()
- Overrides:
hashCodein classorg.apache.iotdb.tsfile.read.common.Path
-
getMeasurement
public java.lang.String getMeasurement()
- Overrides:
getMeasurementin classorg.apache.iotdb.tsfile.read.common.Path
-
getFirstNode
public java.lang.String getFirstNode()
-
getDevice
public java.lang.String getDevice()
- Overrides:
getDevicein classorg.apache.iotdb.tsfile.read.common.Path
-
getMeasurementAlias
public java.lang.String getMeasurementAlias()
-
setMeasurementAlias
public void setMeasurementAlias(java.lang.String measurementAlias)
-
isMeasurementAliasExists
public boolean isMeasurementAliasExists()
-
getFullPathWithAlias
public java.lang.String getFullPathWithAlias()
- Overrides:
getFullPathWithAliasin classorg.apache.iotdb.tsfile.read.common.Path
-
getMeasurementSchema
public org.apache.iotdb.tsfile.write.schema.IMeasurementSchema getMeasurementSchema() throws MetadataException- Throws:
MetadataException
-
getSeriesType
public org.apache.iotdb.tsfile.file.metadata.enums.TSDataType getSeriesType() throws java.lang.UnsupportedOperationException- Throws:
java.lang.UnsupportedOperationException
-
compareTo
public int compareTo(org.apache.iotdb.tsfile.read.common.Path path)
- Specified by:
compareToin interfacejava.lang.Comparable<org.apache.iotdb.tsfile.read.common.Path>- Overrides:
compareToin classorg.apache.iotdb.tsfile.read.common.Path
-
startsWith
public boolean startsWith(java.lang.String[] otherNodes)
-
startWith
public boolean startWith(java.lang.String otherNode)
-
containNode
public boolean containNode(java.lang.String otherNode)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classorg.apache.iotdb.tsfile.read.common.Path
-
getDevicePath
public PartialPath getDevicePath()
-
getDevicePathPattern
public java.util.List<PartialPath> getDevicePathPattern()
-
toTSFilePath
public org.apache.iotdb.tsfile.read.common.Path toTSFilePath()
-
toStringList
public static java.util.List<java.lang.String> toStringList(java.util.List<PartialPath> pathList)
-
fromStringList
public static java.util.List<PartialPath> fromStringList(java.util.List<java.lang.String> pathList)
Convert a list of Strings to a list of PartialPaths, ignoring all illegal paths- Parameters:
pathList-- Returns:
-
clone
public PartialPath clone()
- Overrides:
clonein classorg.apache.iotdb.tsfile.read.common.Path
-
serialize
public java.nio.ByteBuffer serialize() throws java.io.IOException- Throws:
java.io.IOException
-
serialize
public void serialize(java.io.OutputStream stream) throws java.io.IOException- Overrides:
serializein classorg.apache.iotdb.tsfile.read.common.Path- Throws:
java.io.IOException
-
serialize
public void serialize(java.nio.ByteBuffer byteBuffer)
- Overrides:
serializein classorg.apache.iotdb.tsfile.read.common.Path
-
serialize
public void serialize(org.apache.iotdb.tsfile.utils.PublicBAOS stream) throws java.io.IOException- Overrides:
serializein classorg.apache.iotdb.tsfile.read.common.Path- Throws:
java.io.IOException
-
serializeWithoutType
protected void serializeWithoutType(java.nio.ByteBuffer byteBuffer)
- Overrides:
serializeWithoutTypein classorg.apache.iotdb.tsfile.read.common.Path
-
serializeWithoutType
protected void serializeWithoutType(java.io.OutputStream stream) throws java.io.IOException- Overrides:
serializeWithoutTypein classorg.apache.iotdb.tsfile.read.common.Path- Throws:
java.io.IOException
-
deserialize
public static PartialPath deserialize(java.nio.ByteBuffer byteBuffer)
-
transformToPartialPath
public PartialPath transformToPartialPath()
-
estimateSize
public static int estimateSize(PartialPath partialPath)
PartialPath basic total, 52B- Object header, 8B
- String[] reference + header + length, 8 + 4 + 8= 20B
- Path attributes' references, 8 * 3 = 24B
-
-