@TypeInfo(value=BinaryStringTypeInfoFactory.class) public final class BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString>
MemorySegment
instead of String. Its data may span
multiple MemorySegment
s.
Used for internal table-level implementation. The built-in operator will use it for comparison, search, and so on.
BinaryString
are influenced by Apache Spark UTF8String.
Modifier and Type | Field and Description |
---|---|
static BinaryString |
EMPTY_UTF8 |
HIGHEST_FIRST_BIT, HIGHEST_SECOND_TO_EIGHTH_BIT, MAX_FIX_PART_DATA_SIZE
Constructor and Description |
---|
BinaryString() |
Modifier and Type | Method and Description |
---|---|
static BinaryString |
blankString(int length)
Creates an BinaryString that contains `length` spaces.
|
byte |
byteAt(int index)
Returns the
byte value at the specified index. |
int |
compareTo(BinaryString other)
Compares two strings lexicographically.
|
boolean |
contains(BinaryString s)
Returns true if and only if this BinaryString contains the specified
sequence of bytes values.
|
BinaryString |
copy()
Copy a new
BinaryString . |
boolean |
endsWith(BinaryString suffix)
Tests if this BinaryString ends with the specified suffix.
|
void |
ensureMaterialized() |
boolean |
equals(Object o) |
static BinaryString |
fromAddress(MemorySegment[] segments,
int offset,
int numBytes)
Creates an BinaryString from given address (base and offset) and length.
|
static BinaryString |
fromBytes(byte[] bytes)
Creates an BinaryString from given UTF-8 bytes.
|
static BinaryString |
fromBytes(byte[] bytes,
int offset,
int numBytes)
Creates an BinaryString from given UTF-8 bytes with offset and number of bytes.
|
static BinaryString |
fromString(String str)
Creates an BinaryString from given java String.
|
byte[] |
getBytes()
Get the underlying UTF-8 byte array, the returned bytes may be reused.
|
int |
getOffset() |
MemorySegment[] |
getSegments() |
int |
getSizeInBytes() |
int |
hashCode() |
int |
indexOf(BinaryString str,
int fromIndex)
Returns the index within this string of the first occurrence of the
specified substring, starting at the specified index.
|
protected BinarySection |
materialize(TypeSerializer<String> serializer)
Materialize java object to binary format.
|
int |
numChars()
Returns the number of UTF-8 code points in the string.
|
boolean |
startsWith(BinaryString prefix)
Tests if this BinaryString starts with the specified prefix.
|
BinaryString |
substring(int beginIndex,
int endIndex)
Returns a binary string that is a substring of this binary string.
|
BinaryString |
toLowerCase()
Converts all of the characters in this
BinaryString to lower case. |
String |
toString() |
BinaryString |
toUpperCase()
Converts all of the characters in this
BinaryString to upper case. |
BinaryString |
trim()
Returns a string whose value is this string, with any leading and trailing
whitespace removed.
|
ensureMaterialized, getJavaObject, setJavaObject
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
readBinaryFieldFromSegments, readBinaryStringFieldFromSegments
public static final BinaryString EMPTY_UTF8
public static BinaryString fromAddress(MemorySegment[] segments, int offset, int numBytes)
public static BinaryString fromString(String str)
public static BinaryString fromBytes(byte[] bytes)
public static BinaryString fromBytes(byte[] bytes, int offset, int numBytes)
public static BinaryString blankString(int length)
public int numChars()
public byte byteAt(int index)
byte
value at the specified index. An index ranges from 0
to
binarySection.sizeInBytes - 1
.index
- the index of the byte
value.byte
value at the specified index of this UTF-8 bytes.IndexOutOfBoundsException
- if the index
argument is negative or not less than the length of this
UTF-8 bytes.public byte[] getBytes()
public MemorySegment[] getSegments()
getSegments
in interface BinaryFormat
getSegments
in class LazyBinaryFormat<String>
public int getOffset()
getOffset
in interface BinaryFormat
getOffset
in class LazyBinaryFormat<String>
public int getSizeInBytes()
getSizeInBytes
in interface BinaryFormat
getSizeInBytes
in class LazyBinaryFormat<String>
public void ensureMaterialized()
protected BinarySection materialize(TypeSerializer<String> serializer)
LazyBinaryFormat
materialize
in class LazyBinaryFormat<String>
public BinaryString copy()
BinaryString
.public int compareTo(@Nonnull BinaryString other)
compareTo
in interface Comparable<BinaryString>
public BinaryString substring(int beginIndex, int endIndex)
beginIndex
and extends to the character at index endIndex - 1
.
Examples:
fromString("hamburger").substring(4, 8) returns binary string "urge" fromString("smiles").substring(1, 5) returns binary string "mile"
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.public boolean contains(BinaryString s)
s
- the sequence to search fors
, false otherwisepublic boolean startsWith(BinaryString prefix)
prefix
- the prefix.true
if the bytes represented by the argument is a prefix of the bytes
represented by this string; false
otherwise. Note also that true
will be returned if the argument is an empty BinaryString or is equal to this
BinaryString
object as determined by the equals(Object)
method.public boolean endsWith(BinaryString suffix)
suffix
- the suffix.true
if the bytes represented by the argument is a suffix of the bytes
represented by this object; false
otherwise. Note that the result will
be true
if the argument is the empty string or is equal to this
BinaryString
object as determined by the equals(Object)
method.public BinaryString trim()
public int indexOf(BinaryString str, int fromIndex)
str
- the substring to search for.fromIndex
- the index from which to start the search.-1
if there is no such occurrence.public BinaryString toUpperCase()
BinaryString
to upper case.BinaryString
, converted to uppercase.public BinaryString toLowerCase()
BinaryString
to lower case.BinaryString
, converted to lowercase.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.