Skip to content

Commit

Permalink
Basic impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Sep 26, 2023
1 parent 5978729 commit 824f808
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cpp/src/parquet/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,9 @@ class DeltaByteArrayDecoderImpl : public DecoderImpl, virtual public TypedDecode
if (ARROW_PREDICT_FALSE(prefix_len_ptr[i] < 0)) {
throw ParquetException("negative prefix length in DELTA_BYTE_ARRAY");
}
if (buffer[i].len == 0 || prefix_len_ptr[i] == 0) {
continue;
}
if (ARROW_PREDICT_FALSE(AddWithOverflow(data_size, prefix_len_ptr[i], &data_size) ||
AddWithOverflow(data_size, buffer[i].len, &data_size))) {
throw ParquetException("excess expansion in DELTA_BYTE_ARRAY");
Expand All @@ -3382,6 +3385,14 @@ class DeltaByteArrayDecoderImpl : public DecoderImpl, virtual public TypedDecode
if (ARROW_PREDICT_FALSE(static_cast<size_t>(prefix_len_ptr[i]) > prefix.length())) {
throw ParquetException("prefix length too large in DELTA_BYTE_ARRAY");
}
if (prefix_len_ptr[i] == 0) {
prefix = std::string_view{buffer[i]};
continue;
}
if (buffer[i].len == 0) {
buffer[i] = prefix;
continue;
}
memcpy(data_ptr, prefix.data(), prefix_len_ptr[i]);
// buffer[i] currently points to the string suffix
memcpy(data_ptr + prefix_len_ptr[i], buffer[i].ptr, buffer[i].len);
Expand Down

0 comments on commit 824f808

Please sign in to comment.