github.com/parquet-go/parquet-go@v0.21.1-0.20240501160520-b3c3a0c3ed6f/internal/bitpack/unpack.go (about)

     1  package bitpack
     2  
     3  // PaddingInt32 is the padding expected to exist after the end of input buffers
     4  // for the UnpackInt32 algorithm to avoid reading beyond the end of the input.
     5  const PaddingInt32 = 16
     6  
     7  // PaddingInt64 is the padding expected to exist after the end of input buffers
     8  // for the UnpackInt32 algorithm to avoid reading beyond the end of the input.
     9  const PaddingInt64 = 32
    10  
    11  // UnpackInt32 unpacks 32 bit integers from src to dst.
    12  //
    13  // The function unpacked len(dst) integers, it panics if src is too short to
    14  // contain len(dst) values of the given bit width.
    15  func UnpackInt32(dst []int32, src []byte, bitWidth uint) {
    16  	_ = src[:ByteCount(bitWidth*uint(len(dst))+8*PaddingInt32)]
    17  	unpackInt32(dst, src, bitWidth)
    18  }
    19  
    20  // UnpackInt64 unpacks 64 bit integers from src to dst.
    21  //
    22  // The function unpacked len(dst) integers, it panics if src is too short to
    23  // contain len(dst) values of the given bit width.
    24  func UnpackInt64(dst []int64, src []byte, bitWidth uint) {
    25  	_ = src[:ByteCount(bitWidth*uint(len(dst))+8*PaddingInt64)]
    26  	unpackInt64(dst, src, bitWidth)
    27  }