MCPcopy Create free account
hub / github.com/apache/impala / SerializeToSidecar

Method SerializeToSidecar

be/src/rpc/sidecar-util.h:48–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 /// object is compressed.
47 template <typename TCompressed = void, typename T>
48 Status SerializeToSidecar(const T* obj, kudu::rpc::RpcController* rpc_controller,
49 int* sidecar_idx, bool* is_compressed = nullptr) {
50 uint8_t* buf = nullptr;
51 uint32_t len = 0;
52 RETURN_IF_ERROR(serializer_.SerializeToBuffer(obj, &len, &buf));
53
54 if (is_compressed != nullptr) *is_compressed = false;
55
56 if constexpr (!std::is_same_v<TCompressed, void>) {
57 // Compression path.
58 if (compress_threshold_bytes_ > 0 && len > compress_threshold_bytes_) {
59 // NOTE: 'buf' points to the serializer's internal buffer.
60 // Ensure 'buf' is fully consumed into a compressed thrift in
61 // CreateCompressedThrift() before the next call to SerializeToBuffer()
62 // that could reset or reuse the serializer buffer.
63 TCompressed compressed_obj;
64 RETURN_IF_ERROR(CreateCompressedThrift<TCompressed>(buf, len, &compressed_obj));
65 RETURN_IF_ERROR(serializer_.SerializeToBuffer(&compressed_obj, &len, &buf));
66 if (is_compressed != nullptr) *is_compressed = true;
67 }
68 }
69
70 std::unique_ptr<kudu::rpc::RpcSidecar> rpc_sidecar =
71 kudu::rpc::RpcSidecar::FromSlice(kudu::Slice(buf, len));
72 KUDU_RETURN_IF_ERROR(
73 rpc_controller->AddOutboundSidecar(std::move(rpc_sidecar), sidecar_idx),
74 "Failed to add sidecar");
75 return Status::OK();
76 }
77
78 private:
79 ThriftSerializer serializer_;

Callers

nothing calls this directly

Calls 5

moveFunction · 0.85
OKFunction · 0.85
SerializeToBufferMethod · 0.80
SliceClass · 0.50
AddOutboundSidecarMethod · 0.45

Tested by

no test coverage detected