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,
)
| 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. |
| 147 | pub 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 |