Skip to content

Store large documents as single objects#254

Merged
elffjs merged 4 commits into
mainfrom
split_off_large_att
Mar 18, 2026
Merged

Store large documents as single objects#254
elffjs merged 4 commits into
mainfrom
split_off_large_att

Conversation

@elffjs

@elffjs elffjs commented Mar 17, 2026

Copy link
Copy Markdown
Member

If a CloudEvent's size is larger than a configurable threshold—1 MiB by default—write it to S3 as an individual object instead of as a row in a Parquet batch. This happens in a new stream, output-document.yaml.

This new stream has a very small custom Go processor that pairs each large event with a ClickHouse row message, much as in the rawparquet package. We could do all of this in Bloblang if we wanted to, but doing it this way lets us use common helpers and keep the behavior consistent. The object keys look like

cloudevent/blobs/{subject}/{year}/{month}/{day}/single-{uuid}.json

The S3 and ClickHouse portions are extremely similar to those of the Parquet stream. We might consider using resources or chaining with another stream.

output:
switch:
cases:
# Large CloudEvents → individual document storage

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Need to remove these slop comments.

@zer0stars zer0stars left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perfecto :)

Revisit this: this should not be possible
@elffjs elffjs marked this pull request as ready for review March 17, 2026 18:54
@elffjs elffjs changed the title Split off large documents Store large documents as single objects Mar 17, 2026
@elffjs elffjs merged commit 61671ce into main Mar 18, 2026
8 checks passed
@elffjs elffjs deleted the split_off_large_att branch March 18, 2026 14:21
elffjs added a commit to DIMO-Network/cloudevent that referenced this pull request Apr 27, 2026
We wanted to store the data from large documents (per some configurable threshold) in separate S3 objects so that they can be downloaded easily through presigned S3 links and not balloon the size of Parquet files. Since DIMO-Network/dis#254 we've been storing these large events as standalone JSON objects, including the headers. But clients do not enjoy unwrapping the data inside the event and parsing the base64.

To accommodate this, we introduce a new ClickHouse column `data_index_key`. Unlike the existing `index_key`, this column is also written to the Parquet files (morally, we want to be able to reconstruct a working system from S3 alone). In Go we represent this in a new `StoredEvent` type, rather than adding to `CloudEventHeader`, for two reasons:

1. Security. With this choice it's easier to ensure that client input is never placed into this field. If we failed at this, a client might be able to gain access to files that he should not be able to see.
2. Separation. Many users of the cloudevent package don't care about ClickHouse storage at all. The struct currently doesn't bother them with an `IndexKey` field, and it would be nice to maintain this separation.

Old clients that assume the old table structures should still work, but they should upgrade soon.
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.

2 participants