Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Jan 18, 2024
1 parent 01ee1fa commit 5e3c99f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cpp/src/arrow/compute/light_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include <type_traits>

#include "arrow/array/builder_binary.h"
#include "arrow/util/bitmap_ops.h"
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/macros.h"

namespace arrow {
Expand Down Expand Up @@ -576,21 +576,19 @@ Status ExecBatchBuilder::AppendSelected(const std::shared_ptr<ArrayData>& source
// Step 1: calculate target offsets
//
int32_t* offsets = reinterpret_cast<int32_t*>(target->mutable_data(1));
int64_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
int32_t sum = num_rows_before == 0 ? 0 : offsets[num_rows_before];
Visit(source, num_rows_to_append, row_ids,
[&](int i, const uint8_t* ptr, uint32_t num_bytes) {
offsets[num_rows_before + i] = num_bytes;
});
for (int i = 0; i < num_rows_to_append; ++i) {
int32_t length = offsets[num_rows_before + i];
offsets[num_rows_before + i] = static_cast<int32_t>(sum);
if (ARROW_PREDICT_FALSE(sum + length > BinaryBuilder::memory_limit())) {
return Status::Invalid("ExecBatchBuilder cannot contain more than ",
BinaryBuilder::memory_limit(), " bytes, current ", sum,
", appending ", num_rows_before + i + 1,
"-th element of length ", length);
if (ARROW_PREDICT_FALSE(internal::AddWithOverflow(sum, length, &sum))) {
return Status::Invalid("Overflow detected in ExecBatchBuilder when appending ",
num_rows_before + i + 1, "-th element of length ", length,
" bytes to current length ", sum, " bytes");
}
sum += length;
}
offsets[num_rows_before + num_rows_to_append] = static_cast<int32_t>(sum);

Expand Down

0 comments on commit 5e3c99f

Please sign in to comment.