github.com/segmentio/parquet-go@v0.0.0-20230712180008-5d42db8f0d47/encoding/delta/length_byte_array_purego.go (about)

     1  //go:build purego || !amd64
     2  
     3  package delta
     4  
     5  func encodeByteArrayLengths(lengths []int32, offsets []uint32) {
     6  	for i := range lengths {
     7  		lengths[i] = int32(offsets[i+1] - offsets[i])
     8  	}
     9  }
    10  
    11  func decodeByteArrayLengths(offsets []uint32, lengths []int32) (uint32, int32) {
    12  	lastOffset := uint32(0)
    13  
    14  	for i, n := range lengths {
    15  		if n < 0 {
    16  			return lastOffset, n
    17  		}
    18  		offsets[i] = lastOffset
    19  		lastOffset += uint32(n)
    20  	}
    21  
    22  	offsets[len(lengths)] = lastOffset
    23  	return lastOffset, 0
    24  }