mirror of
https://github.com/hanzo-ds/rs.git
synced 2026-10-30 20:49:56 +00:00
Cut from the upstream v0.13.3 release tag (not HEAD) so this is a pure
rename with no behaviour change. v0.13.3 is what our consumers already
resolve to: insights/rust's Cargo.lock pins clickhouse 0.13.3 and its
manifest already declares `datastore` at 0.13.x.
The load-bearing change is the HTTP auth header rename. The Datastore
server reads only X-Datastore-User / X-Datastore-Key; the upstream names
return `401 Code: 194 Authentication failed`. Every un-renamed HTTP
client is therefore unable to authenticate at all — this is a
correctness fix, not branding.
- crate `clickhouse` -> `datastore`, `clickhouse-derive` -> `datastore-derive`;
versions preserved exactly (0.13.3 / 0.2.0).
- derive macro emits `datastore::Row` in lockstep, so downstream
`#[derive(Row)]` keeps resolving.
- User-Agent reports `datastore-rs/{version}`.
- test-harness env vars CLICKHOUSE_* -> DATASTORE_*; compose uses
ghcr.io/hanzoai/datastore with /etc/datastore-server config paths.
- doc links point at docs.hanzo.ai/datastore.
- `publish = false`: the `datastore` name on crates.io belongs to an
unrelated crate, so consume this by git tag, never by version range.
CHANGELOG is truncated to a fork notice rather than find-replaced —
rewriting upstream release history would manufacture changes Datastore
never shipped. References to upstream issues keep their numbers.
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
use serde::Deserialize;
|
|
|
|
use datastore::{Client, Compression, Row};
|
|
|
|
#[derive(Row, Deserialize)]
|
|
struct Data {
|
|
no: u64,
|
|
}
|
|
|
|
async fn bench(name: &str, compression: Compression) {
|
|
let start = std::time::Instant::now();
|
|
let (sum, dec_mbytes, rec_mbytes) = tokio::spawn(do_bench(compression)).await.unwrap();
|
|
assert_eq!(sum, 124999999750000000);
|
|
let elapsed = start.elapsed();
|
|
let throughput = dec_mbytes / elapsed.as_secs_f64();
|
|
println!("{name:>8} {elapsed:>7.3?} {throughput:>4.0} MiB/s {rec_mbytes:>4.0} MiB");
|
|
}
|
|
|
|
async fn do_bench(compression: Compression) -> (u64, f64, f64) {
|
|
let client = Client::default()
|
|
.with_compression(compression)
|
|
.with_url("http://localhost:8123");
|
|
|
|
let mut cursor = client
|
|
.query("SELECT number FROM system.numbers_mt LIMIT 500000000")
|
|
.fetch::<Data>()
|
|
.unwrap();
|
|
|
|
let mut sum = 0;
|
|
while let Some(row) = cursor.next().await.unwrap() {
|
|
sum += row.no;
|
|
}
|
|
|
|
let dec_bytes = cursor.decoded_bytes();
|
|
let dec_mbytes = dec_bytes as f64 / 1024.0 / 1024.0;
|
|
let recv_bytes = cursor.received_bytes();
|
|
let recv_mbytes = recv_bytes as f64 / 1024.0 / 1024.0;
|
|
(sum, dec_mbytes, recv_mbytes)
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
println!("compress elapsed throughput received");
|
|
bench("none", Compression::None).await;
|
|
#[cfg(feature = "lz4")]
|
|
bench("lz4", Compression::Lz4).await;
|
|
}
|