• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16970635821

14 Aug 2025 04:13PM UTC coverage: 85.882% (-1.8%) from 87.693%
16970635821

Pull #4215

github

web-flow
Merge 5182504a6 into f547cbca5
Pull Request #4215: Ji/vectors

80 of 1729 new or added lines in 38 files covered. (4.63%)

117 existing lines in 25 files now uncovered.

56994 of 66363 relevant lines covered (85.88%)

609331.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/vortex-array/src/pipeline/operators/primitive.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::any::Any;
5
use std::hash::{Hash, Hasher};
6
use std::sync::Arc;
7
use std::task::{Poll, ready};
8

9
use vortex_dtype::{NativePType, match_each_native_ptype};
10
use vortex_error::VortexResult;
11

12
use crate::arrays::{PrimitiveArray, PrimitiveVTable};
13
use crate::pipeline::bits::BitView;
14
use crate::pipeline::buffers::BufferHandle;
15
use crate::pipeline::operators::{BindContext, Operator};
16
use crate::pipeline::types::{Element, VType};
17
use crate::pipeline::view::ViewMut;
18
use crate::pipeline::{Kernel, KernelContext, N};
19
use crate::vtable::PipelineVTable;
20

21
impl PipelineVTable<PrimitiveVTable> for PrimitiveVTable {
NEW
22
    fn to_operator(array: &PrimitiveArray) -> VortexResult<Arc<dyn Operator>> {
×
NEW
23
        Ok(Arc::new(array.clone()))
×
NEW
24
    }
×
25

NEW
26
    fn to_pipeline(array: &PrimitiveArray) -> VortexResult<Box<dyn Kernel>> {
×
NEW
27
        todo!()
×
28
    }
29
}
30

31
impl Operator for PrimitiveArray {
NEW
32
    fn as_any(&self) -> &dyn Any {
×
NEW
33
        self
×
NEW
34
    }
×
35

NEW
36
    fn vtype(&self) -> VType {
×
NEW
37
        VType::Primitive(self.ptype())
×
NEW
38
    }
×
39

NEW
40
    fn children(&self) -> &[Arc<dyn Operator>] {
×
NEW
41
        &[]
×
NEW
42
    }
×
43

NEW
44
    fn with_children(&self, children: Vec<Arc<dyn Operator>>) -> Arc<dyn Operator> {
×
NEW
45
        Arc::new(self.clone())
×
NEW
46
    }
×
47

NEW
48
    fn bind(&self, ctx: &dyn BindContext) -> VortexResult<Box<dyn Kernel>> {
×
NEW
49
        match_each_native_ptype!(self.ptype(), |T| {
×
NEW
50
            Ok(Box::new(PrimitiveKernel::<T> {
×
NEW
51
                buffer: BufferHandle::new(self.buffer()),
×
NEW
52
                offset: 0,
×
NEW
53
            }) as Box<dyn Kernel>)
×
54
        })
NEW
55
    }
×
56
}
57

58
impl Hash for PrimitiveArray {
NEW
59
    fn hash<H: Hasher>(&self, state: &mut H) {
×
NEW
60
        self.byte_buffer().as_ptr().hash(state);
×
NEW
61
        self.ptype().hash(state);
×
NEW
62
    }
×
63
}
64

65
/// A kernel that produces primitive values from a byte buffer.
66
pub struct PrimitiveKernel<T: NativePType> {
67
    buffer: BufferHandle<T>,
68
    offset: usize,
69
}
70

71
impl<T: Element + NativePType> Kernel for PrimitiveKernel<T> {
NEW
72
    fn seek(&mut self, chunk_idx: usize) -> VortexResult<()> {
×
NEW
73
        self.offset = chunk_idx * N;
×
NEW
74
        Ok(())
×
NEW
75
    }
×
76

NEW
77
    fn step(
×
NEW
78
        &mut self,
×
NEW
79
        ctx: &dyn KernelContext,
×
NEW
80
        mask: BitView,
×
NEW
81
        out: &mut ViewMut,
×
NEW
82
    ) -> Poll<VortexResult<()>> {
×
83
        // FIXME(ngates): support mask.
NEW
84
        assert_eq!(mask.true_count(), N, "Mask must have exactly N true bits");
×
85

NEW
86
        let buffer = ready!(self.buffer.get_or_load(ctx))?;
×
NEW
87
        let remaining = buffer.len() - self.offset;
×
88

NEW
89
        if remaining > N {
×
NEW
90
            out.as_slice_mut::<T>()
×
NEW
91
                .copy_from_slice(&buffer[self.offset..][..N]);
×
NEW
92
            self.offset += N;
×
NEW
93
        } else {
×
NEW
94
            out.as_slice_mut::<T>()[..remaining].copy_from_slice(&buffer[self.offset..]);
×
NEW
95
            self.offset += remaining;
×
NEW
96
        }
×
97

NEW
98
        Poll::Ready(Ok(()))
×
NEW
99
    }
×
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc