MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / write_rows_single_ts

Function write_rows_single_ts

src/clusterd-test-driver/src/data.rs:147–177  ·  view source on GitHub ↗

Writes `rows` to `shard` at `ts`, advancing `upper` to `ts+1`. All rows are inserted with diff `+1`. Returns once the append succeeds.

(
    client: &PersistClient,
    shard: ShardId,
    desc: &RelationDesc,
    rows: &[Row],
    ts: Timestamp,
)

Source from the content-addressed store, hash-verified

145/// Writes `rows` to `shard` at `ts`, advancing `upper` to `ts+1`. All rows are
146/// inserted with diff `+1`. Returns once the append succeeds.
147pub async fn write_rows_single_ts(
148 client: &PersistClient,
149 shard: ShardId,
150 desc: &RelationDesc,
151 rows: &[Row],
152 ts: Timestamp,
153) -> anyhow::Result<()> {
154 let mut writer = client
155 .open_writer::<SourceData, (), Timestamp, StorageDiff>(
156 shard,
157 Arc::new(desc.clone()),
158 Arc::new(UnitSchema),
159 Diagnostics {
160 shard_name: "driver-data".to_string(),
161 handle_purpose: "headless driver write".to_string(),
162 },
163 )
164 .await?;
165
166 let updates: Vec<_> = rows
167 .iter()
168 .map(|r| ((SourceData(Ok(r.clone())), ()), ts, 1i64))
169 .collect();
170 let lower = Antichain::from_elem(ts);
171 let upper = Antichain::from_elem(ts.step_forward());
172 writer
173 .compare_and_append(&updates, lower, upper)
174 .await?
175 .map_err(|e| anyhow::anyhow!("{e}"))?;
176 Ok(())
177}
178
179/// Writes `rows` spread across timestamps `0..n_ts` (row `i` at time `i % n_ts`)
180/// in a single append that seals `[0, n_ts)`. All rows are inserted with diff

Callers 3

executeMethod · 0.85
index_over_small_shardFunction · 0.85

Calls 8

SourceDataClass · 0.85
cloneMethod · 0.45
to_stringMethod · 0.45
collectMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
step_forwardMethod · 0.45
compare_and_appendMethod · 0.45

Tested by 1

index_over_small_shardFunction · 0.68