pub struct ListBatchIterator { /* private fields */ }Expand description
Iterator for scanning Redis lists in batches as Arrow RecordBatches.
This iterator fetches list keys matching a pattern and retrieves their elements, converting them to Arrow RecordBatches for use with Polars. Each element becomes a row in the output.
§Example
ⓘ
use polars_redis::{ListBatchIterator, ListSchema, BatchConfig};
let schema = ListSchema::new().with_key(true).with_position(true);
let config = BatchConfig::new("queue:*").with_batch_size(1000);
let mut iterator = ListBatchIterator::new(url, schema, config)?;
while let Some(batch) = iterator.next_batch()? {
println!("Got {} elements", batch.num_rows());
}§Output Schema
_key(optional): The Redis keyelement: The list element value (Utf8)position(optional): The element’s position in the list (Int64)
Implementations§
Source§impl ListBatchIterator
impl ListBatchIterator
Sourcepub fn new(url: &str, schema: ListSchema, config: BatchConfig) -> Result<Self>
pub fn new(url: &str, schema: ListSchema, config: BatchConfig) -> Result<Self>
Create a new ListBatchIterator.
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.
Sourcepub fn rows_yielded(&self) -> usize
pub fn rows_yielded(&self) -> usize
Get the number of rows (elements) yielded so far.
Auto Trait Implementations§
impl !Freeze for ListBatchIterator
impl !RefUnwindSafe for ListBatchIterator
impl Send for ListBatchIterator
impl Sync for ListBatchIterator
impl Unpin for ListBatchIterator
impl !UnwindSafe for ListBatchIterator
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