alamb commented on code in PR #12470:
URL: https://github.com/apache/arrow-rs/pull/12470#discussion_r4727963528


##########
arrow-bitutils/src/byte_util.rs:
##########
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
+// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) 
under one or more contributor license agreements
+
+//! Utilities for comparing byte slices a word at a time
+
+use std::cmp::Ordering;
+
+/// Returns the number of leading bytes that `a` and `b` have in common
+///
+/// ```
+/// # use arrow_bitutils::byte_util::common_prefix_len;
+/// assert_eq!(common_prefix_len(b"apple", b"apricot"), 2);
+/// assert_eq!(common_prefix_len(b"app", b"apple"), 3);
+/// assert_eq!(common_prefix_len(b"", b"apple"), 0);
+/// ```
+// Out of line so that callers don't inline the scan. It also has to stay a 
leaf: a stack frame

Review Comment:
   this is somewhat confusing -- I think the first sentence is enough



##########
parquet/src/util/bit_util.rs:
##########
@@ -793,32 +794,10 @@ impl BitWriter {
 /// MAX_VLQ_BYTE_LEN = 5 for i32, and MAX_VLQ_BYTE_LEN = 10 for i64
 pub const MAX_VLQ_BYTE_LEN: usize = 10;
 
-/// Counts set bits directly over byte slices, including unaligned endpoints.
-fn count_set_bits(bytes: &[u8], range: std::ops::Range<usize>) -> usize {
+/// Counts the set bits of `bytes` at bit positions `range`
+pub(crate) fn count_set_bits(bytes: &[u8], range: std::ops::Range<usize>) -> 
usize {

Review Comment:
   probably another good one for the bututil crate



##########
arrow-bitutils/src/lib.rs:
##########
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
+// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) 
under one or more contributor license agreements
+
+//! Word-at-a-time bit and byte manipulation primitives shared by the Apache 
Arrow and Parquet

Review Comment:
   It would be sweet to add a brief catalog / categorization of the available 
functions
   
   Like "bit iterator: See `BitChunkIterator`, etc



##########
arrow-bitutils/Cargo.toml:
##########
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
+# SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under 
one or more contributor license agreements
+
+[package]
+name = "arrow-bitutils"
+version = { workspace = true }
+description = "Word-at-a-time bit and byte manipulation primitives shared by 
the Apache Arrow and Parquet crates"

Review Comment:
   i think just something like "Bit / Byte manipulation primitives shared by 
Apache Arrow and Apache Parquet" might be enough



-- 
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