Class 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.Cloneable
    A prefix path, suffix path or fullPath generated from SQL. Usually used in the IoTDB server module
    See Also:
    Serialized Form
    • Field Detail

      • nodes

        protected java.lang.String[] nodes
    • Constructor Detail

      • PartialPath

        public PartialPath()
      • PartialPath

        public PartialPath​(java.lang.String path)
                    throws IllegalPathException
        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`"}
        Parameters:
        path - a full String of a time series path
        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 - path
        needSplit - 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:
        getFullPath in class org.apache.iotdb.tsfile.read.common.Path
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class org.apache.iotdb.tsfile.read.common.Path
      • equals

        public boolean equals​(java.lang.String obj)
        Overrides:
        equals in class org.apache.iotdb.tsfile.read.common.Path
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.apache.iotdb.tsfile.read.common.Path
      • getMeasurement

        public java.lang.String getMeasurement()
        Overrides:
        getMeasurement in class org.apache.iotdb.tsfile.read.common.Path
      • getFirstNode

        public java.lang.String getFirstNode()
      • getDevice

        public java.lang.String getDevice()
        Overrides:
        getDevice in class org.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:
        getFullPathWithAlias in class org.apache.iotdb.tsfile.read.common.Path
      • 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:
        compareTo in interface java.lang.Comparable<org.apache.iotdb.tsfile.read.common.Path>
        Overrides:
        compareTo in class org.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:
        toString in class org.apache.iotdb.tsfile.read.common.Path
      • 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:
        clone in class org.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:
        serialize in class org.apache.iotdb.tsfile.read.common.Path
        Throws:
        java.io.IOException
      • serialize

        public void serialize​(java.nio.ByteBuffer byteBuffer)
        Overrides:
        serialize in class org.apache.iotdb.tsfile.read.common.Path
      • serialize

        public void serialize​(org.apache.iotdb.tsfile.utils.PublicBAOS stream)
                       throws java.io.IOException
        Overrides:
        serialize in class org.apache.iotdb.tsfile.read.common.Path
        Throws:
        java.io.IOException
      • serializeWithoutType

        protected void serializeWithoutType​(java.nio.ByteBuffer byteBuffer)
        Overrides:
        serializeWithoutType in class org.apache.iotdb.tsfile.read.common.Path
      • serializeWithoutType

        protected void serializeWithoutType​(java.io.OutputStream stream)
                                     throws java.io.IOException
        Overrides:
        serializeWithoutType in class org.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