Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Messages encoded with OCF are wrapped in a List" what for? #79

Closed
romul opened this issue Mar 26, 2021 · 1 comment
Closed

"Messages encoded with OCF are wrapped in a List" what for? #79

romul opened this issue Mar 26, 2021 · 1 comment

Comments

@romul
Copy link

romul commented Mar 26, 2021

Is there any reason why messages encoded with Codec.ObjectContainerFile are wrapped in a list?

I propose to rewrite ObjectContainerFile.decode/1 as:

  def decode(payload) when is_binary(payload) do
    with {:ok, {_, _, [decoded]}} <- do_decode(payload), do: {:ok, decoded}
  end
@Strech
Copy link
Owner

Strech commented Mar 29, 2021

Hi @romul, thanks for you proposal! Unfortunately, I can't accept it because it is done to comply with the Avro specification.

The concept of the OCF is well described by this quote from the official docs

Avro includes a simple object container file format. A file has a schema, and all objects stored in the file must be written according to that schema, using binary encoding. Objects are stored in blocks that may be compressed.

So in other words you have a container (file, or bucket so to say) and you stuff it with objects (multiple records or a special case - 1 record). And because of that we should keep a list, even tho for the case with 1 record it seems redundant.

@Strech Strech closed this as completed Mar 29, 2021
@Strech Strech added help wanted Extra attention is needed question? Questions or ideas about the library and removed help wanted Extra attention is needed question? Questions or ideas about the library labels Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants