mapleFU commented on code in PR #37112:
URL: https://github.com/apache/arrow/pull/37112#discussion_r1291616144


##########
go/parquet/internal/utils/bit_writer.go:
##########
@@ -81,11 +81,15 @@ func NewBitWriter(w io.WriterAt) *BitWriter {
 // ReserveBytes 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) ReserveBytes(nbytes int) (int, error) {
        b.Flush(true)
        ret := b.byteoffset
        b.byteoffset += nbytes
-       return ret
+       if _, err := b.wr.WriteAt(b.raw[:nbytes], int64(ret)); err != nil {
+               log.Println(err)
+               return 0, err
+       }

Review Comment:
   @zeroshade I guess a `Reserve` is not enough, maybe it should be "Reserve + 
Advance"
   
   ```go
   // ReserveBytes 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.
   ```
   
   And C++:
   
   ```c++
     /// Get a pointer to the next aligned byte and advance the underlying 
buffer
     /// by num_bytes.
     /// Returns NULL if there was not enough space.
     uint8_t* GetNextBytePtr(int num_bytes = 1);
   
   
   inline uint8_t* BitWriter::GetNextBytePtr(int num_bytes) {
     Flush(/* align */ true);
     DCHECK_LE(byte_offset_, max_bytes_);
     if (byte_offset_ + num_bytes > max_bytes_) return NULL;
     uint8_t* ptr = buffer_ + byte_offset_;
     byte_offset_ += num_bytes;
     return ptr;
   }
   ```
   
   Would it have a better name than `Reserve`? 🤔



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