Package org.apache.beam.sdk.schemas
Class Schema
- java.lang.Object
-
- org.apache.beam.sdk.schemas.Schema
-
- All Implemented Interfaces:
java.io.Serializable
@Experimental(SCHEMAS) public class Schema extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Schema.Builder
Builder class for buildingSchema
objects.static class
Schema.EquivalenceNullablePolicy
Control whether nullable is included in equivalence check.static class
Schema.Field
Field of a row.static class
Schema.FieldType
A descriptor of a single field type.static interface
Schema.LogicalType<InputT,BaseT>
A LogicalType allows users to define a custom schema type.static class
Schema.Options
static class
Schema.TypeName
An enumerated list of type constructors.
-
Constructor Summary
Constructors Constructor Description Schema(java.util.List<Schema.Field> fields)
Schema(java.util.List<Schema.Field> fields, Schema.Options options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
assignableTo(Schema other)
Returns true if this Schema can be assigned to another Schema.boolean
assignableToIgnoreNullable(Schema other)
Returns true if this Schema can be assigned to another Schema, ignoring nullable.static Schema.Builder
builder()
boolean
equals(@Nullable java.lang.Object o)
Returns true if two Schemas have the same fields in the same order.boolean
equivalent(Schema other)
Returns true if two Schemas have the same fields, but possibly in different orders.java.util.Map<java.lang.String,java.lang.Integer>
getEncodingPositions()
Gets the encoding positions for this schema.Schema.Field
getField(int index)
Return a field by index.Schema.Field
getField(java.lang.String name)
int
getFieldCount()
Return the count of fields.java.util.List<java.lang.String>
getFieldNames()
Return the list of all field names.java.util.List<Schema.Field>
getFields()
Schema.Options
getOptions()
@Nullable java.util.UUID
getUUID()
Get this schema's UUID.boolean
hasField(java.lang.String fieldName)
Returns true iffieldName
exists in the schema, false otherwise.int
hashCode()
int
indexOf(java.lang.String fieldName)
Find the index of a given field.boolean
isEncodingPositionsOverridden()
Returns whether encoding positions have been explicitly overridden.java.lang.String
nameOf(int fieldIndex)
Return the name of field by index.static Schema
of(Schema.Field... fields)
void
setEncodingPositions(java.util.Map<java.lang.String,java.lang.Integer> encodingPositions)
Sets the encoding positions for this schema.void
setUUID(java.util.UUID uuid)
Set this schema's UUID.Schema
sorted()
Returns an identical Schema with sorted fields.static java.util.stream.Collector<Schema.Field,java.util.List<Schema.Field>,Schema>
toSchema()
Collects a stream ofSchema.Field
s into aSchema
.java.lang.String
toString()
boolean
typesEqual(Schema other)
Returns true if two schemas are equal ignoring field names and descriptions.Schema
withOptions(Schema.Options options)
Returns a copy of the Schema with the options set.Schema
withOptions(Schema.Options.Builder optionsBuilder)
Returns a copy of the Schema with the options set.
-
-
-
Constructor Detail
-
Schema
public Schema(java.util.List<Schema.Field> fields)
-
Schema
public Schema(java.util.List<Schema.Field> fields, Schema.Options options)
-
-
Method Detail
-
builder
public static Schema.Builder builder()
-
of
public static Schema of(Schema.Field... fields)
-
sorted
public Schema sorted()
Returns an identical Schema with sorted fields.
-
withOptions
public Schema withOptions(Schema.Options options)
Returns a copy of the Schema with the options set.
-
withOptions
public Schema withOptions(Schema.Options.Builder optionsBuilder)
Returns a copy of the Schema with the options set.
-
setUUID
public void setUUID(java.util.UUID uuid)
Set this schema's UUID. All schemas with the same UUID must be guaranteed to be identical.
-
getEncodingPositions
public java.util.Map<java.lang.String,java.lang.Integer> getEncodingPositions()
Gets the encoding positions for this schema.
-
isEncodingPositionsOverridden
public boolean isEncodingPositionsOverridden()
Returns whether encoding positions have been explicitly overridden.
-
setEncodingPositions
public void setEncodingPositions(java.util.Map<java.lang.String,java.lang.Integer> encodingPositions)
Sets the encoding positions for this schema.
-
getUUID
public @Nullable java.util.UUID getUUID()
Get this schema's UUID.
-
equals
public boolean equals(@Nullable java.lang.Object o)
Returns true if two Schemas have the same fields in the same order.- Overrides:
equals
in classjava.lang.Object
-
typesEqual
public boolean typesEqual(Schema other)
Returns true if two schemas are equal ignoring field names and descriptions.
-
equivalent
public boolean equivalent(Schema other)
Returns true if two Schemas have the same fields, but possibly in different orders.
-
assignableTo
public boolean assignableTo(Schema other)
Returns true if this Schema can be assigned to another Schema. *
-
assignableToIgnoreNullable
public boolean assignableToIgnoreNullable(Schema other)
Returns true if this Schema can be assigned to another Schema, ignoring nullable. *
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getFields
public java.util.List<Schema.Field> getFields()
-
toSchema
public static java.util.stream.Collector<Schema.Field,java.util.List<Schema.Field>,Schema> toSchema()
Collects a stream ofSchema.Field
s into aSchema
.
-
getFieldNames
public java.util.List<java.lang.String> getFieldNames()
Return the list of all field names.
-
getField
public Schema.Field getField(int index)
Return a field by index.
-
getField
public Schema.Field getField(java.lang.String name)
-
indexOf
public int indexOf(java.lang.String fieldName)
Find the index of a given field.
-
hasField
public boolean hasField(java.lang.String fieldName)
Returns true iffieldName
exists in the schema, false otherwise.
-
nameOf
public java.lang.String nameOf(int fieldIndex)
Return the name of field by index.
-
getFieldCount
public int getFieldCount()
Return the count of fields.
-
getOptions
public Schema.Options getOptions()
-
-