Static
URNEncode the input element (a key-value pair) into a byte output stream. They key and value are encoded one after the
other (first key, then value). The key is encoded with Context.needsDelimiters
, while the value is encoded with
the input context of the KVCoder
.
For example:
let w1 = new Writer()
let data = {'key': 'k1', 'value': 'v1'}
new KVCoder(new StrUtf8Coder(), new StrUtf8Coder()).encode(data, w1, Context.needsDelimiters)
console.log(w1.finish()) // ==> prints Uint8Array(6) [ 2, 107, 49, 2, 118, 49 ]
// Note that bytes with value 2 represent length prefixes, and other bytes represent the encoded strings.
Convert this coder into its protocol buffer representation for the Runner API. A coder in protobuf format can be shared with other components such as Beam runners, SDK workers; and reconstructed into its runtime representation if necessary.
a context that holds relevant pipeline attributes such as other coders already in the pipeline.
Generated using TypeDoc
A coder for a key-value pair.