Browse Source

Use cleaner `__from_elem` `avec` constructor

tags/v0.3.0^2
haixuanTao 2 years ago
parent
commit
e45975f65a
4 changed files with 7 additions and 17 deletions
  1. +2
    -5
      apis/python/operator/src/lib.rs
  2. +2
    -4
      apis/rust/node/src/node/mod.rs
  3. +2
    -4
      binaries/runtime/src/operator/python.rs
  4. +1
    -4
      binaries/runtime/src/operator/shared_lib.rs

+ 2
- 5
apis/python/operator/src/lib.rs View File

@@ -151,7 +151,7 @@ pub fn metadata_to_pydict<'a>(metadata: &'a Metadata, py: Python<'a>) -> &'a PyD
mod tests {
use std::sync::Arc;

use aligned_vec::{avec, AVec, ConstAlign};
use aligned_vec::{AVec, ConstAlign};
use arrow::{
array::{
ArrayData, ArrayRef, BooleanArray, Float64Array, Int32Array, Int64Array, Int8Array,
@@ -169,10 +169,7 @@ mod tests {

fn assert_roundtrip(arrow_array: &ArrayData) -> Result<()> {
let size = required_data_size(arrow_array);
let mut sample: AVec<u8, ConstAlign<128>> = AVec::new(128);
for _ in 0..size {
sample.push(0);
}
let mut sample: AVec<u8, ConstAlign<128>> = AVec::__from_elem(128, 0, size);

let info = copy_array_into_sample(&mut sample, arrow_array)?;



+ 2
- 4
apis/rust/node/src/node/mod.rs View File

@@ -257,10 +257,8 @@ impl DoraNode {
len: data_len,
}
} else {
let mut avec: AVec<u8, ConstAlign<128>> = AVec::new(128);
for _ in 0..data_len {
avec.push(0);
}
let avec: AVec<u8, ConstAlign<128>> = AVec::__from_elem(128, 0, data_len);

avec.into()
};



+ 2
- 4
binaries/runtime/src/operator/python.rs View File

@@ -312,10 +312,8 @@ mod callback_impl {
.wrap_err("failed to request output sample")?
.wrap_err("failed to allocate output sample")
} else {
let mut avec: AVec<u8, ConstAlign<128>> = AVec::new(128);
for _ in 0..data_len {
avec.push(0);
}
let avec: AVec<u8, ConstAlign<128>> = AVec::__from_elem(128, 0, data_len);

Ok(avec.into())
}
};


+ 1
- 4
binaries/runtime/src/operator/shared_lib.rs View File

@@ -134,10 +134,7 @@ impl<'lib> SharedLibraryOperator<'lib> {
};

let total_len = required_data_size(&arrow_array);
let mut sample: AVec<u8, ConstAlign<128>> = AVec::new(128);
for _ in 0..total_len {
sample.push(0);
}
let mut sample: AVec<u8, ConstAlign<128>> = AVec::__from_elem(128, 0, total_len);

let type_info = match copy_array_into_sample(&mut sample, &arrow_array) {
Ok(t) => t,


Loading…
Cancel
Save