From f98de481ac84972e28461148f2805dadfdf5ea98 Mon Sep 17 00:00:00 2001 From: pegasas <616672335@qq.com> Date: Sun, 30 Jul 2023 17:07:17 +0800 Subject: [PATCH] [C++] Use anonymous namespace in arrow/IPC/reader.cc --- cpp/src/arrow/ipc/reader.cc | 78 ++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/cpp/src/arrow/ipc/reader.cc b/cpp/src/arrow/ipc/reader.cc index eadba69f05612..442c1ce6a2489 100644 --- a/cpp/src/arrow/ipc/reader.cc +++ b/cpp/src/arrow/ipc/reader.cc @@ -109,8 +109,6 @@ Status InvalidMessageType(MessageType expected, MessageType actual) { } \ } while (0) -} // namespace - // ---------------------------------------------------------------------- // Record batch read path @@ -643,27 +641,6 @@ static Status ReadContiguousPayload(io::InputStream* file, return Status::OK(); } -Result> ReadRecordBatch( - const std::shared_ptr& schema, const DictionaryMemo* dictionary_memo, - const IpcReadOptions& options, io::InputStream* file) { - std::unique_ptr message; - RETURN_NOT_OK(ReadContiguousPayload(file, &message)); - CHECK_HAS_BODY(*message); - ARROW_ASSIGN_OR_RAISE(auto reader, Buffer::GetReader(message->body())); - return ReadRecordBatch(*message->metadata(), schema, dictionary_memo, options, - reader.get()); -} - -Result> ReadRecordBatch( - const Message& message, const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, const IpcReadOptions& options) { - CHECK_MESSAGE_TYPE(MessageType::RECORD_BATCH, message.type()); - CHECK_HAS_BODY(message); - ARROW_ASSIGN_OR_RAISE(auto reader, Buffer::GetReader(message.body())); - return ReadRecordBatch(*message.metadata(), schema, dictionary_memo, options, - reader.get()); -} - Result ReadRecordBatchInternal( const Buffer& metadata, const std::shared_ptr& schema, const std::vector& inclusion_mask, IpcReadContext& context, @@ -764,22 +741,6 @@ Status UnpackSchemaMessage(const Message& message, const IpcReadOptions& options out_schema, field_inclusion_mask, swap_endian); } -Result> ReadRecordBatch( - const Buffer& metadata, const std::shared_ptr& schema, - const DictionaryMemo* dictionary_memo, const IpcReadOptions& options, - io::RandomAccessFile* file) { - std::shared_ptr out_schema; - // Empty means do not use - std::vector inclusion_mask; - IpcReadContext context(const_cast(dictionary_memo), options, false); - RETURN_NOT_OK(GetInclusionMaskAndOutSchema(schema, context.options.included_fields, - &inclusion_mask, &out_schema)); - ARROW_ASSIGN_OR_RAISE( - auto batch_and_custom_metadata, - ReadRecordBatchInternal(metadata, schema, inclusion_mask, context, file)); - return batch_and_custom_metadata.batch; -} - Status ReadDictionary(const Buffer& metadata, const IpcReadContext& context, DictionaryKind* kind, io::RandomAccessFile* file) { const flatbuf::Message* message = nullptr; @@ -851,6 +812,45 @@ Status ReadDictionary(const Message& message, const IpcReadContext& context, return ReadDictionary(*message.metadata(), context, kind, reader.get()); } +} // namespace + +Result> ReadRecordBatch( + const Buffer& metadata, const std::shared_ptr& schema, + const DictionaryMemo* dictionary_memo, const IpcReadOptions& options, + io::RandomAccessFile* file) { + std::shared_ptr out_schema; + // Empty means do not use + std::vector inclusion_mask; + IpcReadContext context(const_cast(dictionary_memo), options, false); + RETURN_NOT_OK(GetInclusionMaskAndOutSchema(schema, context.options.included_fields, + &inclusion_mask, &out_schema)); + ARROW_ASSIGN_OR_RAISE( + auto batch_and_custom_metadata, + ReadRecordBatchInternal(metadata, schema, inclusion_mask, context, file)); + return batch_and_custom_metadata.batch; +} + +Result> ReadRecordBatch( + const std::shared_ptr& schema, const DictionaryMemo* dictionary_memo, + const IpcReadOptions& options, io::InputStream* file) { + std::unique_ptr message; + RETURN_NOT_OK(ReadContiguousPayload(file, &message)); + CHECK_HAS_BODY(*message); + ARROW_ASSIGN_OR_RAISE(auto reader, Buffer::GetReader(message->body())); + return ReadRecordBatch(*message->metadata(), schema, dictionary_memo, options, + reader.get()); +} + +Result> ReadRecordBatch( + const Message& message, const std::shared_ptr& schema, + const DictionaryMemo* dictionary_memo, const IpcReadOptions& options) { + CHECK_MESSAGE_TYPE(MessageType::RECORD_BATCH, message.type()); + CHECK_HAS_BODY(message); + ARROW_ASSIGN_OR_RAISE(auto reader, Buffer::GetReader(message.body())); + return ReadRecordBatch(*message.metadata(), schema, dictionary_memo, options, + reader.get()); +} + // Streaming format decoder class StreamDecoderInternal : public MessageDecoderListener { public: