ClickHouse / ClickHouse/clickhouse-java
Example of migration from ClickHouseRowBinaryStream
- 主要语言
- Java
- 星标
- 1.6k
- 派生
- 636
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 29
描述
### Use case
For users, migrating from old client
### Describe the solution you'd like
...
### Describe the alternatives you've considered
...
### Additional context
I have code, that insert `(UUID, UUID, UUID, byte[])` objects with `clickhouse-jdbc:0.3.1-patch`:
```java
@Override
protected ProcessorResult send(List events) throws BackendServiceFailedException {
var sentEvents = new LinkedList();
try (ClickHouseStatement statement = this.connection.createStatement()) {
statement.write().send(
"INSERT INTO tracing_spans_local (trace_id, parent_span_id, span_id, payload)",
stream -> {
for (var event : events) {
write(stream, sinkEvent.getInternalEvent())
}
},
ClickHouseFormat.RowBinary);
@Override
protected boolean write(ClickHouseRowBinaryStream stream, Event event) throws IOException {
// ...
stream.writeUUID(traceId.get());
stream.writeUUID(parentSpanId.orElse(DEFAULT_UUID));
stream.writeUUID(spanId.get());
stream.writeUnsignedLeb128(event.getBytes().length);
stream.writeBytes(event.getBytes());
```
Now I'm trying to updage to `client-v2:0.8.2` and have no idea how to rewrite this. Tried to use `RowBinaryFormatWriter`, but it looks very complex and have no docs. Probably, it's not for client use?
贡献指南
调研方向
首先比较旧的 ClickHouseRowBinaryStream 用法与 client-v2 RowBinaryFormatWriter 入口以及 issue 中提到的 JDBC client API。记录 UUIDs、带长度前缀的 payload 和字节数据的等效迁移方式,并提供一个完整示例,展示如何发送 insert。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- clickhouse, java
- 领域
- api, documentation
- Issue 类型
- 文档
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 需要澄清
- 新手友好度
- 45/100