Class OneOfType
- java.lang.Object
-
- org.apache.beam.sdk.schemas.logicaltypes.OneOfType
-
- All Implemented Interfaces:
java.io.Serializable
,Schema.LogicalType<OneOfType.Value,Row>
@Experimental(SCHEMAS) public class OneOfType extends java.lang.Object implements Schema.LogicalType<OneOfType.Value,Row>
A logical type representing a union of fields. This logical type is initialized with a set of field and represents a union of those fields. This logical type is backed by a Row object containing one nullable field matching each input field, and one additionalEnumerationType
logical type field that indicates which field is set.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OneOfType.Value
Represents a single OneOf value.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
IDENTIFIER
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OneOfType
create(java.util.List<Schema.Field> fields)
Create anOneOfType
logical type.static OneOfType
create(java.util.List<Schema.Field> fields, java.util.Map<java.lang.String,java.lang.Integer> enumValues)
Create anOneOfType
logical type.static OneOfType
create(Schema.Field... fields)
Create anOneOfType
logical type.<T> OneOfType.Value
createValue(int caseValue, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.<T> OneOfType.Value
createValue(java.lang.String caseValue, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.<T> OneOfType.Value
createValue(EnumerationType.Value caseType, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.byte[]
getArgument()
An optional argument to configure the type.Schema.FieldType
getArgumentType()
A schema type representing how to interpret the argument.Schema.FieldType
getBaseType()
The baseSchema.FieldType
used to store values of this type.EnumerationType
getCaseEnumType()
Returns theEnumerationType
that is used to represent the case type.Schema.FieldType
getFieldType(OneOfType.Value oneOneValue)
java.lang.String
getIdentifier()
The unique identifier for this type.Schema
getOneOfSchema()
Returns the schema of the underlyingRow
that is used to represent the union.Row
toBaseType(OneOfType.Value input)
Convert the input type to the type Java type used by the baseSchema.FieldType
.OneOfType.Value
toInputType(Row base)
Convert the Java type used by the baseSchema.FieldType
to the input type.java.lang.String
toString()
-
-
-
Field Detail
-
IDENTIFIER
public static final java.lang.String IDENTIFIER
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static OneOfType create(Schema.Field... fields)
Create anOneOfType
logical type.
-
create
public static OneOfType create(java.util.List<Schema.Field> fields)
Create anOneOfType
logical type.
-
create
public static OneOfType create(java.util.List<Schema.Field> fields, java.util.Map<java.lang.String,java.lang.Integer> enumValues)
Create anOneOfType
logical type. This method allows control over the integer values in the generated enum.
-
getOneOfSchema
public Schema getOneOfSchema()
Returns the schema of the underlyingRow
that is used to represent the union.
-
getCaseEnumType
public EnumerationType getCaseEnumType()
Returns theEnumerationType
that is used to represent the case type.
-
getIdentifier
public java.lang.String getIdentifier()
Description copied from interface:Schema.LogicalType
The unique identifier for this type.- Specified by:
getIdentifier
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
getArgumentType
public Schema.FieldType getArgumentType()
Description copied from interface:Schema.LogicalType
A schema type representing how to interpret the argument.null
indicates this logical type is not parameterized by an argument.- Specified by:
getArgumentType
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
getArgument
public byte[] getArgument()
Description copied from interface:Schema.LogicalType
An optional argument to configure the type.- Specified by:
getArgument
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
getBaseType
public Schema.FieldType getBaseType()
Description copied from interface:Schema.LogicalType
The baseSchema.FieldType
used to store values of this type.- Specified by:
getBaseType
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
createValue
public <T> OneOfType.Value createValue(java.lang.String caseValue, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.
-
createValue
public <T> OneOfType.Value createValue(int caseValue, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.
-
createValue
public <T> OneOfType.Value createValue(EnumerationType.Value caseType, T value)
Create aOneOfType.Value
specifying which field to set and the value to set.
-
getFieldType
public Schema.FieldType getFieldType(OneOfType.Value oneOneValue)
-
toBaseType
public Row toBaseType(OneOfType.Value input)
Description copied from interface:Schema.LogicalType
Convert the input type to the type Java type used by the baseSchema.FieldType
.- Specified by:
toBaseType
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
toInputType
public OneOfType.Value toInputType(Row base)
Description copied from interface:Schema.LogicalType
Convert the Java type used by the baseSchema.FieldType
to the input type.- Specified by:
toInputType
in interfaceSchema.LogicalType<OneOfType.Value,Row>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-