anoopj commented on code in PR #16747: URL: https://github.com/apache/iceberg/pull/16747#discussion_r3754502044
########## core/src/main/java/org/apache/iceberg/mumbling/BitPacking.java: ########## @@ -0,0 +1,769 @@ +/* + * 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. + */ +package org.apache.iceberg.mumbling; + +import java.nio.ByteBuffer; +import org.apache.iceberg.util.ByteBuffers; + +/** + * Bit packing and unpacking for values of 1–7 bits. + * + * <p>The least-significant bits of each value are packed with the first value occupying the most + * significant bits of the output. Output is padded to the nearest byte with 0s. For example, + * packing values [0b11, 0b10, 0b01] with width 2 produces 0b11100100. + */ +class BitPacking { + + private BitPacking() {} + + /** + * Packs {@code width} least-significant bits of {@code count} values into a data buffer. + * + * <p>Output is padded to the nearest byte with 0s. + * + * <p>Values are written to the buffer's underlying storage, but the buffer's position and limit + * are not modified. + * + * @param width number of bits of each value to pack + * @param values array containing source values to pack + * @param valueOffset starting index of values to pack + * @param data an output {@link ByteBuffer} + * @param dataOffset starting index for output in the data buffer + * @param count the number of values to pack + * @return the number of bytes written to the data buffer + */ + static int packBits( Review Comment: @rdblue The bitpacking unroll code here is very complex (~700+ lines of dense code and hard to review). I have a couple of questions: 1. Does this have any impact on disk or memory footprint? Or is it purely about improving decoding speed? 2. If it's the latter, how much of a CPU impact does it make, given that our descriptor arrays tend to be small (hundreds of bytes)? I can see it will make a difference on larger arrays, which is not our use case for manifest DVs. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
