public class Schema
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Schema.Builder
Builder class for building
Schema 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 and Description |
---|
Schema(java.util.List<Schema.Field> fields) |
Schema(java.util.List<Schema.Field> fields,
Schema.Options options) |
Modifier and Type | Method and 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 if
fieldName 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 of
Schema.Field s into a Schema . |
java.lang.String |
toString() |
boolean |
typesEqual(Schema other)
Returns true if two schemas are equal ignoring field names and descriptions.
|
Schema |
withOptions(Schema.Options.Builder optionsBuilder)
Returns a copy of the Schema with the options set.
|
Schema |
withOptions(Schema.Options options)
Returns a copy of the Schema with the options set.
|
public Schema(java.util.List<Schema.Field> fields)
public Schema(java.util.List<Schema.Field> fields, Schema.Options options)
public static Schema.Builder builder()
public static Schema of(Schema.Field... fields)
public Schema sorted()
public Schema withOptions(Schema.Options options)
public Schema withOptions(Schema.Options.Builder optionsBuilder)
public void setUUID(java.util.UUID uuid)
public java.util.Map<java.lang.String,java.lang.Integer> getEncodingPositions()
public boolean isEncodingPositionsOverridden()
public void setEncodingPositions(java.util.Map<java.lang.String,java.lang.Integer> encodingPositions)
public @Nullable java.util.UUID getUUID()
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
public boolean typesEqual(Schema other)
public boolean equivalent(Schema other)
public boolean assignableTo(Schema other)
public boolean assignableToIgnoreNullable(Schema other)
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.List<Schema.Field> getFields()
public static java.util.stream.Collector<Schema.Field,java.util.List<Schema.Field>,Schema> toSchema()
Schema.Field
s into a Schema
.public java.util.List<java.lang.String> getFieldNames()
public Schema.Field getField(int index)
public Schema.Field getField(java.lang.String name)
public int indexOf(java.lang.String fieldName)
public boolean hasField(java.lang.String fieldName)
fieldName
exists in the schema, false otherwise.public java.lang.String nameOf(int fieldIndex)
public int getFieldCount()
public Schema.Options getOptions()