zeroshade commented on code in PR #38367:
URL: https://github.com/apache/arrow/pull/38367#discussion_r1368867155


##########
go/parquet/internal/encoding/boolean_encoder.go:
##########
@@ -87,3 +89,53 @@ func (enc *PlainBooleanEncoder) FlushValues() (Buffer, 
error) {
 
        return enc.sink.Finish(), nil
 }
+
+type RleBooleanEncoder struct {
+       encoder
+
+       bufferedValues []bool
+}
+
+func (RleBooleanEncoder) Type() parquet.Type {
+       return parquet.Types.Boolean
+}
+
+func (enc *RleBooleanEncoder) Put(in []bool) {
+       enc.bufferedValues = append(enc.bufferedValues, in...)
+}
+
+func (enc *RleBooleanEncoder) PutSpaced(in []bool, validBits []byte, 
validBitsOffset int64) {
+       bufferOut := make([]bool, len(in))
+       nvalid := spacedCompress(in, bufferOut, validBits, validBitsOffset)
+       enc.Put(bufferOut[:nvalid])
+}
+
+func (enc *RleBooleanEncoder) EstimatedDataEncodedSize() int64 {
+       const rleLengthInBytes = 4
+       return rleLengthInBytes + int64(enc.maxRleBufferSize())
+}
+
+func (enc *RleBooleanEncoder) maxRleBufferSize() int {
+       return utils.MaxBufferSize(1, len(enc.bufferedValues))

Review Comment:
   `len(enc.bufferedValues)` is bytes, and this is also what the C++ code 
currently does: 
https://github.com/apache/arrow/blob/1d11df318a7043ec2eaa5984a5daf4ff0890651f/cpp/src/parquet/encoding.cc#L2934
   
   It makes sense since even though it's RLE encoding, we're still encoding the 
booleans as 1 bit per boolean (using bitwidth 1) so a number of bytes equal to 
the number of bool values is definitely going to be the high end estimate worst 
case.



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