Skip to content

Commit

Permalink
GH-38090: [C++][Emscripten] orc: Suppress shorten-64-to-32 warnings (#…
Browse files Browse the repository at this point in the history
…38097)

### Rationale for this change

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

### What changes are included in this PR?

Explicit casts.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* Closes: #38090

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Oct 7, 2023
1 parent 3697bcd commit 839137e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cpp/src/arrow/adapters/orc/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ORCFileReader::Impl {

Status Init() {
int64_t nstripes = reader_->getNumberOfStripes();
stripes_.resize(nstripes);
stripes_.resize(static_cast<size_t>(nstripes));
std::unique_ptr<liborc::StripeInformation> stripe;
uint64_t first_row_of_stripe = 0;
for (int i = 0; i < nstripes; ++i) {
Expand All @@ -222,7 +222,9 @@ class ORCFileReader::Impl {

int64_t NumberOfRows() { return static_cast<int64_t>(reader_->getNumberOfRows()); }

StripeInformation GetStripeInformation(int64_t stripe) { return stripes_[stripe]; }
StripeInformation GetStripeInformation(int64_t stripe) {
return stripes_[static_cast<size_t>(stripe)];
}

FileVersion GetFileVersion() {
liborc::FileVersion orc_file_version = reader_->getFormatVersion();
Expand Down Expand Up @@ -365,7 +367,7 @@ class ORCFileReader::Impl {
liborc::RowReaderOptions opts = default_row_reader_options();
RETURN_NOT_OK(SelectStripe(&opts, stripe));
ARROW_ASSIGN_OR_RAISE(auto schema, ReadSchema(opts));
return ReadBatch(opts, schema, stripes_[stripe].num_rows);
return ReadBatch(opts, schema, stripes_[static_cast<size_t>(stripe)].num_rows);
}

Result<std::shared_ptr<RecordBatch>> ReadStripe(
Expand All @@ -374,7 +376,7 @@ class ORCFileReader::Impl {
RETURN_NOT_OK(SelectIndices(&opts, include_indices));
RETURN_NOT_OK(SelectStripe(&opts, stripe));
ARROW_ASSIGN_OR_RAISE(auto schema, ReadSchema(opts));
return ReadBatch(opts, schema, stripes_[stripe].num_rows);
return ReadBatch(opts, schema, stripes_[static_cast<size_t>(stripe)].num_rows);
}

Result<std::shared_ptr<RecordBatch>> ReadStripe(
Expand All @@ -383,15 +385,15 @@ class ORCFileReader::Impl {
RETURN_NOT_OK(SelectNames(&opts, include_names));
RETURN_NOT_OK(SelectStripe(&opts, stripe));
ARROW_ASSIGN_OR_RAISE(auto schema, ReadSchema(opts));
return ReadBatch(opts, schema, stripes_[stripe].num_rows);
return ReadBatch(opts, schema, stripes_[static_cast<size_t>(stripe)].num_rows);
}

Status SelectStripe(liborc::RowReaderOptions* opts, int64_t stripe) {
ARROW_RETURN_IF(stripe < 0 || stripe >= NumberOfStripes(),
Status::Invalid("Out of bounds stripe: ", stripe));

opts->range(static_cast<uint64_t>(stripes_[stripe].offset),
static_cast<uint64_t>(stripes_[stripe].length));
opts->range(static_cast<uint64_t>(stripes_[static_cast<size_t>(stripe)].offset),
static_cast<uint64_t>(stripes_[static_cast<size_t>(stripe)].length));
return Status::OK();
}

Expand Down

0 comments on commit 839137e

Please sign in to comment.