datatypes::vectors::operations

Trait VectorOp

Source
pub trait VectorOp {
    // Required methods
    fn replicate(&self, offsets: &[usize]) -> VectorRef;
    fn find_unique(
        &self,
        selected: &mut BitVec,
        prev_vector: Option<&dyn Vector>,
    );
    fn filter(&self, filter: &BooleanVector) -> Result<VectorRef>;
    fn cast(&self, to_type: &ConcreteDataType) -> Result<VectorRef>;
    fn take(&self, indices: &UInt32Vector) -> Result<VectorRef>;
}
Expand description

Vector compute operations.

Required Methods§

Source

fn replicate(&self, offsets: &[usize]) -> VectorRef

Copies each element according offsets parameter.

  • i-th element should be copied offsets[i] - offsets[i - 1] times
  • 0-th element would be copied offsets[0] times
§Panics

Panics if offsets.len() != self.len().

Source

fn find_unique(&self, selected: &mut BitVec, prev_vector: Option<&dyn Vector>)

Mark i-th bit of selected to true if the i-th element of self is unique, which means there is no elements behind it have same value as it.

The caller should ensure

  1. the length of selected bitmap is equal to vector.len().
  2. vector and prev_vector are sorted.

If there are multiple duplicate elements, this function retains the first element. The first element is considered as unique if the first element of self is different from its previous element, that is the last element of prev_vector.

§Panics

Panics if

  • selected.len() < self.len().
  • prev_vector and self have different data types.
Source

fn filter(&self, filter: &BooleanVector) -> Result<VectorRef>

Filters the vector, returns elements matching the filter (i.e. where the values are true).

Note that the nulls of filter are interpreted as false will lead to these elements being masked out.

Source

fn cast(&self, to_type: &ConcreteDataType) -> Result<VectorRef>

Cast vector to the provided data type and return a new vector with type to_type, if possible.

TODO(dennis) describe behaviors in details.

Source

fn take(&self, indices: &UInt32Vector) -> Result<VectorRef>

Take elements from the vector by the given indices.

§Panics

Panics if an index is out of bounds.

Implementors§