Ch.RowBinary (Ch v0.3.1)

View Source

Helpers for working with ClickHouse RowBinary format.

Summary

Functions

Same as decode_rows/1 but the first element is a list of column names.

Encodes a single row to RowBinary as iodata.

Encodes multiple rows to RowBinary as iodata.

Functions

decode_names_and_rows(arg)

Same as decode_rows/1 but the first element is a list of column names.

Example:

iex> decode_names_and_rows(<<1, 3, "1+1"::bytes, 5, "UInt8"::bytes, 2>>)
[["1+1"], [2]]

decode_rows(row_binary_with_names_and_types)

Decodes RowBinaryWithNamesAndTypes into rows.

Example:

iex> decode_rows(<<1, 3, "1+1"::bytes, 5, "UInt8"::bytes, 2>>)
[[2]]

decode_rows(row_binary, types)

Decodes RowBinary into rows.

Example:

iex> decode_rows(<<1>>, ["UInt8"])
[[1]]

encode_row(row, types)

Encodes a single row to RowBinary as iodata.

Examples:

iex> encode_row([], [])
[]

iex> encode_row([1], ["UInt8"])
[1]

iex> encode_row([3, "hello"], ["UInt8", "String"])
[3, [5 | "hello"]]

encode_rows(rows, types)

Encodes multiple rows to RowBinary as iodata.

Examples:

iex> encode_rows([], [])
[]

iex> encode_rows([[1]], ["UInt8"])
[1]

iex> encode_rows([[3, "hello"], [4, "hi"]], ["UInt8", "String"])
[3, [5 | "hello"], 4, [2 | "hi"]]