sdf-jkl commented on code in PR #9372:
URL: https://github.com/apache/arrow-rs/pull/9372#discussion_r2875012335


##########
parquet/src/encodings/decoding/alp.rs:
##########
@@ -0,0 +1,1258 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::marker::PhantomData;
+use std::ops::Range;
+
+use bytes::Bytes;
+
+use crate::basic::Encoding;
+use crate::data_type::DataType;
+use crate::encodings::decoding::Decoder;
+use crate::errors::{ParquetError, Result};
+use crate::util::bit_util::{BitReader, FromBytes};
+
+const ALP_HEADER_SIZE: usize = 8;
+const ALP_VERSION: u8 = 1;
+const ALP_COMPRESSION_MODE: u8 = 0;
+const ALP_INTEGER_ENCODING_FOR_BIT_PACK: u8 = 0;
+const ALP_MAX_LOG_VECTOR_SIZE: u8 = 16;
+const ALP_MAX_EXPONENT_F32: u8 = 10;
+const ALP_MAX_EXPONENT_F64: u8 = 18;
+
+/// Page-level ALP header (version 1, 8 bytes).
+///
+/// Layout in bytes:
+/// - `[0]` `version`
+/// - `[1]` `compression_mode`
+/// - `[2]` `integer_encoding`
+/// - `[3]` `log_vector_size`
+/// - `[4..8]` `num_elements` (little-endian `i32`)
+#[derive(Debug, Clone, Copy)]
+struct AlpHeader {
+    version: u8,
+    compression_mode: u8,
+    integer_encoding: u8,
+    log_vector_size: u8,
+    num_elements: i32,
+}
+
+impl AlpHeader {
+    fn num_elements_usize(&self) -> usize {
+        self.num_elements as usize
+    }
+
+    fn vector_size(&self) -> usize {
+        1usize << self.log_vector_size
+    }
+
+    fn num_vectors(&self) -> usize {
+        if self.num_elements == 0 {
+            0
+        } else {
+            self.num_elements_usize().div_ceil(self.vector_size())
+        }
+    }
+
+    fn vector_num_elements(&self, vector_index: usize) -> u16 {
+        let vector_size = self.vector_size();
+        let num_full_vectors = self.num_elements_usize() / vector_size;
+        let remainder = self.num_elements_usize() % vector_size;
+        if vector_index < num_full_vectors {
+            vector_size as u16

Review Comment:
   thanks, I asked a question about this in the original C++ PR - 
https://github.com/apache/arrow/pull/48345#discussion_r2835501958



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to