Static
INSTANCEStatic
URNDecode the input byte stream into a byte array.
If context is needsDelimiters
, the first bytes will be interpreted as a var-int32 encoding
the length of the data.
If the context is wholeStream
, the whole input stream is decoded as-is.
a reader to access the input byte stream
whether the data is encoded with delimiters (Context.needsDelimiters
), or without (Context.wholeStream
).
Encode the input element (a byte-string) into the output byte stream from writer
.
If context is needsDelimiters
, the byte string is encoded prefixed with a
varint representing its length.
If the context is wholeStream
, the byte string is encoded as-is.
For example:
const w1 = new Writer()
const data = new TextEncoder().encode("bytes")
new BytesCoder().encode(data, w1, Context.needsDelimiters)
console.log(w1.finish()) // ==> prints Uint8Array(6) [ 5, 98, 121, 116, 101, 115 ], where 5 is the length prefix.
const w2 = new Writer()
new BytesCoder().encode("bytes", w1, Context.wholeStream)
console.log(w2.finish()) // ==> prints Uint8Array(5) [ 98, 121, 116, 101, 115 ], without the length prefix
a byte array to encode. This represents an element to be encoded.
a writer to access the stream of bytes with encoded data
whether to encode the data with delimiters (Context.needsDelimiters
), or without (Context.wholeStream
).
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
Coder for byte-array data types.