abracad.avro documentation

Functions for de/serializing data with Avro.

*avro-readers*

Like `clojure.core/*data-readers*`, but for reading Avro records.
Initializes with merged contents of `avro_readers.clj` resources.
Whenever an Avro record is deserialized, the Clojure datum reader will
check this map for a key matching the Avro record name represented as
a namespace-qualified symbol.  When found, the datum reader will
invoke the associated value as a function on the deserialized record's
fields as positional arguments.  The datum reader will use the return
value as the deserialization result.

-seekable-input

(-seekable-input x opts)
Attempt to coerce `x` to an Avro `SeekableInput`.

AvroSerializable

Protocol for customizing Avro serialization.

PSeekableInput

Protocol for coercing to an Avro `SeekableInput`.

binary-decoder

(binary-decoder source)
Return a binary-encoding decoder for `source`.  The `source` may be
an input stream, a byte array, or a vector of `[bytes off len]`.

binary-encoded

(binary-encoded schema & records)
Return bytes produced by binary-encoding `records` with `schema`
via `encode`.

binary-encoder

(binary-encoder sink)
Return a binary-encoding encoder for `sink`.

compare

(compare schema x y)
Compare `x` and `y` according to `schema`.

data-file-reader

(data-file-reader source)(data-file-reader expected source)
Return an Avro DataFileReader which produces Clojure data structures.

data-file-writer

(data-file-writer)(data-file-writer sink)(data-file-writer schema sink)(data-file-writer codec schema sink)
Return an Avro DataFileWriter which consumes Clojure data structures.

datum-reader

(datum-reader)(datum-reader schema)(datum-reader expected actual)
Return an Avro DatumReader which produces Clojure data structures.

datum-writer

(datum-writer)(datum-writer schema)
Return an Avro DatumWriter which consumes Clojure data structures.

decode

(decode schema source)
Decode and return one object from `source` using `schema`.  The
`source` may be an existing Decoder object or anything on which
a (binary-encoding) Decoder may be opened.

decode-seq

(decode-seq schema source)
As per `decode`, but decode and return a sequence of all objects
decoded serially from `source`.

direct-binary-decoder

(direct-binary-decoder source)
Return a non-buffered binary-encoding decoder for `source`.

direct-binary-encoder

(direct-binary-encoder sink)
Return an unbuffered binary-encoding encoder for `sink`.

encode

(encode schema sink & records)
Serially encode each record in `records` to `sink` using `schema`.
The `sink` may be an existing Encoder object, or anything on which
a (binary-encoding) Encoder may be opened.

field-get

(field-get this field)
Value of keyword `field` for Avro serialization of object.

field-list

(field-list this)
List of keyword fields this object provides.

grouping-schema

(grouping-schema n schema)
Produce a grouping schema version of record schema `schema` which ignores all
but the first `n` fields when sorting.

json-decoder

(json-decoder schema source)
Return a JSON-encoding decoder for `source` using `schema`.

json-encoded

(json-encoded schema & records)
Return string produced by JSON-encoding `records` with `schema`
via `encode`.

json-encoder

(json-encoder schema sink)
Return a JSON-encoding encoder for `sink` using `schema`.

mslurp

(mslurp f & opts)
Like Avro `slurp`, but produces a sequence of records.

mspit

(mspit schema f content & opts)
Like Avro `spit`, but emits `content` as a sequence of records.

parse-schema

(parse-schema source)(parse-schema source & sources)
Parse Avro schemas in `source` and `sources`.  Each schema source may be a
JSON string, an input stream containing a JSON schema, a Clojure data structure
which may be converted to a JSON schema, or an already-parsed Avro schema
object.  The schema for each subsequent source may refer to the types defined in
the previous schemas.  The parsed schema from the final source is returned.

schema-name

(schema-name this)
Full package-/namespace-qualified name for Avro purposes.

schema?

(schema? schema)
True iff `schema` is an Avro `Schema` instance.

seekable-input

(seekable-input x)(seekable-input opts x)
Attempt to coerce `x` to an Avro `SeekableInput`.

slurp

(slurp f & opts)
Like core `slurp`, but reads Avro content from `f`.

spit

(spit schema f content & opts)
Like core `spit`, but emits `content` to `f` as Avro with `schema`.

tuple-schema

(tuple-schema types)(tuple-schema name types)
Return Clojure-data Avro schema for record consisting of fields of the
provided `types`, and optionally named `name`.

unparse-schema

(unparse-schema schema)
Return Avro-normalized Clojure data version of `schema`.  If `schema` is not
already a parsed schema, will first normalize and parse it.