You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: README.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,14 @@ A CloudEvent is uniquely identified by the combination of the following fields:
110
110
-`Source`
111
111
-`ID`
112
112
113
-
This combination forms the "index key" for the event and is used for deduplication and retrieval purposes.
113
+
This combination is the event's logical key (see `CloudEventHeader.Key()`) and is used for deduplication.
114
+
115
+
### Storage keys
116
+
117
+
These are storage pointers, set server-side by the ingestion pipeline. They are **not** part of the CloudEvent wire format and must never be set from producer-supplied input.
118
+
119
+
-`index_key`: pointer to the backing object holding this event's row. For events grouped into a Parquet bundle, the format is `<bundleObjectKey>#<rowOffset>` (see `parquet.ParseIndexKey`). For singleton events, it's the standalone object's key (see `clickhouse.CloudEventToObjectKey`).
120
+
-`data_index_key`: pointer to the external object holding this event's payload, when the payload is stored out-of-band (e.g. a large image). Empty when the payload is inline in the row's `data` / `data_base64`. Carried on `cloudevent.StoredEvent.DataIndexKey` at write time and stored as a column in both ClickHouse and the Parquet bundle.
ALTERTABLE cloud_event ADD COLUMN data_index_key String COMMENT 'Key of the object holding the data payload. Empty for small events that are entirely stored in the object referenced by index_key.' AFTER index_key;
4
+
-- +goose StatementEnd
5
+
6
+
-- +goose Down
7
+
-- +goose StatementBegin
8
+
ALTERTABLE cloud_event DROP COLUMN data_index_key;
0 commit comments