comphead commented on code in PR #604:
URL: https://github.com/apache/datafusion-comet/pull/604#discussion_r1681579614


##########
native/core/src/parquet/read/values.rs:
##########
@@ -180,63 +182,37 @@ macro_rules! make_plain_dict_impl {
 }
 
 make_plain_dict_impl! { Int8Type, UInt8Type, Int16Type, UInt16Type, Int32Type, 
UInt32Type }
-make_plain_dict_impl! { Int32DateType, Int64Type, FloatType, FLBAType }
+make_plain_dict_impl! { Int32DateType, Int64Type, FloatType, 
Int64ToDecimal64Type, FLBAType }
 make_plain_dict_impl! { DoubleType, Int64TimestampMillisType, 
Int64TimestampMicrosType }
 
-impl PlainDictDecoding for Int32To64Type {
-    fn decode_dict_one(
-        idx: usize,
-        val_idx: usize,
-        src: &ParquetMutableVector,
-        dst: &mut ParquetMutableVector,
-        _: usize,
-    ) {
-        let src_ptr = src.value_buffer.as_ptr() as *const i32;
-        let dst_ptr = dst.value_buffer.as_mut_ptr() as *mut i64;
-        unsafe {
-            dst_ptr
-                .add(idx)
-                .write_unaligned(src_ptr.add(val_idx).read_unaligned() as i64);
-        }
-    }
-}
-
-impl PlainDecoding for FloatToDoubleType {
-    fn decode(src: &mut PlainDecoderInner, dst: &mut ParquetMutableVector, 
num: usize) {
-        let src_ptr = src.data.as_ptr() as *const f32;
-        let dst_ptr = dst.value_buffer.as_mut_ptr() as *mut f64;
-        unsafe {
-            for i in 0..num {
-                dst_ptr
-                    .add(dst.num_values + i)
-                    .write_unaligned(src_ptr.add(src.offset + 
i).read_unaligned() as f64);
+macro_rules! make_int_variant_dict_impl {
+    ($ty:ty, $src_ty:ty, $dst_ty:ty) => {
+        impl PlainDictDecoding for $ty {
+            fn decode_dict_one(
+                idx: usize,
+                val_idx: usize,
+                src: &ParquetMutableVector,
+                dst: &mut ParquetMutableVector,
+                _: usize,
+            ) {
+                let src_ptr = src.value_buffer.as_ptr() as *const $src_ty;
+                let dst_ptr = dst.value_buffer.as_mut_ptr() as *mut $dst_ty;
+                unsafe {
+                    dst_ptr
+                        .add(idx)
+                        .write_unaligned(src_ptr.add(val_idx).read_unaligned() 
as $dst_ty);
+                }
             }
         }
-        src.offset += 4 * num;
-    }
-
-    fn skip(src: &mut PlainDecoderInner, num: usize) {
-        src.offset += 4 * num;
-    }
+    };
 }
 
-impl PlainDictDecoding for FloatToDoubleType {
-    fn decode_dict_one(
-        idx: usize,
-        val_idx: usize,
-        src: &ParquetMutableVector,
-        dst: &mut ParquetMutableVector,
-        _: usize,
-    ) {
-        let src_ptr = src.value_buffer.as_ptr() as *const f32;
-        let dst_ptr = dst.value_buffer.as_mut_ptr() as *mut f64;
-        unsafe {
-            dst_ptr
-                .add(idx)
-                .write_unaligned(src_ptr.add(val_idx).read_unaligned() as f64);
-        }
-    }
-}
+make_int_variant_dict_impl!(Int16ToDoubleType, i16, f64);
+make_int_variant_dict_impl!(Int32To64Type, i32, i64);
+make_int_variant_dict_impl!(Int32ToDecimal64Type, i32, i64);
+make_int_variant_dict_impl!(Int32ToDoubleType, i32, f64);
+make_int_variant_dict_impl!(Int32TimestampMicrosType, i32, i64);

Review Comment:
   Int32 Millis?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to