Skip to content

Commit

Permalink
revert a change
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Jun 11, 2024
1 parent 8db6610 commit 805ae8f
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions core/src/parquet/read/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::{marker::PhantomData, mem};
use std::{marker::PhantomData, mem, ptr::copy_nonoverlapping};

use arrow::buffer::Buffer;
use bytes::Buf;
Expand Down Expand Up @@ -440,33 +440,39 @@ impl PlainDictDecoding for BoolType {

// Shared implementation for int variants such as Int8 and Int16
macro_rules! make_int_variant_impl {
($ty: ident, $native_ty: ty) => {
($ty: ident, $native_ty: ty, $type_size: expr) => {
impl PlainDecoding for $ty {
fn decode(src: &mut PlainDecoderInner, dst: &mut ParquetMutableVector, num: usize) {
let src_ptr = src.data.as_ptr() as *const i32;
let dst_ptr = dst.value_buffer.as_mut_ptr() as *mut $native_ty;
unsafe {
for i in 0..num {
dst_ptr
.add(dst.num_values + i)
.write_unaligned(src_ptr.add(src.offset + i).read_unaligned() as $native_ty);
let src_data = &src.data;
let dst_slice = dst.value_buffer.as_slice_mut();
let mut dst_offset = dst.num_values * $type_size;
for _ in 0..num {
unsafe {
copy_nonoverlapping(
&src_data[src.offset..] as *const [u8] as *const u8
as *const $native_ty,
&mut dst_slice[dst_offset] as *mut u8 as *mut $native_ty,
1,
);
}
src.offset += 4; // Parquet stores Int8/Int16 using 4 bytes
dst_offset += $type_size;
}
src.offset += 4 * num;
}

fn skip(src: &mut PlainDecoderInner, num: usize) {
src.offset += 4 * num; // Parquet stores Int8/Int16 using 4 bytes
let num_bytes = 4 * num; // Parquet stores Int8/Int16 using 4 bytes
src.offset += num_bytes;
}
}
};
}

make_int_variant_impl!(Int8Type, i8);
make_int_variant_impl!(UInt8Type, u8);
make_int_variant_impl!(Int16Type, i16);
make_int_variant_impl!(UInt16Type, u16);
make_int_variant_impl!(UInt32Type, u32);
make_int_variant_impl!(Int8Type, i8, 1);
make_int_variant_impl!(UInt8Type, u8, 2);
make_int_variant_impl!(Int16Type, i16, 2);
make_int_variant_impl!(UInt16Type, u16, 4);
make_int_variant_impl!(UInt32Type, u32, 8);

// Shared implementation for variants of Binary type
macro_rules! make_plain_binary_impl {
Expand Down

0 comments on commit 805ae8f

Please sign in to comment.