rok commented on code in PR #14341:
URL: https://github.com/apache/arrow/pull/14341#discussion_r1158125248
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3177,8 +3194,7 @@ void DeltaByteArrayEncoder<DType>::Put(const T* src, int
num_values) {
::arrow::stl::allocator<int32_t>(pool_));
std::string_view last_value_view = last_value_;
- int i = 0;
- while (i < num_values) {
+ for (int i = 0; i < num_values; i++) {
Review Comment:
Added generic function that throws and changed the comments a little bit.
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3187,21 +3203,74 @@ void DeltaByteArrayEncoder<DType>::Put(const T* src,
int num_values) {
auto view = string_view{reinterpret_cast<const char*>(value->ptr),
value->len};
uint32_t j = 0;
- while (j < std::min(value->len,
static_cast<uint32_t>(last_value_view.length()))) {
+ const uint32_t common_length =
+ std::min(value->len, static_cast<uint32_t>(last_value_view.length()));
+ while (j < common_length) {
if (last_value_view[j] != view[j]) {
break;
}
j++;
}
+ last_value_view = view;
prefix_lengths[i] = j;
- const uint8_t* suffix_ptr = value->ptr + j;
- const uint32_t suffix_length = static_cast<uint32_t>(value->len - j);
+ const auto suffix_length = static_cast<uint32_t>(value->len - j);
+ const uint8_t* suffix_ptr;
+ if (suffix_length == 0) {
+ suffix_ptr = reinterpret_cast<const uint8_t*>("");
Review Comment:
Changed.
--
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]