Skip to content

Commit

Permalink
apacheGH-38090: [C++][Emscripten] arrow: Suppress shorten-64-to-32 wa…
Browse files Browse the repository at this point in the history
…rnings

We need explicit cast to use `int64_t` for `size_t` on Emscripten.

Explicit casts.
  • Loading branch information
kou committed Oct 7, 2023
1 parent 3697bcd commit 9ed66b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cpp/src/arrow/scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ struct ScalarHashImpl {
// We can't visit values without unboxing the whole array, so only hash
// the null bitmap for now. Only hash the null bitmap if the null count
// is not 0 to ensure hash consistency.
hash_ = internal::ComputeBitmapHash(validity, /*seed=*/hash_,
/*bits_offset=*/offset, /*num_bits=*/length);
hash_ = static_cast<size_t>(internal::ComputeBitmapHash(validity, /*seed=*/hash_,
/*bits_offset=*/offset,
/*num_bits=*/length));
}

// Hash the relevant child arrays for each type taking offset and length
Expand Down Expand Up @@ -791,7 +792,7 @@ struct MakeNullImpl {
ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Buffer> value,
AllocateBuffer(type.byte_width()));
// Avoid exposing past memory contents
memset(value->mutable_data(), 0, value->size());
memset(value->mutable_data(), 0, static_cast<size_t>(value->size()));
out_ = std::make_shared<FixedSizeBinaryScalar>(std::move(value), type_,
/*is_valid=*/false);
return Status::OK();
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/arrow/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,8 @@ std::string NullType::ToString() const { return name(); }
// FieldPath

size_t FieldPath::hash() const {
return internal::ComputeStringHash<0>(indices().data(), indices().size() * sizeof(int));
return static_cast<size_t>(
internal::ComputeStringHash<0>(indices().data(), indices().size() * sizeof(int)));
}

std::string FieldPath::ToString() const {
Expand Down Expand Up @@ -1423,7 +1424,7 @@ void FieldRef::Flatten(std::vector<FieldRef> children) {
if (n_indices == 0) {
return;
} else if (n_indices > 0) {
std::vector<int> indices(n_indices);
std::vector<int> indices(static_cast<size_t>(n_indices));
auto out_indices = indices.begin();
for (const auto& child : flattened_children) {
for (int index : *child.field_path()) {
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/arrow/visit_data_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ struct ArraySpanInlineVisitor<T, enable_if_base_binary<T>> {
arr.buffers[0].data, arr.offset, arr.length,
[&](int64_t i) {
ARROW_UNUSED(i);
auto value = std::string_view(data + cur_offset, *offsets - cur_offset);
auto value = std::string_view(data + cur_offset,
static_cast<size_t>(*offsets - cur_offset));
cur_offset = *offsets++;
return valid_func(value);
},
Expand Down Expand Up @@ -137,7 +138,7 @@ struct ArraySpanInlineVisitor<T, enable_if_base_binary<T>> {
arr.buffers[0].data, arr.offset, arr.length,
[&](int64_t i) {
auto value = std::string_view(reinterpret_cast<const char*>(data + offsets[i]),
offsets[i + 1] - offsets[i]);
static_cast<size_t>(offsets[i + 1] - offsets[i]));
valid_func(value);
},
std::forward<NullFunc>(null_func));
Expand Down

0 comments on commit 9ed66b0

Please sign in to comment.