public interface Schema
Definition of an abstract data type. Data types can be primitive types (integer types, floating point types, boolean, strings, and bytes) or complex types (typed arrays, maps with one key schema and value schema, and structs that have a fixed set of field names each with an associated value schema). Any type can be specified as optional, allowing it to be omitted (resulting in null values when it is missing) and can specify a default value.
All schemas may have some associated metadata: a name, version, and documentation. These are all considered part of the schema itself and included when comparing schemas. Besides adding important metadata, these fields enable the specification of logical types that specify additional constraints and semantics (e.g. UNIX timestamps are just an int64, but the user needs the know about the additional semantics to interpret it properly).
Schemas can be created directly, but in most cases using SchemaBuilder
will be simpler.
Modifier and Type | Interface and Description |
---|---|
static class |
Schema.Type
The type of a schema.
|
Modifier and Type | Field and Description |
---|---|
static Schema |
BOOLEAN_SCHEMA |
static Schema |
BYTES_SCHEMA |
static Schema |
FLOAT32_SCHEMA |
static Schema |
FLOAT64_SCHEMA |
static Schema |
INT16_SCHEMA |
static Schema |
INT32_SCHEMA |
static Schema |
INT64_SCHEMA |
static Schema |
INT8_SCHEMA |
static Schema |
OPTIONAL_BOOLEAN_SCHEMA |
static Schema |
OPTIONAL_BYTES_SCHEMA |
static Schema |
OPTIONAL_FLOAT32_SCHEMA |
static Schema |
OPTIONAL_FLOAT64_SCHEMA |
static Schema |
OPTIONAL_INT16_SCHEMA |
static Schema |
OPTIONAL_INT32_SCHEMA |
static Schema |
OPTIONAL_INT64_SCHEMA |
static Schema |
OPTIONAL_INT8_SCHEMA |
static Schema |
OPTIONAL_STRING_SCHEMA |
static Schema |
STRING_SCHEMA |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
defaultValue() |
java.lang.String |
doc() |
Field |
field(java.lang.String fieldName)
Get a field for this Schema by name.
|
java.util.List<Field> |
fields()
Get the list of fields for this Schema.
|
boolean |
isOptional() |
Schema |
keySchema()
Get the key schema for this map schema.
|
java.lang.String |
name() |
java.util.Map<java.lang.String,java.lang.String> |
parameters()
Get a map of schema parameters.
|
Schema |
schema()
Return a concrete instance of the
Schema |
Schema.Type |
type() |
Schema |
valueSchema()
Get the value schema for this map or array schema.
|
java.lang.Integer |
version()
Get the optional version of the schema.
|
static final Schema INT8_SCHEMA
static final Schema INT16_SCHEMA
static final Schema INT32_SCHEMA
static final Schema INT64_SCHEMA
static final Schema FLOAT32_SCHEMA
static final Schema FLOAT64_SCHEMA
static final Schema BOOLEAN_SCHEMA
static final Schema STRING_SCHEMA
static final Schema BYTES_SCHEMA
static final Schema OPTIONAL_INT8_SCHEMA
static final Schema OPTIONAL_INT16_SCHEMA
static final Schema OPTIONAL_INT32_SCHEMA
static final Schema OPTIONAL_INT64_SCHEMA
static final Schema OPTIONAL_FLOAT32_SCHEMA
static final Schema OPTIONAL_FLOAT64_SCHEMA
static final Schema OPTIONAL_BOOLEAN_SCHEMA
static final Schema OPTIONAL_STRING_SCHEMA
static final Schema OPTIONAL_BYTES_SCHEMA
Schema.Type type()
boolean isOptional()
java.lang.Object defaultValue()
java.lang.String name()
java.lang.Integer version()
java.lang.String doc()
java.util.Map<java.lang.String,java.lang.String> parameters()
Schema keySchema()
Schema valueSchema()
java.util.List<Field> fields()
Field field(java.lang.String fieldName)
fieldName
- the name of the field to look up