hcrosse commented on code in PR #1728:
URL: https://github.com/apache/arrow-go/pull/1728#discussion_r4805458925


##########
parquet/internal/encoding/types.go:
##########
@@ -315,10 +315,11 @@ func (b *PooledBufferWriter) Bytes() []byte {
 
 // Len provides the current Length of the byte slice
 func (b *PooledBufferWriter) Len() int {
-       if b.buf.Len() < b.pos {
-               b.buf.ResizeNoShrink(b.pos)
+       bufLen := 0
+       if b.buf != nil {
+               bufLen = b.buf.Len()
        }
-       return b.buf.Len() - b.offset
+       return max(bufLen, b.pos) - b.offset
 }

Review Comment:
   `SetOffset` shifts the write position by the offset delta and resets keep 
both at zero, so `pos` is never below `offset` and the difference stays 
non-negative. The returned value matches the previous length calculation 
without mutating the underlying buffer on read.



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