be/src/util/thrift_util.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <gen_cpp/DataSinks_types.h> |
21 | | #include <gen_cpp/Types_types.h> |
22 | | #include <thrift/TApplicationException.h> |
23 | | #include <thrift/transport/TBufferTransports.h> |
24 | | |
25 | | #include <cstdint> |
26 | | #include <cstring> |
27 | | #include <exception> |
28 | | #include <memory> |
29 | | #include <string> |
30 | | #include <vector> |
31 | | |
32 | | #include "common/status.h" |
33 | | |
34 | | namespace apache::thrift::protocol { |
35 | | class TProtocol; |
36 | | class TProtocolFactory; |
37 | | } // namespace apache::thrift::protocol |
38 | | |
39 | | namespace doris { |
40 | | |
41 | | class TNetworkAddress; |
42 | | class ThriftServer; |
43 | | |
44 | | // Utility class to serialize thrift objects to a binary format. This object |
45 | | // should be reused if possible to reuse the underlying memory. |
46 | | // Note: thrift will encode NULLs into the serialized buffer so it is not valid |
47 | | // to treat it as a string. |
48 | | class ThriftSerializer { |
49 | | public: |
50 | | // If compact, the objects will be serialized using the Compact Protocol. Otherwise, |
51 | | // we'll use the binary protocol. |
52 | | // Note: the deserializer must be matching. |
53 | | ThriftSerializer(bool compact, int initial_buffer_size); |
54 | | |
55 | | // Serializes obj into result. Result will contain a copy of the memory. |
56 | | template <class T> |
57 | | Status serialize(T* obj, std::vector<uint8_t>* result) { |
58 | | uint32_t len = 0; |
59 | | uint8_t* buffer = nullptr; |
60 | | RETURN_IF_ERROR(serialize<T>(obj, &len, &buffer)); |
61 | | result->resize(len); |
62 | | memcpy(result->data(), buffer, len); |
63 | | return Status::OK(); |
64 | | } |
65 | | |
66 | | // serialize obj into a memory buffer. The result is returned in buffer/len. The |
67 | | // memory returned is owned by this object and will be invalid when another object |
68 | | // is serialized. |
69 | | template <class T> |
70 | 161k | Status serialize(T* obj, uint32_t* len, uint8_t** buffer) { |
71 | 161k | try { |
72 | 161k | _mem_buffer->resetBuffer(); |
73 | 161k | obj->write(_protocol.get()); |
74 | 161k | } catch (std::exception& e) { |
75 | 0 | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); |
76 | 0 | } |
77 | | |
78 | 161k | _mem_buffer->getBuffer(buffer, len); |
79 | 161k | return Status::OK(); |
80 | 161k | } _ZN5doris16ThriftSerializer9serializeINS_26TJavaUdfExecutorCtorParamsEEENS_6StatusEPT_PjPPh Line | Count | Source | 70 | 5.68k | Status serialize(T* obj, uint32_t* len, uint8_t** buffer) { | 71 | 5.68k | try { | 72 | 5.68k | _mem_buffer->resetBuffer(); | 73 | 5.68k | obj->write(_protocol.get()); | 74 | 5.68k | } catch (std::exception& e) { | 75 | 0 | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); | 76 | 0 | } | 77 | | | 78 | 5.76k | _mem_buffer->getBuffer(buffer, len); | 79 | 5.76k | return Status::OK(); | 80 | 5.68k | } |
_ZN5doris16ThriftSerializer9serializeINS_12TResultBatchEEENS_6StatusEPT_PjPPh Line | Count | Source | 70 | 156k | Status serialize(T* obj, uint32_t* len, uint8_t** buffer) { | 71 | 156k | try { | 72 | 156k | _mem_buffer->resetBuffer(); | 73 | 156k | obj->write(_protocol.get()); | 74 | 156k | } catch (std::exception& e) { | 75 | 0 | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); | 76 | 0 | } | 77 | | | 78 | 156k | _mem_buffer->getBuffer(buffer, len); | 79 | 156k | return Status::OK(); | 80 | 156k | } |
_ZN5doris16ThriftSerializer9serializeINS_19TRuntimeProfileTreeEEENS_6StatusEPT_PjPPh Line | Count | Source | 70 | 21 | Status serialize(T* obj, uint32_t* len, uint8_t** buffer) { | 71 | 21 | try { | 72 | 21 | _mem_buffer->resetBuffer(); | 73 | 21 | obj->write(_protocol.get()); | 74 | 21 | } catch (std::exception& e) { | 75 | 0 | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); | 76 | 0 | } | 77 | | | 78 | 21 | _mem_buffer->getBuffer(buffer, len); | 79 | 21 | return Status::OK(); | 80 | 21 | } |
|
81 | | |
82 | | template <class T> |
83 | 1.19k | Status serialize(T* obj, std::string* result) { |
84 | 1.19k | try { |
85 | 1.19k | _mem_buffer->resetBuffer(); |
86 | 1.19k | obj->write(_protocol.get()); |
87 | 1.19k | } catch (apache::thrift::TApplicationException& e) { |
88 | 0 | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); |
89 | 0 | } |
90 | | |
91 | 1.24k | *result = _mem_buffer->getBufferAsString(); |
92 | 1.24k | return Status::OK(); |
93 | 1.19k | } |
94 | | |
95 | | template <class T> |
96 | | Status serialize(T* obj) { |
97 | | try { |
98 | | _mem_buffer->resetBuffer(); |
99 | | obj->write(_protocol.get()); |
100 | | } catch (apache::thrift::TApplicationException& e) { |
101 | | return Status::InternalError("Couldn't serialize thrift object:\n{}", e.what()); |
102 | | } |
103 | | |
104 | | return Status::OK(); |
105 | | } |
106 | | |
107 | 0 | void get_buffer(uint8_t** buffer, uint32_t* length) { _mem_buffer->getBuffer(buffer, length); } |
108 | | |
109 | | private: |
110 | | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> _mem_buffer; |
111 | | std::shared_ptr<apache::thrift::protocol::TProtocol> _protocol; |
112 | | }; |
113 | | |
114 | | class ThriftDeserializer { |
115 | | public: |
116 | | ThriftDeserializer(bool compact); |
117 | | |
118 | | private: |
119 | | std::shared_ptr<apache::thrift::protocol::TProtocolFactory> _factory; |
120 | | std::shared_ptr<apache::thrift::protocol::TProtocol> _tproto; |
121 | | }; |
122 | | |
123 | | // Utility to create a protocol (deserialization) object for 'mem'. |
124 | | std::shared_ptr<apache::thrift::protocol::TProtocol> create_deserialize_protocol( |
125 | | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> mem, bool compact); |
126 | | |
127 | | // Deserialize a thrift message from buf/len. buf/len must at least contain |
128 | | // all the bytes needed to store the thrift message. On return, len will be |
129 | | // set to the actual length of the header. |
130 | | template <class T> |
131 | | Status deserialize_thrift_msg(const uint8_t* buf, uint32_t* len, bool compact, |
132 | 2.53M | T* deserialized_msg) { |
133 | | // Deserialize msg bytes into c++ thrift msg using memory |
134 | | // transport. TMemoryBuffer is not const-safe, although we use it in |
135 | | // a const-safe way, so we have to explicitly cast away the const. |
136 | 2.53M | auto conf = std::make_shared<apache::thrift::TConfiguration>(); |
137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. |
138 | | // max message size is 100MB default, so make it unlimited. |
139 | 2.53M | conf->setMaxMessageSize(std::numeric_limits<int>::max()); |
140 | 2.53M | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( |
141 | 2.53M | new apache::thrift::transport::TMemoryBuffer( |
142 | 2.53M | const_cast<uint8_t*>(buf), *len, |
143 | 2.53M | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); |
144 | 2.53M | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = |
145 | 2.53M | create_deserialize_protocol(tmem_transport, compact); |
146 | | |
147 | 2.53M | try { |
148 | 2.53M | deserialized_msg->read(tproto.get()); |
149 | 2.53M | } catch (std::exception& e) { |
150 | 366 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); |
151 | 366 | } catch (...) { |
152 | | // TODO: Find the right exception for 0 bytes |
153 | 0 | return Status::InternalError("Unknown exception"); |
154 | 0 | } |
155 | | |
156 | 2.53M | uint32_t bytes_left = tmem_transport->available_read(); |
157 | 2.53M | *len = *len - bytes_left; |
158 | 2.53M | return Status::OK(); |
159 | 2.53M | } _ZN5doris22deserialize_thrift_msgIN8tparquet17BloomFilterHeaderEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 32 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 32 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 32 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 32 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 32 | new apache::thrift::transport::TMemoryBuffer( | 142 | 32 | const_cast<uint8_t*>(buf), *len, | 143 | 32 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 32 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 32 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 32 | try { | 148 | 32 | deserialized_msg->read(tproto.get()); | 149 | 32 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 32 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 32 | *len = *len - bytes_left; | 158 | 32 | return Status::OK(); | 159 | 32 | } |
_ZN5doris22deserialize_thrift_msgINS_19TRuntimeProfileTreeEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 20 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 20 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 20 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 20 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 20 | new apache::thrift::transport::TMemoryBuffer( | 142 | 20 | const_cast<uint8_t*>(buf), *len, | 143 | 20 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 20 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 20 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 20 | try { | 148 | 20 | deserialized_msg->read(tproto.get()); | 149 | 20 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 21 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 21 | *len = *len - bytes_left; | 158 | 21 | return Status::OK(); | 159 | 20 | } |
_ZN5doris22deserialize_thrift_msgIN8tparquet12FileMetaDataEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 11.2k | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 11.2k | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 11.2k | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 11.2k | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 11.2k | new apache::thrift::transport::TMemoryBuffer( | 142 | 11.2k | const_cast<uint8_t*>(buf), *len, | 143 | 11.2k | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 11.2k | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 11.2k | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 11.2k | try { | 148 | 11.2k | deserialized_msg->read(tproto.get()); | 149 | 11.2k | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 11.3k | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 11.3k | *len = *len - bytes_left; | 158 | 11.3k | return Status::OK(); | 159 | 11.2k | } |
_ZN5doris22deserialize_thrift_msgIN8tparquet10PageHeaderEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 2.17M | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 2.17M | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 2.17M | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 2.17M | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 2.17M | new apache::thrift::transport::TMemoryBuffer( | 142 | 2.17M | const_cast<uint8_t*>(buf), *len, | 143 | 2.17M | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 2.17M | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 2.17M | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 2.17M | try { | 148 | 2.17M | deserialized_msg->read(tproto.get()); | 149 | 2.17M | } catch (std::exception& e) { | 150 | 366 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 366 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 2.17M | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 2.17M | *len = *len - bytes_left; | 158 | 2.17M | return Status::OK(); | 159 | 2.17M | } |
_ZN5doris22deserialize_thrift_msgIN8tparquet11ColumnIndexEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 2.66k | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 2.66k | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 2.66k | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 2.66k | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 2.66k | new apache::thrift::transport::TMemoryBuffer( | 142 | 2.66k | const_cast<uint8_t*>(buf), *len, | 143 | 2.66k | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 2.66k | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 2.66k | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 2.66k | try { | 148 | 2.66k | deserialized_msg->read(tproto.get()); | 149 | 2.66k | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 2.67k | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 2.67k | *len = *len - bytes_left; | 158 | 2.67k | return Status::OK(); | 159 | 2.66k | } |
_ZN5doris22deserialize_thrift_msgIN8tparquet11OffsetIndexEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 60.9k | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 60.9k | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 60.9k | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 60.9k | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 60.9k | new apache::thrift::transport::TMemoryBuffer( | 142 | 60.9k | const_cast<uint8_t*>(buf), *len, | 143 | 60.9k | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 60.9k | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 60.9k | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 60.9k | try { | 148 | 60.9k | deserialized_msg->read(tproto.get()); | 149 | 60.9k | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 60.9k | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 60.9k | *len = *len - bytes_left; | 158 | 60.9k | return Status::OK(); | 159 | 60.9k | } |
_ZN5doris22deserialize_thrift_msgINS_14TQueryPlanInfoEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 3 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 3 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 3 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 3 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 3 | new apache::thrift::transport::TMemoryBuffer( | 142 | 3 | const_cast<uint8_t*>(buf), *len, | 143 | 3 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 3 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 3 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 3 | try { | 148 | 3 | deserialized_msg->read(tproto.get()); | 149 | 3 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 3 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 3 | *len = *len - bytes_left; | 158 | 3 | return Status::OK(); | 159 | 3 | } |
_ZN5doris22deserialize_thrift_msgINS_27TPipelineFragmentParamsListEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 280k | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 280k | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 280k | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 280k | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 280k | new apache::thrift::transport::TMemoryBuffer( | 142 | 280k | const_cast<uint8_t*>(buf), *len, | 143 | 280k | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 280k | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 280k | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 280k | try { | 148 | 280k | deserialized_msg->read(tproto.get()); | 149 | 280k | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 280k | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 280k | *len = *len - bytes_left; | 158 | 280k | return Status::OK(); | 159 | 280k | } |
_ZN5doris22deserialize_thrift_msgINS_15TResultFileSinkEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 4 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 4 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 4 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 4 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 4 | new apache::thrift::transport::TMemoryBuffer( | 142 | 4 | const_cast<uint8_t*>(buf), *len, | 143 | 4 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 4 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 4 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 4 | try { | 148 | 4 | deserialized_msg->read(tproto.get()); | 149 | 4 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 4 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 4 | *len = *len - bytes_left; | 158 | 4 | return Status::OK(); | 159 | 4 | } |
_ZN5doris22deserialize_thrift_msgINS_14TFileScanRangeEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 3.68k | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 3.68k | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 3.68k | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 3.68k | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 3.68k | new apache::thrift::transport::TMemoryBuffer( | 142 | 3.68k | const_cast<uint8_t*>(buf), *len, | 143 | 3.68k | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 3.68k | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 3.68k | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 3.68k | try { | 148 | 3.68k | deserialized_msg->read(tproto.get()); | 149 | 3.68k | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 3.68k | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 3.68k | *len = *len - bytes_left; | 158 | 3.68k | return Status::OK(); | 159 | 3.68k | } |
_ZN5doris22deserialize_thrift_msgINS_16TTableDescriptorEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 307 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 307 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 307 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 307 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 307 | new apache::thrift::transport::TMemoryBuffer( | 142 | 307 | const_cast<uint8_t*>(buf), *len, | 143 | 307 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 307 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 307 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 307 | try { | 148 | 307 | deserialized_msg->read(tproto.get()); | 149 | 307 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 307 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 307 | *len = *len - bytes_left; | 158 | 307 | return Status::OK(); | 159 | 307 | } |
_ZN5doris22deserialize_thrift_msgINS_19TFoldConstantParamsEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 566 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 566 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 566 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 566 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 566 | new apache::thrift::transport::TMemoryBuffer( | 142 | 566 | const_cast<uint8_t*>(buf), *len, | 143 | 566 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 566 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 566 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 566 | try { | 148 | 566 | deserialized_msg->read(tproto.get()); | 149 | 566 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 566 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 566 | *len = *len - bytes_left; | 158 | 566 | return Status::OK(); | 159 | 566 | } |
_ZN5doris22deserialize_thrift_msgINS_16TDescriptorTableEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 154 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 154 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 154 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 154 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 154 | new apache::thrift::transport::TMemoryBuffer( | 142 | 154 | const_cast<uint8_t*>(buf), *len, | 143 | 154 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 154 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 154 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 154 | try { | 148 | 154 | deserialized_msg->read(tproto.get()); | 149 | 154 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 154 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 154 | *len = *len - bytes_left; | 158 | 154 | return Status::OK(); | 159 | 154 | } |
_ZN5doris22deserialize_thrift_msgINS_9TExprListEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 154 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 154 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 154 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 154 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 154 | new apache::thrift::transport::TMemoryBuffer( | 142 | 154 | const_cast<uint8_t*>(buf), *len, | 143 | 154 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 154 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 154 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 154 | try { | 148 | 154 | deserialized_msg->read(tproto.get()); | 149 | 154 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 154 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 154 | *len = *len - bytes_left; | 158 | 154 | return Status::OK(); | 159 | 154 | } |
_ZN5doris22deserialize_thrift_msgINS_13TQueryOptionsEEENS_6StatusEPKhPjbPT_ Line | Count | Source | 132 | 154 | T* deserialized_msg) { | 133 | | // Deserialize msg bytes into c++ thrift msg using memory | 134 | | // transport. TMemoryBuffer is not const-safe, although we use it in | 135 | | // a const-safe way, so we have to explicitly cast away the const. | 136 | 154 | auto conf = std::make_shared<apache::thrift::TConfiguration>(); | 137 | | // On Thrift 0.14.0+, need use TConfiguration to raise the max message size. | 138 | | // max message size is 100MB default, so make it unlimited. | 139 | 154 | conf->setMaxMessageSize(std::numeric_limits<int>::max()); | 140 | 154 | std::shared_ptr<apache::thrift::transport::TMemoryBuffer> tmem_transport( | 141 | 154 | new apache::thrift::transport::TMemoryBuffer( | 142 | 154 | const_cast<uint8_t*>(buf), *len, | 143 | 154 | apache::thrift::transport::TMemoryBuffer::OBSERVE, conf)); | 144 | 154 | std::shared_ptr<apache::thrift::protocol::TProtocol> tproto = | 145 | 154 | create_deserialize_protocol(tmem_transport, compact); | 146 | | | 147 | 154 | try { | 148 | 154 | deserialized_msg->read(tproto.get()); | 149 | 154 | } catch (std::exception& e) { | 150 | 0 | return Status::InternalError<false>("Couldn't deserialize thrift msg:\n{}", e.what()); | 151 | 0 | } catch (...) { | 152 | | // TODO: Find the right exception for 0 bytes | 153 | 0 | return Status::InternalError("Unknown exception"); | 154 | 0 | } | 155 | | | 156 | 154 | uint32_t bytes_left = tmem_transport->available_read(); | 157 | 154 | *len = *len - bytes_left; | 158 | 154 | return Status::OK(); | 159 | 154 | } |
|
160 | | |
161 | | // Redirects all Thrift logging to VLOG_CRITICAL |
162 | | void init_thrift_logging(); |
163 | | |
164 | | // Wait for a server that is running locally to start accepting |
165 | | // connections, up to a maximum timeout |
166 | | Status wait_for_local_server(const ThriftServer& server, int num_retries, int retry_interval_ms); |
167 | | |
168 | | // Wait for a server to start accepting connections, up to a maximum timeout |
169 | | Status wait_for_server(const std::string& host, int port, int num_retries, int retry_interval_ms); |
170 | | |
171 | | // Utility method to print address as address:port |
172 | | void t_network_address_to_string(const TNetworkAddress& address, std::string* out); |
173 | | |
174 | | // Compares two TNetworkAddresses alphanumerically by their host:port |
175 | | // string representation |
176 | | bool t_network_address_comparator(const TNetworkAddress& a, const TNetworkAddress& b); |
177 | | |
178 | | PURE std::string to_string(const TUniqueId& id); |
179 | | |
180 | | PURE bool _has_inverted_index_v1_or_partial_update(TOlapTableSink sink); |
181 | | |
182 | | } // namespace doris |