package avro-compiler

  1. Overview
  2. Docs
Schema compiler for Avro

Install

Dune Dependency

Authors

Maintainers

Sources

v0.1.tar.gz
md5=729b33e6f19b3065fe2e3444c0981d73
sha512=671049a5b471323d87bfa7fd85dc4d1a5ba606c035110e2170b292f32d90d37f093ba91eb0234fbf73435c4c6c3a9a7381fb1a4e450101fa10ff5dea1e3e62a8

Description

Published: 12 Dec 2021

README

Avro

  • avro is the runtime library, should be reasonably small (depends only on camlzip)

  • avro-compiler can read a json schema and generate code from it

See some examples from the tests/ directory:

  • tests/records.json and tests/records_test.ml that use it. you can see what the schema compiler will produce:

    $ ./compiler.sh ./tests/records.json
    (* generated by avro-compiler *)
    
    open Avro
    
    module Str_map = Map.Make(String)
    
    let schema = "{\"type\":\"record\",\"name\":\"test\",\"fields\":[{\"type\":\"long\",\"name\":\"a\"},{
    \"type\":\"string\",\"name\":\"b\"}]}"
    
    type nonrec t = { a: int64;  b: string; }
    
    let read (input:Input.t) : t =
      (let a = Input.read_int64 input in
       let b = Input.read_string input in
       { a;b })
    
    let write (out:Output.t) (self:t) : unit =
      ((let self = self.a in Output.write_int64 out self);
        (let self = self.b in Output.write_string out self);
        )
    
    
  • similarly for tests/employee.json and tests/employee_test.ml that use it

License

MIT license.

Dependencies (3)

  1. yojson >= "1.6"
  2. ocaml >= "4.08.0"
  3. dune >= "2.0"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. avro

Conflicts

None

OCaml

Innovation. Community. Security.