avro-0.3.5.0: Avro serialization support for Haskell

Safe HaskellNone
LanguageHaskell2010

Data.Avro.Decode.Lazy

Contents

Synopsis

Documentation

decodeAvro :: Schema -> ByteString -> LazyValue Type Source #

Decode bytes into a Value as described by Schema.

decodeContainer :: forall a. FromAvro a => ByteString -> [Either String a] Source #

Decodes the container as a lazy list of values of the requested type.

The schema for the requested type will be de-conflicted with the schema embedded with the container.

Errors are reported as a part of the list and the list will stop at first error. This means that the consumer will get all the "good" content from the container until the error is detected, then this error and then the list is finished.

decodeContainer' :: forall a. FromAvro a => ByteString -> Either String [[Either String a]] Source #

Decodes the container as a lazy list of values of the requested type.

The schema for the requested type will be de-conflicted with the schema embedded with the container.

The content of the container is returned as a list of "blocks" of values inside this container, so the notion of blocks in the container is preserved. Since decoding is lazy it should be safe to concat these values into one lazy list.

The "outer" error represents the error in opening the container itself (including problems like reading schemas embedded into the container.)

The "inner" errors represent problems in decoding individual values.

Note that this function will not stop decoding at the first occurance of the "inner" error, and will continue attempting decoding values, so it is possible to get Right after Left. It is up to the user to decide whether it is correct or not to continue after errors (most likely it will not be correct).

decodeContainer function makes a choice to stop after the first error.

decodeContainerWithSchema :: FromAvro a => Schema -> ByteString -> [Either String a] Source #

Same as decodeContainer but uses provided schema as a reader schema for the container instead of the schema obtained from the type of a.

It is up to the user to make sure that the provided schema is compatible with a and with the container's writer schema.

decodeContainerWithSchema' :: FromAvro a => Schema -> ByteString -> Either String [[Either String a]] Source #

Same as decodeContainer' but uses provided schema as a reader schema for the container instead of the schema obtained from the type of a.

It is up to the user to make sure that the provided schema is compatible with a and with the container's writer schema.

Bypass decoding

decodeRawBlocks :: ByteString -> Either String (Schema, [Either String (Int, ByteString)]) Source #

Reads the container as a list of blocks without decoding them into actual values.

This can be useful for streaming splitting merging Avro containers without paying the cost for Avro encoding/decoding.

Each block is returned as a raw ByteString annotated with the number of Avro values that are contained in this block.

The "outer" error represents the error in opening the container itself (including problems like reading schemas embedded into the container.)

Lower level interface

getContainerValues :: ByteString -> Either String (Schema, [[LazyValue Type]]) Source #

Decodes the container into a list of blocks of raw Avro values.

The content of the container is returned as a list of "blocks" of values inside this container, so the notion of blocks in the container is preserved. Since decoding is lazy it should be safe to concat these values into one lazy list.

Each LazyValue can be an Error and this function doesn't make any attempts of dealing with them leaving it up to the user.

The "outer" error represents the error in opening the container itself (including problems like reading schemas embedded into the container.)

class GetAvro a where Source #

Minimal complete definition

getAvro

Methods

getAvro :: Get a Source #

Instances
GetAvro Bool Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Bool Source #

GetAvro Double Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro Float Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro Int32 Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro Int64 Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro ByteString Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro ByteString Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro String Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro Text Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Text Source #

GetAvro ContainerHeader Source # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro a => GetAvro [a] Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get [a] Source #

GetAvro a => GetAvro (Maybe a) Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Maybe a) Source #

(GetAvro a, Ord a) => GetAvro (Set a) Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Set a) Source #

GetAvro a => GetAvro (Vector a) Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Vector a) Source #

GetAvro ty => GetAvro (Map Text ty) Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Map Text ty) Source #

GetAvro a => GetAvro (Array Int a) Source # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Array Int a) Source #