Skip to main content

oxirs_arq/streaming/
bufferedpatternscan_traits.rs

1//! # BufferedPatternScan - Trait Implementations
2//!
3//! This module contains trait implementations for `BufferedPatternScan`.
4//!
5//! ## Implemented Traits
6//!
7//! - `DataStream`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::algebra::Solution;
12use anyhow::Result;
13use std::time::Duration;
14
15use super::functions::DataStream;
16use super::types::{BufferedPatternScan, StreamStats};
17
18impl DataStream for BufferedPatternScan {
19    fn next_batch(&mut self) -> Result<Option<Vec<Solution>>> {
20        if self.exhausted || self.current_index >= self.solutions.len() {
21            return Ok(None);
22        }
23        let end_index = (self.current_index + self.batch_size).min(self.solutions.len());
24        let batch = self.solutions[self.current_index..end_index].to_vec();
25        self.current_index = end_index;
26        if self.current_index >= self.solutions.len() {
27            self.exhausted = true;
28        }
29        Ok(Some(batch))
30    }
31    fn has_more(&self) -> bool {
32        !self.exhausted && self.current_index < self.solutions.len()
33    }
34    fn estimated_size(&self) -> Option<usize> {
35        Some(self.solutions.len())
36    }
37    fn reset(&mut self) -> Result<()> {
38        self.current_index = 0;
39        self.exhausted = false;
40        Ok(())
41    }
42    fn get_stats(&self) -> StreamStats {
43        StreamStats {
44            rows_processed: self.solutions.len(),
45            bytes_processed: 0,
46            processing_time: Duration::from_secs(0),
47            spill_operations: 0,
48            cache_hits: 0,
49            cache_misses: 0,
50        }
51    }
52}