Struct TextArrayV

Source
pub struct TextArrayV {
    pub array: TextArray,
    pub offset: usize,
    /* private fields */
}
Expand description

§TextArrayView

Borrowed, indexable view into a [offset .. offset + len) window of a TextArray.

§Purpose

  • Zero-copy access to contiguous UTF-8 values in either StringArray or CategoricalArray form.
  • Allows null counts for the view to be cached to speed up scans.

§Fields

  • array: the backing TextArray.
  • offset: starting index of the view.
  • len: number of logical elements in the view.
  • null_count: cached Option<usize> of nulls for this range.

§Notes

  • TextArrayV is not thread-safe due to its use of Cell for caching the null count.
  • Use slice to derive smaller views from this one.
  • Use to_text_array to materialise the data.

Fields§

§array: TextArray§offset: usize

Implementations§

Source§

impl TextArrayV

Source

pub fn new(array: TextArray, offset: usize, len: usize) -> Self

Creates a new TextArrayView with the given offset and length.

Examples found in repository?
examples/print_arrays.rs (line 119)
20fn main() {
21    // Numeric (Integer, Float, all sizes)
22    let col_i32 = IntArr::<i32>::from_slice(&[1, 2, 3, 4, 5]);
23    let col_u32 = IntArr::<u32>::from_slice(&[100, 200, 300, 400, 500]);
24    let col_f32 = FltArr::<f32>::from_slice(&[1.1, 2.2, 3.3, 4.4, 5.5]);
25
26    // Boolean with nulls
27    let mut col_bool = BoolArr::from_slice(&[true, false, true, false, true]);
28    col_bool.set_null_mask(Some(Bitmask::from_bools(&[true, true, true, false, true])));
29
30    // String and Dictionary/Categorical
31    let col_str32 = StrArr::from_slice(&["red", "blue", "green", "yellow", "purple"]);
32
33    let col_cat32 = CatArr::<u32>::from_values(
34        ["apple", "banana", "cherry", "banana", "apple"]
35            .iter()
36            .copied(),
37    );
38
39    // Datetime
40    #[cfg(feature = "datetime")]
41    let col_dt32 = DatetimeArray::<i32>::from_slice(
42        &[1000, 2000, 3000, 4000, 5000],
43        Some(minarrow::enums::time_units::TimeUnit::Milliseconds),
44    );
45    #[cfg(feature = "datetime")]
46    let col_dt64 = DatetimeArray::<i64>::from_slice(
47        &[
48            1_000_000_000,
49            2_000_000_000,
50            3_000_000_000,
51            4_000_000_000,
52            5_000_000_000,
53        ],
54        Some(minarrow::enums::time_units::TimeUnit::Nanoseconds),
55    );
56
57    #[cfg(feature = "datetime")]
58    col_dt32.print();
59    #[cfg(feature = "datetime")]
60    println!("\n");
61    #[cfg(feature = "datetime")]
62    col_dt64.print();
63    #[cfg(feature = "datetime")]
64    println!("\n");
65
66    // --- Print NumericArray, TextArray, TemporalArray enums
67    println!("\n--- Enums: NumericArray, TextArray, TemporalArray ---");
68    NumericArray::Int32(Arc::new(col_i32.clone())).print();
69    println!("\n");
70    NumericArray::UInt32(Arc::new(col_u32.clone())).print();
71    println!("\n");
72    NumericArray::Float32(Arc::new(col_f32.clone())).print();
73    println!("\n");
74    TextArray::String32(Arc::new(col_str32.clone())).print();
75    println!("\n");
76    let _ = &TextArray::Categorical32(Arc::new(col_cat32.clone())).print();
77
78    println!("\n/ *** To display as dates, enable the optional 'chrono' feature *** /\n");
79
80    #[cfg(feature = "datetime")]
81    let _ = &TemporalArray::Datetime32(Arc::new(col_dt32.clone())).print();
82    println!("\n");
83    #[cfg(feature = "datetime")]
84    let _ = &TemporalArray::Datetime64(Arc::new(col_dt64.clone())).print();
85    println!("\n");
86
87    println!("\n--- Array (top-level) ---");
88    Array::from_int32(col_i32.clone()).print();
89    println!("\n");
90    Array::from_uint32(col_u32.clone()).print();
91    println!("\n");
92    Array::from_float32(col_f32.clone()).print();
93    println!("\n");
94    Array::from_string32(col_str32.clone()).print();
95    println!("\n");
96    Array::from_categorical32(col_cat32.clone()).print();
97    println!("\n");
98    #[cfg(feature = "datetime")]
99    Array::from_datetime_i32(col_dt32.clone()).print();
100    println!("\n");
101    // --- Print Array Views (ArrayV, NumericArrayV, TextArrayV, TemporalArrayV)
102    #[cfg(feature = "views")]
103    println!("\n--- Array Views ---");
104    #[cfg(feature = "views")]
105    ArrayV::new(Array::from_int32(col_i32.clone()), 1, 3).print();
106
107    let num_arr = NumericArray::Int32(Arc::new(col_i32.clone()));
108    num_arr.print();
109
110    #[cfg(feature = "views")]
111    let num_view = NumericArrayV::new(num_arr, 1, 3);
112    #[cfg(feature = "views")]
113    num_view.print();
114
115    let txt_arr = TextArray::String32(Arc::new(col_str32.clone()));
116    txt_arr.print();
117
118    #[cfg(feature = "views")]
119    let txt_view = TextArrayV::new(txt_arr, 1, 3);
120    #[cfg(feature = "views")]
121    txt_view.print();
122
123    #[cfg(all(feature = "datetime", feature = "views"))]
124    {
125        use minarrow::TemporalArrayV;
126
127        let tmp_arr = TemporalArray::Datetime32(Arc::new(col_dt32.clone()));
128        tmp_arr.print();
129        TemporalArrayV::new(tmp_arr, 1, 3).print();
130    }
131
132    // --- Print Bitmask and BitmaskV
133    println!("\n--- Bitmask & BitmaskV ---");
134    let bm = Bitmask::from_bools(&[true, false, true, true, false]);
135    bm.print();
136    #[cfg(feature = "views")]   
137    BitmaskV::new(bm.clone(), 1, 3).print();
138}
Source

pub fn with_null_count( array: TextArray, offset: usize, len: usize, null_count: usize, ) -> Self

Creates a new TextArrayView with a precomputed null count.

Source

pub fn is_empty(&self) -> bool

Returns true if the view is empty.

Source

pub fn get_str(&self, i: usize) -> Option<&str>

Returns the value at logical index i as an Option<&str>.

Source

pub fn slice(&self, offset: usize, len: usize) -> Self

Returns a sliced view into a subrange of this view.

Source

pub fn len(&self) -> usize

Returns the length of the window

Source

pub fn as_array(&self) -> Array

Returns the underlying array as an Array enum value.

Useful to access its inner methods

Source

pub fn to_text_array(&self) -> TextArray

Returns an owned TextArray clone of the window.

Source

pub fn end(&self) -> usize

Returns the end index of the view.

Source

pub fn as_tuple(&self) -> (TextArray, usize, usize)

Returns the view as a tuple (array, offset, len).

Source

pub fn null_count(&self) -> usize

Returns the number of nulls in the view.

Caches it after the first calculation.

Source

pub fn null_mask_view(&self) -> Option<BitmaskV>

Returns the null mask as a windowed BitmaskView.

Source

pub fn set_null_count(&self, count: usize)

Sets the cached null count for the view.

Trait Implementations§

Source§

impl Clone for TextArrayV

Source§

fn clone(&self) -> TextArrayV

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TextArrayV

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for TextArrayV

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Array> for TextArrayV

Source§

fn from(array: Array) -> Self

Converts to this type from the input type.
Source§

impl From<ArrayV> for TextArrayV

Source§

fn from(view: ArrayV) -> Self

Converts to this type from the input type.
Source§

impl From<TextArray> for TextArrayV

Source§

fn from(array: TextArray) -> Self

Converts to this type from the input type.
Source§

impl From<TextArrayV> for Value

Source§

fn from(v: TextArrayV) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for TextArrayV

Source§

fn eq(&self, other: &TextArrayV) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Value> for TextArrayV

Source§

type Error = MinarrowError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for TextArrayV

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Print for T
where T: Display,

Source§

fn print(&self)
where Self: Display,

Source§

impl<T> ToCompactString for T
where T: Display,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T