InputT
- The Java type used to set the type when using Row.Builder#addValue
.BaseT
- The Java type for the underlying storage.public static interface Schema.LogicalType<InputT,BaseT>
extends java.io.Serializable
A LogicalType is a way to define a new type that can be stored in a schema field using an
underlying FieldType as storage. A LogicalType must specify a base FieldType used to store the
data by overriding the getBaseType()
method. Usually the FieldType returned will be
one of the standard ones implemented by Schema. It is legal to return another LogicalType, but
the storage types must eventually resolve to one of the standard Schema types; it is not
allowed to have LogicalTypes reference each other recursively via getBaseType. The toBaseType(InputT)
and toInputType(BaseT)
should convert back and forth between the Java type for
the LogicalType (InputT) and the Java type appropriate for the underlying base type (BaseT).
getIdentifier()
must define a globally unique identifier for this LogicalType. A
LogicalType can optionally provide an identifying argument as well using getArgument()
.
An example is a LogicalType that represents a fixed-size byte array. The identifier
"FixedBytes" uniquely identifies this LogicalType (or specifically, this class of
LogicalTypes), while the argument returned will be the length of the fixed-size byte array. The
combination of getIdentifier()
and getArgument()
must completely identify a
LogicalType.
A LogicalType can be added to a schema using Schema.Builder.addLogicalTypeField(java.lang.String, org.apache.beam.sdk.schemas.Schema.LogicalType<InputT, BaseT>)
.
Modifier and Type | Method and Description |
---|---|
default <T> T |
getArgument()
An optional argument to configure the type.
|
Schema.FieldType |
getArgumentType()
A schema type representing how to interpret the argument.
|
Schema.FieldType |
getBaseType()
The base
Schema.FieldType used to store values of this type. |
java.lang.String |
getIdentifier()
The unique identifier for this type.
|
BaseT |
toBaseType(InputT input) |
InputT |
toInputType(BaseT base)
Convert the Java type used by the base
Schema.FieldType to the input type. |
java.lang.String getIdentifier()
Schema.FieldType getArgumentType()
default <T> T getArgument()
Schema.FieldType getBaseType()
Schema.FieldType
used to store values of this type.InputT toInputType(BaseT base)
Schema.FieldType
to the input type.