oxirs_arq/streaming/
streamingselection_traits.rs1use crate::algebra::Solution;
12use anyhow::Result;
13
14use super::functions::DataStream;
15use super::types::{StreamStats, StreamingSelection};
16
17impl DataStream for StreamingSelection {
18 fn next_batch(&mut self) -> Result<Option<Vec<Solution>>> {
19 if let Some(batch) = self.input.next_batch()? {
20 let filtered: Vec<Solution> = batch
21 .into_iter()
22 .filter(|solution| self.evaluate_condition(solution).unwrap_or(false))
23 .collect();
24 if filtered.is_empty() && self.input.has_more() {
25 self.next_batch()
26 } else {
27 Ok(Some(filtered))
28 }
29 } else {
30 Ok(None)
31 }
32 }
33 fn has_more(&self) -> bool {
34 self.input.has_more()
35 }
36 fn estimated_size(&self) -> Option<usize> {
37 self.input.estimated_size()
38 }
39 fn reset(&mut self) -> Result<()> {
40 self.input.reset()
41 }
42 fn get_stats(&self) -> StreamStats {
43 self.input.get_stats()
44 }
45}