Skip to main content

MockVectorReader

Struct MockVectorReader 

Source
pub struct MockVectorReader { /* private fields */ }
Expand description

An in-memory mock input vector for testing update and scan callbacks.

Construct from typed slices using the convenience constructors, then call row_count(), is_valid(), and try_get_*() in your callback logic, matching the method names used in real DuckDB callbacks.

§Example

use quack_rs::testing::{MockVectorReader, MockDuckValue};

let reader = MockVectorReader::from_i64s([Some(10), None, Some(30)]);
assert_eq!(reader.row_count(), 3);
assert!(reader.is_valid(0));
assert!(!reader.is_valid(1));
assert_eq!(reader.try_get_i64(0), Some(10));
assert_eq!(reader.try_get_i64(1), None); // NULL row
assert_eq!(reader.try_get_i64(2), Some(30));

Implementations§

Source§

impl MockVectorReader

Source

pub fn new(rows: impl IntoIterator<Item = Option<MockDuckValue>>) -> Self

Creates a reader from an arbitrary sequence of Option<MockDuckValue>.

None entries represent NULL rows.

Source

pub fn from_i64s(values: impl IntoIterator<Item = Option<i64>>) -> Self

Creates a reader from a sequence of Option<i64> values.

Convenience constructor for BIGINT columns.

Source

pub fn from_i32s(values: impl IntoIterator<Item = Option<i32>>) -> Self

Creates a reader from a sequence of Option<i32> values.

Convenience constructor for INTEGER columns.

Source

pub fn from_f64s(values: impl IntoIterator<Item = Option<f64>>) -> Self

Creates a reader from a sequence of Option<f64> values.

Convenience constructor for DOUBLE columns.

Source

pub fn from_bools(values: impl IntoIterator<Item = Option<bool>>) -> Self

Creates a reader from a sequence of Option<bool> values.

Convenience constructor for BOOLEAN columns.

Source

pub fn from_i8s(values: impl IntoIterator<Item = Option<i8>>) -> Self

Creates a reader from a sequence of Option<i8> values.

Convenience constructor for TINYINT columns.

Source

pub fn from_i16s(values: impl IntoIterator<Item = Option<i16>>) -> Self

Creates a reader from a sequence of Option<i16> values.

Convenience constructor for SMALLINT columns.

Source

pub fn from_u8s(values: impl IntoIterator<Item = Option<u8>>) -> Self

Creates a reader from a sequence of Option<u8> values.

Convenience constructor for UTINYINT columns.

Source

pub fn from_u16s(values: impl IntoIterator<Item = Option<u16>>) -> Self

Creates a reader from a sequence of Option<u16> values.

Convenience constructor for USMALLINT columns.

Source

pub fn from_u32s(values: impl IntoIterator<Item = Option<u32>>) -> Self

Creates a reader from a sequence of Option<u32> values.

Convenience constructor for UINTEGER columns.

Source

pub fn from_u64s(values: impl IntoIterator<Item = Option<u64>>) -> Self

Creates a reader from a sequence of Option<u64> values.

Convenience constructor for UBIGINT columns.

Source

pub fn from_f32s(values: impl IntoIterator<Item = Option<f32>>) -> Self

Creates a reader from a sequence of Option<f32> values.

Convenience constructor for FLOAT columns.

Source

pub fn from_i128s(values: impl IntoIterator<Item = Option<i128>>) -> Self

Creates a reader from a sequence of Option<i128> values.

Convenience constructor for HUGEINT columns.

Source

pub fn from_intervals( values: impl IntoIterator<Item = Option<DuckInterval>>, ) -> Self

Creates a reader from a sequence of Option<DuckInterval> values.

Convenience constructor for INTERVAL columns.

Source

pub fn from_blobs<'a>( values: impl IntoIterator<Item = Option<&'a [u8]>>, ) -> Self

Creates a reader from a sequence of Option<&[u8]> values.

Convenience constructor for BLOB columns.

Source

pub fn from_strs<'a>(values: impl IntoIterator<Item = Option<&'a str>>) -> Self

Creates a reader from a sequence of Option<&str> values.

Convenience constructor for VARCHAR columns.

Source

pub fn row_count(&self) -> usize

Returns the number of rows in this reader.

Source

pub fn is_valid(&self, idx: usize) -> bool

Returns true if row idx is not NULL.

§Panics

Panics if idx is not less than row_count.

Source

pub fn get(&self, idx: usize) -> Option<&MockDuckValue>

Returns the raw value at row idx, or None if it is NULL.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_i64(&self, idx: usize) -> Option<i64>

Returns the BIGINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_i32(&self, idx: usize) -> Option<i32>

Returns the INTEGER value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_f64(&self, idx: usize) -> Option<f64>

Returns the DOUBLE value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_bool(&self, idx: usize) -> Option<bool>

Returns the BOOLEAN value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_str(&self, idx: usize) -> Option<&str>

Returns the VARCHAR value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_interval(&self, idx: usize) -> Option<DuckInterval>

Returns the INTERVAL value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_i8(&self, idx: usize) -> Option<i8>

Returns the TINYINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_i16(&self, idx: usize) -> Option<i16>

Returns the SMALLINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_u8(&self, idx: usize) -> Option<u8>

Returns the UTINYINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_u16(&self, idx: usize) -> Option<u16>

Returns the USMALLINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_u32(&self, idx: usize) -> Option<u32>

Returns the UINTEGER value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_u64(&self, idx: usize) -> Option<u64>

Returns the UBIGINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_f32(&self, idx: usize) -> Option<f32>

Returns the FLOAT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_i128(&self, idx: usize) -> Option<i128>

Returns the HUGEINT value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_blob(&self, idx: usize) -> Option<&[u8]>

Returns the BLOB value at row idx, or None if NULL or wrong type.

§Panics

Panics if idx is not less than row_count.

Source

pub fn try_get_uuid(&self, idx: usize) -> Option<u128>

Returns the UUID’s textual 128 bits at row idx, or None if NULL or wrong type.

Undoes DuckDB’s top-bit flip exactly as VectorReader::read_uuid does. try_get_i128 returns the raw storage.

§Panics

Panics if idx is not less than row_count.

Trait Implementations§

Source§

impl Clone for MockVectorReader

Source§

fn clone(&self) -> MockVectorReader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MockVectorReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.