scribe.avro.core
Functions for Clojure Spec to Avro schema conversion, encoding and decoding.
->avro-schema
(->avro-schema spec-k)
Generates an Avro schema for `spec-k`. `spec-k`: the key of the Spec to convert
->avro-schema*
multimethod
Returns a tuple: [`::spec->avro-ref` `::avro-schema`]. The `::spec->avro-ref` map is updated in any calls that define Avro named types, so that schemas are only defined on the first instance and then referred to by fully qualified name. NOTE: you shouldn't need to call this directly, but you can extend this multimethod to implement schema generation for specs that aren't included here.
binary-encoded
(binary-encoded spec-k & records)
See `abracad.avro/binary-encoded`.
decode
(decode spec-k source)
See `abracad.avro/decode`.
enum?
(enum? x)
Specs defined as non-empty, keyword-only sets are `::enum`s. `::enum`s are used for defining a finite set of choices and are converted to Avro `:enum`s. An example would be: `(s/def ::color #{:red :green :blue})'
post-deserialize
(post-deserialize spec-k v)
Processes a deserailized value `v` from Avro. For example, it converts bytes to a `BigDecimal` for an Avro `:decimal`, integers to `Instants` for `:timestamp-millis` and so on, according to the Avro specification.
post-deserialize*
multimethod
See `post-deserialize`. NOTE: you shouldn't need to call this directly, but you can extend this multimethod to implement value post-deserialization for specs that aren't included here.
pre-serialize
(pre-serialize spec-k v)
Prepares a value `v` for encoding to Avro. For example, it converts `BigDecimal`s to bytes for Avro `:decimal`s, `:timestamp-millis` to integers and so on, according to the Avro specification.
pre-serialize*
multimethod
See `pre-serialize`. NOTE: you shouldn't need to call this directly, but you can extend this multimethod to implement value pre-serialization for specs that aren't included here.