pub struct StringBatchIterator { /* private fields */ }Expand description
Iterator for scanning Redis strings in batches as Arrow RecordBatches.
This iterator fetches string keys matching a pattern and retrieves their values, converting them to Arrow RecordBatches for use with Polars.
String values are parsed according to the schema’s data type (e.g., Int64, Float64, Boolean, or Utf8).
§Example
ⓘ
use polars_redis::{StringBatchIterator, StringSchema, BatchConfig, DataType};
let schema = StringSchema::new(DataType::Int64).with_key(true);
let config = BatchConfig::new("counter:*").with_batch_size(1000);
let mut iterator = StringBatchIterator::new(url, schema, config)?;
while let Some(batch) = iterator.next_batch()? {
println!("Got {} rows", batch.num_rows());
}§Performance
- Uses
SCANwith configurableCOUNThint for non-blocking iteration - Pipelines multiple
GETcommands per batch - Memory-efficient streaming (processes one batch at a time)
Implementations§
Source§impl StringBatchIterator
impl StringBatchIterator
Sourcepub fn new(url: &str, schema: StringSchema, config: BatchConfig) -> Result<Self>
pub fn new(url: &str, schema: StringSchema, config: BatchConfig) -> Result<Self>
Create a new StringBatchIterator.
Sourcepub fn next_batch(&mut self) -> Result<Option<RecordBatch>>
pub fn next_batch(&mut self) -> Result<Option<RecordBatch>>
Get the next batch of data as a RecordBatch.
Returns None when iteration is complete.
Sourcepub fn rows_yielded(&self) -> usize
pub fn rows_yielded(&self) -> usize
Get the number of rows yielded so far.
Auto Trait Implementations§
impl !Freeze for StringBatchIterator
impl !RefUnwindSafe for StringBatchIterator
impl Send for StringBatchIterator
impl Sync for StringBatchIterator
impl Unpin for StringBatchIterator
impl !UnwindSafe for StringBatchIterator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more