avro-0.3.5.1: Avro serialization support for Haskell

Safe HaskellNone
LanguageHaskell2010

Data.Avro.Decode.Lazy

Contents

Synopsis

Documentation

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

Decode bytes into a Value as described by Schema.

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

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]] #

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] #

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]] #

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)]) #

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]]) #

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.)

getContainerValuesBytes :: ByteString -> Either String (Schema, [Either String ByteString]) #

Splits container into a list of individual avro-encoded values.

This is particularly useful when slicing up containers into one or more smaller files. By extracting the original bytestring it is possible to avoid re-encoding data.

getContainerValuesBytes' :: ByteString -> Either String (Schema, [Either String (Value Type, ByteString)]) #

Splits container into a list of individual avro-encoded values. This version provides both encoded and decoded values.

This is particularly useful when slicing up containers into one or more smaller files. By extracting the original bytestring it is possible to avoid re-encoding data.

class GetAvro a where #

Minimal complete definition

getAvro

Methods

getAvro :: Get a #

Instances
GetAvro Bool # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Bool #

GetAvro Double # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Double #

GetAvro Float # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Float #

GetAvro Int32 # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Int32 #

GetAvro Int64 # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Int64 #

GetAvro ByteString # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro ByteString # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro String # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get String #

GetAvro Text # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get Text #

GetAvro ContainerHeader # 
Instance details

Defined in Data.Avro.Decode.Get

GetAvro a => GetAvro [a] # 
Instance details

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get [a] #

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

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Maybe a) #

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

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Set a) #

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

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Vector a) #

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

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Map Text ty) #

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

Defined in Data.Avro.Decode.Get

Methods

getAvro :: Get (Array Int a) #