Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't merge] Upgrade the Arrow to 16.1.0 #67

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cpp/src/arrow/adapters/orc/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ class ORCFileReader::Impl {
return Init();
}

virtual liborc::Reader* GetRawORCReader() {
return reader_.get();
}


Status Init() {
int64_t nstripes = reader_->getNumberOfStripes();
stripes_.resize(static_cast<size_t>(nstripes));
Expand Down Expand Up @@ -548,6 +553,10 @@ class ORCFileReader::Impl {
return NextStripeReader(batch_size, empty_vec);
}

liborc::Reader* ORCFileReader::GetRawORCReader() {
return impl_->GetRawORCReader();
}

private:
MemoryPool* pool_;
std::unique_ptr<liborc::Reader> reader_;
Expand All @@ -559,6 +568,15 @@ ORCFileReader::ORCFileReader() { impl_.reset(new ORCFileReader::Impl()); }

ORCFileReader::~ORCFileReader() {}

liborc::Reader* ORCFileReader::GetRawORCReader() {
return impl_->GetRawORCReader();
}

Status ORCFileReader::Open(const std::shared_ptr<io::RandomAccessFile>& file,
MemoryPool* pool, std::unique_ptr<ORCFileReader>* reader) {
return Open(file, pool).Value(reader);
}

Result<std::unique_ptr<ORCFileReader>> ORCFileReader::Open(
const std::shared_ptr<io::RandomAccessFile>& file, MemoryPool* pool) {
#ifdef ARROW_ORC_NEED_TIME_ZONE_DATABASE_CHECK
Expand Down
14 changes: 14 additions & 0 deletions cpp/src/arrow/adapters/orc/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "arrow/type_fwd.h"
#include "arrow/util/macros.h"
#include "arrow/util/visibility.h"
#include "arrow/adapters/orc/adapter_util.h"

namespace arrow {
namespace adapters {
Expand All @@ -53,6 +54,19 @@ class ARROW_EXPORT ORCFileReader {
public:
~ORCFileReader();

/// \brief Creates a new ORC reader.
///
/// \param[in] file the data source
/// \param[in] pool a MemoryPool to use for buffer allocations
/// \param[out] reader the returned reader object
/// \return Status
ARROW_DEPRECATED("Deprecated in 6.0.0. Use Result-returning overload instead.")
static Status Open(const std::shared_ptr<io::RandomAccessFile>& file, MemoryPool* pool,
std::unique_ptr<ORCFileReader>* reader);

/// \brief Get ORC reader from inside.
liborc::Reader* GetRawORCReader();

/// \brief Creates a new ORC reader
///
/// \param[in] file the data source
Expand Down
17 changes: 17 additions & 0 deletions cpp/src/arrow/ipc/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,23 @@ class RecordBatchFileReaderImpl : public RecordBatchFileReader {
return total;
}

Result<int64_t> RecordBatchCountRows(int i) override {
DCHECK_GE(i, 0);
DCHECK_LT(i, num_record_batches());
ARROW_ASSIGN_OR_RAISE(auto outer_message,
ReadMessageFromBlock(GetRecordBatchBlock(i)));
auto metadata = outer_message->metadata();
const flatbuf::Message* message = nullptr;
RETURN_NOT_OK(
internal::VerifyMessage(metadata->data(), metadata->size(), &message));
auto batch = message->header_as_RecordBatch();
if (batch == nullptr) {
return Status::IOError(
"Header-type of flatbuffer-encoded Message is not RecordBatch.");
}
return batch->length();
}

Status Open(const std::shared_ptr<io::RandomAccessFile>& file, int64_t footer_offset,
const IpcReadOptions& options) {
owned_file_ = file;
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/ipc/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class ARROW_EXPORT RecordBatchFileReader
/// \brief Computes the total number of rows in the file.
virtual Result<int64_t> CountRows() = 0;

virtual Result<int64_t> RecordBatchCountRows(int i) = 0;

/// \brief Begin loading metadata for the desired batches into memory.
///
/// This method will also begin loading all dictionaries messages into memory.
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/arrow/util/bit_stream_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ inline void GetValue_(int num_bits, T* v, int max_bytes, const uint8_t* buffer,
#pragma warning(push)
#pragma warning(disable : 4800)
#endif
if (ARROW_PREDICT_FALSE(*bit_offset >= 64)) {
auto msg = std::string("invalid bit offset: ") + std::to_string(*bit_offset);
msg += ", may be malformed num_bits: " + std::to_string(num_bits);
throw std::runtime_error(msg);
}
*v = static_cast<T>(bit_util::TrailingBits(*buffered_values, *bit_offset + num_bits) >>
*bit_offset);
#ifdef _MSC_VER
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/encoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2721,7 +2721,7 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecoder<DTyp
T min_delta_;
uint32_t mini_block_idx_;
std::shared_ptr<ResizableBuffer> delta_bit_widths_;
int delta_bit_width_;
int delta_bit_width_ = 0;

T last_value_;
};
Expand Down
Loading