Module Obj_container_file.Encode

Encoding multiple rows to an output

type 'a t

Encoder

exception Closed
type 'a with_params = ?max_block_count:int -> ?buf_size:int -> ?pool:Avro__Iobuf.Pool.t -> ?codec:Codec.t -> 'a
val make : (Output.t -> schema:string -> write:(Output.t -> 'a -> unit) -> 'a t) with_params

make a new encoder.

  • parameter write

    the row type writer

  • parameter schema

    the json schema

  • parameter pool

    pool of buffers to use internally

  • parameter buf_size

    size of buffers if pool is not provided

  • parameter max_block_count

    forces a flush whenever there are that many elements in the current block.

val push : 'a t -> 'a -> unit

push enc x pushes a row into enc.

  • raises Closed

    if the encoder is closed with close.

val cur_block_count : _ t -> int

How many objects in the current block?

val flush_block : _ t -> unit

Flush current block to output

val close : _ t -> unit

close enc flushes the last block, if any, and renders the encoder unusable.

High level API

val write_seq : (schema:string -> write:(Output.t -> 'a -> unit) -> Output.t -> 'a Stdlib.Seq.t -> unit) with_params

Encode the given sequence of rows into the output.

val write_seq_to_string : (schema:string -> write:(Output.t -> 'a -> unit) -> 'a Stdlib.Seq.t -> string) with_params

Encode the given sequence of rows into a string