Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data ReadSchema
- = Null
- | Boolean
- | Int { }
- | Long { }
- | Float { }
- | Double { }
- | Bytes { }
- | String { }
- | Array {
- item :: ReadSchema
- | Map {
- values :: ReadSchema
- | NamedType TypeName
- | Record { }
- | Enum { }
- | Union {
- options :: Vector (Int, ReadSchema)
- | Fixed {
- name :: TypeName
- aliases :: [TypeName]
- size :: Int
- logicalTypeF :: Maybe LogicalTypeFixed
- | FreeUnion {
- pos :: Int
- ty :: ReadSchema
- data ReadField = ReadField {
- fldName :: Text
- fldAliases :: [Text]
- fldDoc :: Maybe Text
- fldOrder :: Maybe Order
- fldStatus :: FieldStatus
- fldType :: ReadSchema
- fldDefault :: Maybe DefaultValue
- data ReadLong
- data ReadFloat
- data ReadDouble
- fromSchema :: Schema -> ReadSchema
- fromField :: FieldStatus -> Field -> ReadField
- extractBindings :: ReadSchema -> HashMap TypeName ReadSchema
- data Decimal = Decimal {}
- newtype LogicalTypeBytes = DecimalB Decimal
- data LogicalTypeFixed
- data LogicalTypeInt
- data LogicalTypeLong
- data LogicalTypeString = UUID
- data FieldStatus
Documentation
data ReadSchema Source #
This type represents a deconflicted version of a Schema
.
Schema resolution is described in Avro specification: https://avro.apache.org/docs/current/spec.html#Schema+Resolution
This library represents "normal" schema and "deconflicted" schema as different types to avoid confusion between these two usecases (we shouldn't serialise values with such schema) and to be able to accomodate some extra information that links between how data is supposed transformed between what reader wants and what writer has.
Null | |
Boolean | |
Int | |
Long | |
Float | |
Double | |
Bytes | |
String | |
Array | |
| |
Map | |
| |
NamedType TypeName | |
Record | |
Enum | |
Union | |
| |
Fixed | |
| |
FreeUnion | |
|
Instances
Deconflicted record field.
ReadField | |
|
Instances
How to decode a value of target type Long
.
This type controls how many bits are needed to be read from the encoded bytestring.
The number of bits can be different depending on differences between reader and writer schemas.
The rules are described in https://avro.apache.org/docs/current/spec.html#Schema+Resolution
LongFromInt | Read |
ReadLong | Read |
How to decode a value of target type Float
.
This type controls how many bits are needed to be read from the encoded bytestring.
The number of bits can be different depending on differences between reader and writer schemas.
The rules are described in https://avro.apache.org/docs/current/spec.html#Schema+Resolution
FloatFromInt | Read |
FloatFromLong | Read |
ReadFloat | Read |
Instances
Generic ReadFloat Source # | |
Show ReadFloat Source # | |
NFData ReadFloat Source # | |
Defined in Data.Avro.Schema.ReadSchema | |
Eq ReadFloat Source # | |
Ord ReadFloat Source # | |
Defined in Data.Avro.Schema.ReadSchema | |
type Rep ReadFloat Source # | |
Defined in Data.Avro.Schema.ReadSchema type Rep ReadFloat = D1 ('MetaData "ReadFloat" "Data.Avro.Schema.ReadSchema" "avro-0.6.2.1-A0QG4Nfzciz1CCj51QVwFU" 'False) (C1 ('MetaCons "FloatFromInt" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FloatFromLong" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ReadFloat" 'PrefixI 'False) (U1 :: Type -> Type))) |
data ReadDouble Source #
How to decode a value of target type Double
.
This type controls how many bits are needed to be read from the encoded bytestring.
The number of bits can be different depending on differences between reader and writer schemas.
The rules are described in https://avro.apache.org/docs/current/spec.html#Schema+Resolution
DoubleFromInt | Read |
DoubleFromFloat | Read |
DoubleFromLong | Read |
ReadDouble |
Instances
fromSchema :: Schema -> ReadSchema Source #
Converts Avro Schema to ReaderSchema trivially. This function is useful when no deconflicting is required.
extractBindings :: ReadSchema -> HashMap TypeName ReadSchema Source #
extractBindings schema
traverses a schema and builds a map of all declared
types.
Types declared implicitly in record field definitions are also included. No distinction is made between aliases and normal names.
The decimal
logical type represents arbitrary-precision decimal
numbers. Numbers are represented as unscaled * (10 ** -scale)
where scale
is part of the logical type and unscaled
is an
integer represented by the underlying primitive type.
Instances of the decimal
logical type need to specify a scale
and precision
.
decimal
can be encoded as one of several different primitive
types:
bytes
fixed
long
int
For long
and int
, unscaled
is the underlying number.
For bytes
and fixed
, unscaled
is represented as a
two's-complement signed integer in big-endian byte order.
Note: int
and long
representations for decimal
are not part
of the current Avro
specification,
but they are supported by some language implementations including
the official Java library. Implementations that do not support this
should ignore the logical type and use the underlying primitive
type instead.
Instances
Generic Decimal Source # | |
Show Decimal Source # | |
NFData Decimal Source # | |
Defined in Data.Avro.Schema.Schema | |
Eq Decimal Source # | |
Ord Decimal Source # | |
Lift Decimal Source # | |
type Rep Decimal Source # | |
Defined in Data.Avro.Schema.Schema type Rep Decimal = D1 ('MetaData "Decimal" "Data.Avro.Schema.Schema" "avro-0.6.2.1-A0QG4Nfzciz1CCj51QVwFU" 'False) (C1 ('MetaCons "Decimal" 'PrefixI 'True) (S1 ('MetaSel ('Just "precision") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Integer) :*: S1 ('MetaSel ('Just "scale") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Integer))) |
newtype LogicalTypeBytes Source #
Instances
data LogicalTypeFixed Source #
DecimalF Decimal | An arbitrary-precision signed decimal number. See |
Duration | An interval of time, represented as some number of months, days and milliseconds. Encoded as three little-endian unsigned integers for months, days and milliseconds respectively. |
Instances
data LogicalTypeInt Source #
DecimalI Decimal | An arbitrary-precision signed decimal number. See |
Date | A date (eg Encoded as the number of days before/after the Unix epoch (1970-01-01). |
TimeMillis | A time of day with millisecond precision. Encoded as the number of milliseconds after midnight. |
Instances
data LogicalTypeLong Source #
DecimalL Decimal | An arbitrary-precision signed decimal number. See |
TimeMicros | A time of day with microsecond precision. Encoded as the number of microseconds after midnight. |
TimestampMillis | A UTC timestamp with millisecond precision. Encoded as the number of milliseconds before/after the Unix epoch (1970-01-01 00:00:00.000). |
TimestampMicros | A UTC timestamp with microsecond precision. Encoded as the number of microseconds before/after the Unix epoch (1970-01-01 00:00:00.000000). |
LocalTimestampMillis | A timestamp in the local timezone, whatever that happens to be, with millisecond precision. Encoded as the number of milliseconds before/after the Unix epoch (1970-01-01 00:00:00.000). |
LocalTimestampMicros | A timestamp in the local timezone, whatever that happens to be, with microsecond precision. Encoded as the number of microseconds before/after the Unix epoch (1970-01-01 00:00:00.000000). |
Instances
data LogicalTypeString Source #
Instances
data FieldStatus Source #
Depending on differences between reader and writer schemas, a record field can be found:
- Present in the reader schema but missing from the writer schema.
In this case the reader field is marked as
Defaulted
with the default value from the reader schema. An index value represents the position of the field in the reader schema. - Present in the writer schema but missing from the reader schema.
In this case the record field is marked as
Ignored
: the corresponding bytes still need to be read from the payload (to advance the position in a bytestring), but the result is discarded. - Present in both reader and writer schemas.
In this case the field is marked to be read
AsIs
with an index that represents the field's position in the reader schema.