Skip to content

Commit 950f993

Browse files
committed
test(wasm): follow current VGI producer API
1 parent c56a38f commit 950f993

3 files changed

Lines changed: 55 additions & 7 deletions

File tree

test/support/sabtable/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/support/sabtable/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ path = "src/lib.rs"
2121
# staticlib builds with no heavy/C deps.
2222
vgi = { path = "../../../../vgi-rust/vgi", default-features = false }
2323
# Must match the exact vgi-rpc that `vgi` resolves to (the local checkout via
24-
# the [patch.crates-io] below — 0.23.0 today) so the `OutputCollector` /
24+
# the [patch.crates-io] below) so the `OutputCollector` /
2525
# `Result` / `RpcError` types are one crate instance, not two. A stale version
2626
# requirement here silently resolves a SECOND vgi-rpc from crates.io and the
2727
# build fails on mismatched `RpcError`/`TableProducer` types.
@@ -35,8 +35,8 @@ serde = { version = "1", features = ["derive"] }
3535
[profile.release]
3636
opt-level = 2
3737

38-
# vgi (via ../../../../vgi-rust) resolves vgi-rpc to the local 0.12.0 checkout;
38+
# vgi (via ../../../../vgi-rust) resolves vgi-rpc to the local checkout;
3939
# point this standalone crate at the same source so both unify to ONE vgi-rpc
40-
# instance. Remove once vgi-rpc 0.12.0 is on crates.io.
40+
# instance.
4141
[patch.crates-io]
4242
vgi-rpc = { path = "../../../../vgi-rpc-rust/vgi-rpc" }

test/support/sabtable/src/lib.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ impl TableProducer for CountProducer {
115115
.map_err(|e| RpcError::runtime_error(e.to_string()))?;
116116
Ok(Some(batch))
117117
}
118+
119+
fn resume_supported(&self) -> bool {
120+
// The producer returns at most one batch.
121+
false
122+
}
118123
}
119124

120125
impl TableFunction for CountTo {
@@ -167,6 +172,8 @@ impl TableProducer for EmitProducer {
167172
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
168173
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
169174
}
175+
176+
vgi::resume_fields!(batch_idx, counter);
170177
}
171178
impl TableFunction for EmitBatches {
172179
fn name(&self) -> &str {
@@ -204,6 +211,11 @@ impl TableProducer for BoomProducer {
204211
fn next_batch(&mut self, _out: &mut OutputCollector) -> Result<Option<RecordBatch>> {
205212
Err(RpcError::runtime_error("boom: intentional worker error"))
206213
}
214+
215+
fn resume_supported(&self) -> bool {
216+
// This fixture errors before it can emit a batch.
217+
false
218+
}
207219
}
208220
impl TableFunction for Boom {
209221
fn name(&self) -> &str {
@@ -265,6 +277,8 @@ impl TableProducer for SlowProducer {
265277
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
266278
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
267279
}
280+
281+
vgi::resume_fields!(i);
268282
}
269283
impl TableFunction for SlowCount {
270284
fn name(&self) -> &str {
@@ -309,6 +323,11 @@ impl TableProducer for PeekProducer {
309323
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
310324
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
311325
}
326+
327+
fn resume_supported(&self) -> bool {
328+
// The producer returns at most one batch.
329+
false
330+
}
312331
}
313332
impl TableFunction for PeekMaxConcurrency {
314333
fn name(&self) -> &str {
@@ -353,6 +372,8 @@ impl TableProducer for ParallelProbeProducer {
353372
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
354373
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
355374
}
375+
376+
vgi::resume_fields!(i);
356377
}
357378
impl TableFunction for ParallelProbe {
358379
fn name(&self) -> &str {
@@ -519,6 +540,8 @@ impl TableProducer for SabBigProducer {
519540
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
520541
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
521542
}
543+
544+
vgi::resume_fields!(emitted);
522545
}
523546
impl TableFunction for SabBig {
524547
fn name(&self) -> &str {
@@ -578,6 +601,11 @@ impl TableProducer for SabCachedProducer {
578601
fn last_metadata(&self) -> Option<HashMap<String, String>> {
579602
self.meta.clone()
580603
}
604+
605+
fn resume_supported(&self) -> bool {
606+
// The cache fixture deliberately returns one metadata-bearing batch.
607+
false
608+
}
581609
}
582610
impl TableFunction for SabCached {
583611
fn name(&self) -> &str {
@@ -636,6 +664,11 @@ impl TableProducer for BrowserInfoProducer {
636664
Ok(Some(RecordBatch::try_new(self.schema.clone(), cols)
637665
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
638666
}
667+
668+
fn resume_supported(&self) -> bool {
669+
// The browser snapshot is returned in one batch.
670+
false
671+
}
639672
}
640673
#[cfg(target_os = "emscripten")]
641674
impl TableFunction for BrowserInfo {
@@ -696,6 +729,11 @@ impl TableProducer for ClientRandomProducer {
696729
Ok(Some(RecordBatch::try_new(self.schema.clone(), vec![col])
697730
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
698731
}
732+
733+
fn resume_supported(&self) -> bool {
734+
// All requested random values are returned in one batch.
735+
false
736+
}
699737
}
700738
#[cfg(target_os = "emscripten")]
701739
impl TableFunction for ClientRandom {
@@ -760,6 +798,11 @@ impl TableProducer for ClientFetchProducer {
760798
Ok(Some(RecordBatch::try_new(self.schema.clone(), cols)
761799
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
762800
}
801+
802+
fn resume_supported(&self) -> bool {
803+
// One fetch produces one response batch.
804+
false
805+
}
763806
}
764807
#[cfg(target_os = "emscripten")]
765808
impl TableFunction for ClientFetch {
@@ -827,6 +870,11 @@ impl TableProducer for ClientGeoProducer {
827870
Ok(Some(RecordBatch::try_new(self.schema.clone(), cols)
828871
.map_err(|e| RpcError::runtime_error(e.to_string()))?))
829872
}
873+
874+
fn resume_supported(&self) -> bool {
875+
// One geolocation lookup produces one snapshot batch.
876+
false
877+
}
830878
}
831879
#[cfg(target_os = "emscripten")]
832880
impl TableFunction for ClientGeo {

0 commit comments

Comments
 (0)