Skip to content

Commit

Permalink
Move serialization helpers out of gRPC namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
David Li authored and David Li committed Feb 5, 2019
1 parent 21b315a commit 1f816e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
8 changes: 6 additions & 2 deletions cpp/src/arrow/flight/serialization-internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#include "arrow/flight/serialization-internal.h"

namespace grpc {
namespace arrow {
namespace flight {
namespace internal {

bool ReadBytesZeroCopy(const std::shared_ptr<arrow::Buffer>& source_data,
CodedInputStream* input, std::shared_ptr<arrow::Buffer>* out) {
Expand All @@ -30,4 +32,6 @@ bool ReadBytesZeroCopy(const std::shared_ptr<arrow::Buffer>& source_data,
return input->Skip(static_cast<int>(length));
}

} // namespace grpc
} // namespace internal
} // namespace flight
} // namespace arrow
27 changes: 19 additions & 8 deletions cpp/src/arrow/flight/serialization-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,11 @@ struct FlightData {
std::shared_ptr<Buffer> 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 {
Expand Down Expand Up @@ -116,7 +110,8 @@ class GrpcBuffer : public arrow::MutableBuffer {
grpc_slice_unref(slice_);
}

static arrow::Status Wrap(ByteBuffer* cpp_buf, std::shared_ptr<arrow::Buffer>* out) {
static arrow::Status Wrap(grpc::ByteBuffer* cpp_buf,
std::shared_ptr<arrow::Buffer>* out) {
// These types are guaranteed by static assertions in gRPC to have the same
// in-memory representation

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1f816e8

Please sign in to comment.