Class StringValue

    • Constructor Detail

      • StringValue

        public StringValue()
        Initializes the encapsulated String object with an empty string.
      • StringValue

        public StringValue​(CharSequence value)
        Initializes this StringValue to the value of the given string.
        Parameters:
        value - The string containing the value for this StringValue.
      • StringValue

        public StringValue​(StringValue value)
        Initializes this StringValue to a copy the given StringValue.
        Parameters:
        value - The initial value.
      • StringValue

        public StringValue​(StringValue value,
                           int offset,
                           int len)
        Initializes the StringValue to a sub-string of the given StringValue.
        Parameters:
        value - The string containing the substring.
        offset - The offset of the substring.
        len - The length of the substring.
    • Method Detail

      • setLength

        public void setLength​(int len)
        Sets a new length for the string.
        Parameters:
        len - The new length.
      • getCharArray

        public char[] getCharArray()
        Returns this StringValue's internal character data. The array might be larger than the string which is currently stored in the StringValue.
        Returns:
        The character data.
      • getValue

        public String getValue()
        Gets this StringValue as a String.
        Returns:
        A String resembling the contents of this StringValue.
      • setValue

        public void setValue​(CharSequence value)
        Sets the value of the StringValue to the given string.
        Parameters:
        value - The new string value.
      • setValue

        public void setValue​(StringValue value,
                             int offset,
                             int len)
        Sets the value of the StringValue to a substring of the given string.
        Parameters:
        value - The new string value.
        offset - The position to start the substring.
        len - The length of the substring.
      • setValue

        public void setValue​(CharSequence value,
                             int offset,
                             int len)
        Sets the value of the StringValue to a substring of the given string.
        Parameters:
        value - The new string value.
        offset - The position to start the substring.
        len - The length of the substring.
      • setValue

        public void setValue​(CharBuffer buffer)
        Sets the contents of this string to the contents of the given CharBuffer. The characters between the buffer's current position (inclusive) and the buffer's limit (exclusive) will be stored in this string.
        Parameters:
        buffer - The character buffer to read the characters from.
      • setValue

        public void setValue​(char[] chars,
                             int offset,
                             int len)
        Sets the value of the StringValue to a substring of the given value.
        Parameters:
        chars - The new string value (as a character array).
        offset - The position to start the substring.
        len - The length of the substring.
      • setValueAscii

        public void setValueAscii​(byte[] bytes,
                                  int offset,
                                  int len)
        Sets the value of this StringValue, assuming that the binary data is ASCII coded. The n-th character of the StringValue corresponds directly to the n-th byte in the given array after the offset.
        Parameters:
        bytes - The binary character data.
        offset - The offset in the array.
        len - The number of bytes to read from the array.
      • substring

        public StringValue substring​(int start)
        Returns a new StringValuestring that is a substring of this string. The substring begins at the given start index and ends at end of the string
        Parameters:
        start - The beginning index, inclusive.
        Returns:
        The substring.
        Throws:
        IndexOutOfBoundsException - Thrown, if the start is negative.
      • substring

        public StringValue substring​(int start,
                                     int end)
        Returns a new StringValuestring that is a substring of this string. The substring begins at the given start index and ends at end - 1.
        Parameters:
        start - The beginning index, inclusive.
        end - The ending index, exclusive.
        Returns:
        The substring.
        Throws:
        IndexOutOfBoundsException - Thrown, if the start is negative, or the end is larger than the length.
      • substring

        public void substring​(StringValue target,
                              int start)
        Copies a substring of this string into the given target StringValue. The substring begins at the given start index and ends at end of the string
        Parameters:
        target - The StringValue object to copy the substring to.
        start - The beginning index, inclusive.
        Throws:
        IndexOutOfBoundsException - Thrown, if the start is negative.
      • substring

        public void substring​(StringValue target,
                              int start,
                              int end)
        Copies a substring of this string into the given target StringValue. The substring begins at the given start index and ends at end - 1.
        Parameters:
        target - The StringValue object to copy the substring to.
        start - The beginning index, inclusive.
        end - The ending index, exclusive.
        Throws:
        IndexOutOfBoundsException - Thrown, if the start is negative, or the end is larger than the length.
      • find

        public int find​(CharSequence str)
        Finds any occurrence of the str character sequence in this StringValue.
        Returns:
        The position of the first occurrence of the search string in the string value, or -1, if the character sequence was not found.
      • find

        public int find​(CharSequence str,
                        int start)
        Finds any occurrence of the str character sequence in this StringValue. The search starts at position start.
        Returns:
        The position of the first occurrence of the search string in the string value, or -1, if the character sequence was not found.
      • startsWith

        public boolean startsWith​(CharSequence prefix,
                                  int startIndex)
        Checks whether the substring, starting at the specified index, starts with the given prefix string.
        Parameters:
        prefix - The prefix character sequence.
        startIndex - The position to start checking for the prefix.
        Returns:
        True, if this StringValue substring, starting at position startIndex has prefix as its prefix.
      • startsWith

        public boolean startsWith​(CharSequence prefix)
        Checks whether this StringValue starts with the given prefix string.
        Parameters:
        prefix - The prefix character sequence.
        Returns:
        True, if this StringValue has prefix as its prefix.
      • read

        public void read​(DataInputView in)
                  throws IOException
        Description copied from interface: IOReadableWritable
        Reads the object's internal data from the given data input view.
        Specified by:
        read in interface IOReadableWritable
        Parameters:
        in - the input view to read the data from
        Throws:
        IOException - thrown if any error occurs while reading from the input stream
      • hashCode

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

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

        public int getMaxNormalizedKeyLen()
        Description copied from interface: NormalizableKey
        Gets the maximal length of normalized keys that the data type would produce to determine the order of instances solely by the normalized key. A value of Integer.MAX_VALUE is interpreted as infinite.

        For example, 32 bit integers return four, while Strings (potentially unlimited in length) return Integer.MAX_VALUE.

        Specified by:
        getMaxNormalizedKeyLen in interface NormalizableKey<StringValue>
        Returns:
        The maximal length of normalized keys.
      • copyNormalizedKey

        public void copyNormalizedKey​(MemorySegment target,
                                      int offset,
                                      int len)
        Description copied from interface: NormalizableKey
        Writes a normalized key for the given record into the target byte array, starting at the specified position an writing exactly the given number of bytes. Note that the comparison of the bytes is treating the bytes as unsigned bytes: int byteI = bytes[i] & 0xFF;

        If the meaningful part of the normalized key takes less than the given number of bytes, then it must be padded. Padding is typically required for variable length data types, such as strings. The padding uses a special character, either 0 or 0xff, depending on whether shorter values are sorted to the beginning or the end.

        Specified by:
        copyNormalizedKey in interface NormalizableKey<StringValue>
        Parameters:
        target - The memory segment to put the normalized key bytes into.
        offset - The offset in the byte array where the normalized key's bytes should start.
        len - The number of bytes to put.
      • getBinaryLength

        public int getBinaryLength()
        Description copied from interface: CopyableValue
        Gets the length of the data type when it is serialized, in bytes.
        Specified by:
        getBinaryLength in interface CopyableValue<StringValue>
        Returns:
        The length of the data type, or -1, if variable length.
      • copyTo

        public void copyTo​(StringValue target)
        Description copied from interface: CopyableValue
        Performs a deep copy of this object into the target instance.
        Specified by:
        copyTo in interface CopyableValue<StringValue>
        Parameters:
        target - Object to copy into.
      • copy

        public StringValue copy()
        Description copied from interface: CopyableValue
        Performs a deep copy of this object into a new instance.

        This method is useful for generic user-defined functions to clone a CopyableValue when storing multiple objects. With object reuse a deep copy must be created and type erasure prevents calling new.

        Specified by:
        copy in interface CopyableValue<StringValue>
        Returns:
        New object with copied fields.
      • copy

        public void copy​(DataInputView in,
                         DataOutputView target)
                  throws IOException
        Description copied from interface: CopyableValue
        Copies the next serialized instance from source to target.

        This method is equivalent to calling IOReadableWritable.read(DataInputView) followed by IOReadableWritable.write(DataOutputView) but does not require intermediate deserialization.

        Specified by:
        copy in interface CopyableValue<StringValue>
        Parameters:
        in - Data source for serialized instance.
        target - Data target for serialized instance.
        Throws:
        IOException
        See Also:
        IOReadableWritable