From 1f816e8c3184ad9f3342eeb4be5e85ff875768cd Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 5 Feb 2019 10:18:31 -0500 Subject: [PATCH] Move serialization helpers out of gRPC namespace --- .../arrow/flight/serialization-internal.cc | 8 ++++-- cpp/src/arrow/flight/serialization-internal.h | 27 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/flight/serialization-internal.cc b/cpp/src/arrow/flight/serialization-internal.cc index f3dbba47255f4..194a7b5bc0c30 100644 --- a/cpp/src/arrow/flight/serialization-internal.cc +++ b/cpp/src/arrow/flight/serialization-internal.cc @@ -17,7 +17,9 @@ #include "arrow/flight/serialization-internal.h" -namespace grpc { +namespace arrow { +namespace flight { +namespace internal { bool ReadBytesZeroCopy(const std::shared_ptr& source_data, CodedInputStream* input, std::shared_ptr* out) { @@ -30,4 +32,6 @@ bool ReadBytesZeroCopy(const std::shared_ptr& source_data, return input->Skip(static_cast(length)); } -} // namespace grpc +} // namespace internal +} // namespace flight +} // namespace arrow diff --git a/cpp/src/arrow/flight/serialization-internal.h b/cpp/src/arrow/flight/serialization-internal.h index 73d15f6bfaf07..d4254d606d40f 100644 --- a/cpp/src/arrow/flight/serialization-internal.h +++ b/cpp/src/arrow/flight/serialization-internal.h @@ -61,17 +61,11 @@ struct FlightData { std::shared_ptr body; }; -} // namespace flight -} // namespace arrow +namespace internal { -namespace grpc { - -using google::protobuf::internal::WireFormatLite; using google::protobuf::io::CodedInputStream; using google::protobuf::io::CodedOutputStream; -using arrow::flight::FlightData; - // More efficient writing of FlightData to gRPC output buffer // Implementation of ZeroCopyOutputStream that writes to a fixed-size buffer class FixedSizeProtoWriter : public ::google::protobuf::io::ZeroCopyOutputStream { @@ -116,7 +110,8 @@ class GrpcBuffer : public arrow::MutableBuffer { grpc_slice_unref(slice_); } - static arrow::Status Wrap(ByteBuffer* cpp_buf, std::shared_ptr* out) { + static arrow::Status Wrap(grpc::ByteBuffer* cpp_buf, + std::shared_ptr* out) { // These types are guaranteed by static assertions in gRPC to have the same // in-memory representation @@ -156,6 +151,22 @@ class GrpcBuffer : public arrow::MutableBuffer { grpc_slice slice_; }; +} // namespace internal + +} // namespace flight +} // namespace arrow + +namespace grpc { + +using arrow::flight::FlightData; +using arrow::flight::internal::FixedSizeProtoWriter; +using arrow::flight::internal::GrpcBuffer; +using arrow::flight::internal::ReadBytesZeroCopy; + +using google::protobuf::internal::WireFormatLite; +using google::protobuf::io::CodedInputStream; +using google::protobuf::io::CodedOutputStream; + // Helper to log status code, as gRPC doesn't expose why // (de)serialization fails inline Status FailSerialization(Status status) {