Class PathSegment

java.lang.Object
org.apache.drill.common.expression.PathSegment
Direct Known Subclasses:
PathSegment.ArraySegment, PathSegment.NameSegment

public abstract class PathSegment extends Object
Used to represent path to nested field within schema as a chain of path segments. Where each segment in the chain may be either named or array segment.
See Also:
  • Field Details

    • originalValue

      protected final Object originalValue
      Holds original value associated with the path segment. Used when reading data from DICT.
    • originalValueType

      protected final TypeProtos.MajorType originalValueType
      Indicates the type of original value.
      See Also:
  • Constructor Details

  • Method Details

    • cloneWithNewChild

      public abstract PathSegment cloneWithNewChild(PathSegment newChild)
      Makes copy of segment chain with newChild added at the end.
      Parameters:
      newChild - new child to add
      Returns:
      full copy of segment chain with new child added at the end of chain
    • clone

      public abstract PathSegment clone()
      Overrides:
      clone in class Object
    • getOriginalValue

      public Object getOriginalValue()
    • getOriginalValueType

      public TypeProtos.MajorType getOriginalValueType()
    • getNameSegment

      public PathSegment.NameSegment getNameSegment()
    • getArraySegment

      public PathSegment.ArraySegment getArraySegment()
    • isArray

      public abstract boolean isArray()
    • isNamed

      public abstract boolean isNamed()
    • isLastPath

      public boolean isLastPath()
    • getChild

      public PathSegment getChild()
    • segmentHashCode

      protected abstract int segmentHashCode()
    • segmentEquals

      protected abstract boolean segmentEquals(PathSegment other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • contains

      public boolean contains(PathSegment otherSeg)
      Check if another path is contained in this one. This is useful for 2 cases. The first is checking if the other is lower down in the tree, below this path. The other is if a path is actually contained above the current one. Examples: [a] . contains( [a.b.c] ) returns true [a.b.c] . contains( [a] ) returns true This behavior is used for cases like scanning json in an event based fashion, when we arrive at a node in a complex type, we will know the complete path back to the root. This method can be used to determine if we need the data below. This is true in both the cases where the column requested from the user is below the current node (in which case we may ignore other nodes further down the tree, while keeping others). This is also the case if the requested path is further up the tree, if we know we are at position a.b.c and a.b was a requested column, we need to scan all of the data at and below the current a.b.c node.
      Parameters:
      otherSeg - - path segment to check if it is contained below this one.
      Returns:
      - is this a match