Skip to content

[WIP] Protobuf support - #2440

Closed
zhkvia wants to merge 2 commits into
ClickHouse:masterfrom
zhkvia:add-protobuf-support
Closed

zhkvia wants to merge 2 commits into
ClickHouse:masterfrom
zhkvia:add-protobuf-support

Conversation

@zhkvia

@zhkvia zhkvia commented May 29, 2018

Copy link
Copy Markdown
Contributor

std::cerr << "schema_path: " << schema_path << std::endl;
std::cerr << "root obj: " << root_obj << std::endl;

int fd = open(schema_path.c_str(), O_RDONLY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use high-level interface.
If an exception is thrown below, the open file will remain.

@alexey-milovidov

Copy link
Copy Markdown
Member

It is 5% done, at most. This PR has no future.
We will continue in a separate PR.

@knoguchi

knoguchi commented Dec 19, 2018 •

Copy link
Copy Markdown
Contributor

I know this is a closed PR but I tested anyway. The biggest problem is it can't handle multiple PB messages. The Kafka storage polls Kafka, then the messages consumed are batched up and copied into a buffer. The delimiter option in Kafka storage won't work because PB is not a delimiter safe format unfortunately. One idea is to frame the each message with a run length prefix that is a little endian uint32 before copying into the buffer. Can we introduce such option to Kafka storage? Or kafka_format=Protobuf can imply the run length prefix since it's just an internal contract between Kafka storage and ProtobufRowInputStream.

@alexey-milovidov

Copy link
Copy Markdown
Member

We have started another task as a replacement for this PR.
Protobuf messages will be delimited by size, as in https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/delimited_message_util.h

@alexey-milovidov

Copy link
Copy Markdown
Member

If your messages in Kafka will be prefixed by size in appropriate format (varint), the Kafka storage will be able to read them from Protobuf format.

@knoguchi

knoguchi commented Dec 20, 2018 •

Copy link
Copy Markdown
Contributor

Thanks for the description (I've read it using Google Translator). It seems Protobuf v3.3.0 added the delimited message utilities for C++ (Protobuf for Java supports delimiter for a long time).

I did a bit of experiment. Unfortunately ParseDelimitedFromZeroCopyStream takes MessageLite instead of Message. MessageLite lacks reflection methods that are necessary to extract fields from messages dynamically. There might be a way to work around but probably it's ok to copy some functions from the utility to ClickHouse while keeping the compatibility with the Google's official delimiter spec.

By the way I've written "jq for Protobuf" using libjq and libjv. It can query nested Protobuf messages just like jq for JSON. You mentioned in the document that arrays, nested messages and other complex types won't be supported. The jq can flatten the complex structure. I'm integrating it to ClickHouse as a proof of concept.

filimonov added a commit to filimonov/ClickHouse that referenced this pull request Oct 12, 2026
…ifest id

From the audit comment on PR ClickHouse#2440. The path predates the PR (Parts
layer, 9d08bc0); priority Low until the read-your-writes question
is answered.
Related: Altinity#2440 (comment)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01V8mZSGiD8iJumpJMiQnrmC
Signed-off-by: Mikhail Filimonov <[email protected]>
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

Successfully merging this pull request may close these issues.

4 participants