@@ -993,11 +993,24 @@ void CheckRoundTrip(const Array& data, int bit_width, bool spaced, int32_t parts
993993 const int data_size = static_cast <int >(data.length ());
994994 const int data_values_count =
995995 static_cast <int >(data.length () - spaced * data.null_count ());
996+ // Note: because of the way RleEncoder::CheckBufferFull()
997+ // is called, we have to reserve an extra "RleEncoder::MinBufferSize"
998+ // bytes. These extra bytes won't be used but not reserving them
999+ // would cause the encoder to fail.
9961000 const int buffer_size =
997- static_cast <int >(RleBitPackedEncoder::MaxBufferSize (bit_width, data_size));
1001+ static_cast <int >(
1002+ ::arrow::util::RleBitPackedEncoder::MaxBufferSize (bit_width, data_values_count) +
1003+ ::arrow::util::RleBitPackedEncoder::MinBufferSize(bit_width));
1004+
9981005 ASSERT_GE (parts, 1 );
9991006 ASSERT_LE (parts, data_size);
10001007
1008+ ARROW_SCOPED_TRACE (" bit_width = " , bit_width, " , spaced = " , spaced, " , data_size = " , data_size,
1009+ " , buffer_size = " , buffer_size);
1010+ ARROW_LOG (INFO) << " bit_width = " <<bit_width << " , data_size = " << data_size
1011+ << " , buffer size = " << buffer_size
1012+ << " , min buffer size = " << RleBitPackedEncoder::MinBufferSize (bit_width);
1013+
10011014 const value_type* data_values = static_cast <const ArrayType&>(data).raw_values ();
10021015
10031016 // Encode the data into `buffer` using the encoder.
@@ -1008,13 +1021,15 @@ void CheckRoundTrip(const Array& data, int bit_width, bool spaced, int32_t parts
10081021 // Depending on `spaced` we treat nulls as regular values.
10091022 if (data.IsValid (i) || !spaced) {
10101023 bool success = encoder.Put (static_cast <uint64_t >(data_values[i]));
1011- ASSERT_TRUE (success) << " Encoding failed in pos " << i;
1024+ ASSERT_TRUE (success) << " Encoding failed in pos " << i << " , current encoder len: " << encoder. len () ;
10121025 ++encoded_values_size;
10131026 }
10141027 }
10151028 int encoded_byte_size = encoder.Flush ();
10161029 ASSERT_EQ (encoded_values_size, data_values_count)
10171030 << " All values input were not encoded successfully by the encoder" ;
1031+ // ARROW_LOG(INFO) << "bit_width = " <<bit_width << ", data_size = " << data_size
1032+ // << ", buffer size = " << buffer_size << ", encoded_byte_size = " << encoded_byte_size;
10181033
10191034 // Now we verify batch read
10201035 RleBitPackedDecoder<value_type> decoder (buffer.data (), encoded_byte_size, bit_width);
0 commit comments