@PublicEvolving public final class VarBinaryType extends LogicalType
The serialized string representation is VARBINARY(n)
where n
is the maximum
number of bytes. n
must have a value between 1 and Integer.MAX_VALUE
(both
inclusive). If no length is specified, n
is equal to 1. BYTES
is a synonym for
VARBINARY(2147483647)
.
For enabling type inference of a zero-length binary string literal to a variable-length binary
string, this type does also support n
to be 0. However, this is not exposed through the
API.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LENGTH |
static int |
EMPTY_LITERAL_LENGTH |
static int |
MAX_LENGTH |
static int |
MIN_LENGTH |
Constructor and Description |
---|
VarBinaryType() |
VarBinaryType(boolean isNullable,
int length) |
VarBinaryType(int length) |
Modifier and Type | Method and Description |
---|---|
<R> R |
accept(LogicalTypeVisitor<R> visitor) |
String |
asSerializableString()
Returns a string that fully serializes this instance.
|
String |
asSummaryString()
Returns a string that summarizes this type for printing to a console.
|
LogicalType |
copy(boolean isNullable)
Returns a deep copy of this type with possibly different nullability.
|
boolean |
equals(Object o) |
List<LogicalType> |
getChildren() |
Class<?> |
getDefaultConversion()
Returns the default conversion class.
|
int |
getLength() |
int |
hashCode() |
static VarBinaryType |
ofEmptyLiteral()
The SQL standard defines that character string literals are allowed to be zero-length strings
(i.e., to contain no characters) even though it is not permitted to declare a type that is
zero.
|
boolean |
supportsInputConversion(Class<?> clazz)
Returns whether an instance of the given class can be represented as a value of this logical
type when entering the table ecosystem.
|
boolean |
supportsOutputConversion(Class<?> clazz)
Returns whether a value of this logical type can be represented as an instance of the given
class when leaving the table ecosystem.
|
conversionSet, copy, getTypeRoot, is, is, isAnyOf, isAnyOf, isNullable, toString, withNullability
public static final int EMPTY_LITERAL_LENGTH
public static final int MIN_LENGTH
public static final int MAX_LENGTH
public static final int DEFAULT_LENGTH
public VarBinaryType(boolean isNullable, int length)
public VarBinaryType(int length)
public VarBinaryType()
public static VarBinaryType ofEmptyLiteral()
This method enables this special kind of binary string.
Zero-length binary strings have no serializable string representation.
public int getLength()
public LogicalType copy(boolean isNullable)
LogicalType
copy
in class LogicalType
isNullable
- the intended nullability of the copied typepublic String asSerializableString()
LogicalType
See LogicalTypeParser
for the reverse operation.
asSerializableString
in class LogicalType
public String asSummaryString()
LogicalType
Use LogicalType.asSerializableString()
for a type string that fully serializes this instance.
asSummaryString
in class LogicalType
public boolean supportsInputConversion(Class<?> clazz)
LogicalType
A supported conversion directly maps an input class to a logical type without loss of precision or type widening.
For example, java.lang.Long
or long
can be used as input for BIGINT
independent of the set nullability.
supportsInputConversion
in class LogicalType
clazz
- input class to be converted into this logical typeLogicalType.getDefaultConversion()
public boolean supportsOutputConversion(Class<?> clazz)
LogicalType
A supported conversion directly maps a logical type to an output class without loss of precision or type widening.
For example, java.lang.Long
or long
can be used as output for BIGINT
if the type is not nullable. If the type is nullable, only java.lang.Long
can
represent this.
supportsOutputConversion
in class LogicalType
clazz
- output class to be converted from this logical typeLogicalType.getDefaultConversion()
public Class<?> getDefaultConversion()
LogicalType
For example, java.lang.Long
is the default input and output for BIGINT
.
getDefaultConversion
in class LogicalType
LogicalType.supportsInputConversion(Class)
,
LogicalType.supportsOutputConversion(Class)
public List<LogicalType> getChildren()
getChildren
in class LogicalType
public <R> R accept(LogicalTypeVisitor<R> visitor)
accept
in class LogicalType
public boolean equals(Object o)
equals
in class LogicalType
public int hashCode()
hashCode
in class LogicalType
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.