mapleFU commented on code in PR #37112:
URL: https://github.com/apache/arrow/pull/37112#discussion_r1293843473
##########
go/parquet/internal/utils/bit_writer.go:
##########
@@ -74,18 +79,19 @@ type BitWriter struct {
// NewBitWriter initializes a new bit writer to write to the passed in
interface
// using WriteAt to write the appropriate offsets and values.
-func NewBitWriter(w io.WriterAt) *BitWriter {
+func NewBitWriter(w WriterAtWithLen) *BitWriter {
return &BitWriter{wr: w}
}
-// ReserveBytes reserves the next aligned nbytes, skipping them and returning
+// SkipBytes reserves the next aligned nbytes, skipping them and returning
// the offset to use with WriteAt to write to those reserved bytes. Used for
// RLE encoding to fill in the indicators after encoding.
-func (b *BitWriter) ReserveBytes(nbytes int) int {
+func (b *BitWriter) SkipBytes(nbytes int) (int, error) {
b.Flush(true)
ret := b.byteoffset
b.byteoffset += nbytes
- return ret
+ b.wr.Reserve(b.byteoffset)
Review Comment:
Yeah I know what you mean. Assume that we want we `SkipBytes(4)`, and
`b.byteoffset = 1024`.
1. `b.byteoffset = 1024 + 4`
2. `b.wr.Reserve(1028)`
3. dispatch to `PooledBufferWriter.Reserve(1028)`
4. `newCap: at lease 1024 + 1028`
I just want to make sure that in (4), would it better be `newCap: 1028`?
##########
go/parquet/internal/utils/bit_writer.go:
##########
@@ -74,18 +79,19 @@ type BitWriter struct {
// NewBitWriter initializes a new bit writer to write to the passed in
interface
// using WriteAt to write the appropriate offsets and values.
-func NewBitWriter(w io.WriterAt) *BitWriter {
+func NewBitWriter(w WriterAtWithLen) *BitWriter {
return &BitWriter{wr: w}
}
-// ReserveBytes reserves the next aligned nbytes, skipping them and returning
+// SkipBytes reserves the next aligned nbytes, skipping them and returning
// the offset to use with WriteAt to write to those reserved bytes. Used for
// RLE encoding to fill in the indicators after encoding.
-func (b *BitWriter) ReserveBytes(nbytes int) int {
+func (b *BitWriter) SkipBytes(nbytes int) (int, error) {
b.Flush(true)
ret := b.byteoffset
b.byteoffset += nbytes
- return ret
+ b.wr.Reserve(b.byteoffset)
Review Comment:
Yeah I know what you mean. Assume that we want we `SkipBytes(4)`, and
`b.byteoffset = 1024`.
1. `b.byteoffset = 1024 + 4`
2. `b.wr.Reserve(1028)`
3. dispatch to `PooledBufferWriter.Reserve(1028)`
4. `newCap: at lease 1024 + 1028`
I just want to make sure that in (4), would it better be `newCap: at least
1028`?
--
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]