Class CharSequenceWrapper

java.lang.Object
org.apache.drill.exec.expr.fn.impl.CharSequenceWrapper
All Implemented Interfaces:
CharSequence

public class CharSequenceWrapper extends Object implements CharSequence
A CharSequence is a readable sequence of char values. This interface provides uniform, read-only access to many different kinds of char sequences. A char value represents a character in the Basic Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.
Specifically this implementation of the CharSequence adapts a Drill DrillBuf to the CharSequence. The implementation is meant to be re-used that is allocated once and then passed DrillBuf to adapt. This can be handy to exploit API that consume CharSequence avoiding the need to create string objects.
  • Constructor Details

    • CharSequenceWrapper

      public CharSequenceWrapper()
    • CharSequenceWrapper

      public CharSequenceWrapper(int start, int end, DrillBuf buffer)
  • Method Details

    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      When using the Java regex Matcher the subSequence is only called when capturing groups. Drill does not currently use capture groups in the UDF so this method is not required.
      It could be implemented by creating a new CharSequenceWrapper however this would imply newly allocated objects which is what this wrapper tries to avoid.
      Specified by:
      subSequence in interface CharSequence
    • setBuffer

      public void setBuffer(int start, int end, DrillBuf buffer)
      Set the DrillBuf to adapt to a CharSequence. This method can be used to replace any previous DrillBuf thus avoiding recreating the CharSequenceWrapper and thus re-using the CharSequenceWrapper object.
      Parameters:
      start -
      end -
      buffer -
    • toString

      public String toString()
      The regexp_replace function is implemented in a way to avoid the call to toString() not to uselessly create a string object.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object