Safe Haskell | None |
---|---|
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
Eq ReadFloat Source # | |
Ord ReadFloat Source # | |
Defined in Data.Avro.Schema.ReadSchema | |
Show ReadFloat Source # | |
Generic ReadFloat Source # | |
NFData 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.0.0-DoOm2DJah3nIktWo4nyiQe" '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.
Instances
Eq Decimal Source # | |
Ord Decimal Source # | |
Show Decimal Source # | |
Generic Decimal Source # | |
NFData Decimal Source # | |
Defined in Data.Avro.Schema.Schema | |
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.0.0-DoOm2DJah3nIktWo4nyiQe" '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 #
Instances
data LogicalTypeInt Source #
Instances
data LogicalTypeLong Source #
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.