clj-odbp.binary.serialize.types

embedded-record?

(embedded-record? r)
Check if `r` is a valid OrientDB embedded record. eg:

{:_class "User" :name "Test"}

first-elem

(first-elem record-map offset)
Determine the structure of the first element of `record-map`.

get-structure

(get-structure record-map)
Transform the record `record-map` into a custom structure. eg.:

(get-structure {:_class "User" :name "Test"}) =>
[{:key-type 7, :field-name :_class, :position 0, :type 7, :value "User"}
 {:key-type 7, :field-name :name, :position 0, :type 7, :value "Test"}]

get-type

(get-type v)
Return a keyword the identifies the type of `v.` e.g.

(get-type true) => :boolean-type

header-size

(header-size headers fixed-header-int)
Calculate the total `headers` size. `fixed-header-int` is needed to
distinguish the calculation of the header size of a record from that of an
embedded map.

link?

(link? v)
Check if `v` is a valid OrientDB link. e.g.: "#21:1"

obinary?

(obinary? v)
Check if `v` is an OrientDB binary type.

oemap->structure

(oemap->structure data-map offset)
Trasform the embedded map `data-map` into a structure. e.g.:

(oemap->structure {:test 1} 0) =>
({:key-type 7, :field-name :test, :position [0 0 0 12], :type 1, :value 1,
  :serialized-value [2]})

oemap-positions

(oemap-positions structure offset)
Calculate the position of the values in `structure`, offsetting the first
value with `offset.`

oridbag?

(oridbag? v)
Check if `v` is an OrientDB RidBag embedded type.

oridtree?

(oridtree? v)
Check if `v` is an OrientDB RidBag tree type.

orient-int32

(orient-int32 value)
Convert `value` in an int32. e.g.: (orient-int32 1) => [0 0 0 1]

orient-types

Map custom orient types to their respective byte identifier.

positions->orient-int32

(positions->orient-int32 structure)
Convert the positions in `structure` in int32.

record-map->structure

(record-map->structure record-map offset)
Transform the record `record-map` into a structure. e.g.:

(record-map->structure {:_class "User" :name "Test"} 0) =>
({:key-type 7, :field-name :_class, :type 7, :value "User",
  :serialized-value [8 85 115 101 114], :position [0 0 0 24]}
 {:key-type 7, :field-name :name, :type 7, :value "Test",
  :position [0 0 0 29], :serialized-value [8 84 101 115 116]})

remove-meta-data

(remove-meta-data v)
Remove from `v` the entries whose keyword name starts with "_".

rest-elem

(rest-elem record-map first-elem)
Determine the structure of all but the first element of `record-map`.

serialize

multimethod

Serialize `value` based on its type.
It optionally accepts an `offset` which will be used to calculate the position
of `value` from the beginning of the record.

serialize-data

(serialize-data structure)
Retrieve the :serialized-value inside `structure`.

serialize-elements

(serialize-elements header key-order)
Serialize the elements in `header` returning a vector sorted by `key-order`.

serialize-headers

(serialize-headers structure key-order)
Serialize the elements in `structure` returning a sequence sorted by
`key-order`.

serialize-key-value

(serialize-key-value k v)
Serialize a key-value according to OrientDB specification.
See: http://orientdb.com/docs/last/Record-Schemaless-Binary-Serialization.html#linkmap

serialize-list-item

(serialize-list-item value)
Serialize `value` in a vector of bytes with the byte representing its type
coming first. e.g.:

(serialize-list-item true) => [0 1]

serialize-structure-values

(serialize-structure-values structure)
Serialize the values inside `structure` according to their type.