MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / EncodeRowBatch

Function EncodeRowBatch

src/client/tablet_client.cc:114–140  ·  view source on GitHub ↗

* Utility function to encode row batch data into rpc attachment buffer */

Source from the content-addressed store, hash-verified

112 * Utility function to encode row batch data into rpc attachment buffer
113 */
114static bool EncodeRowBatch(std::shared_ptr<::fedb::sdk::SQLRequestRowBatch> row_batch,
115 ::fedb::api::SQLBatchRequestQueryRequest* request,
116 butil::IOBuf* io_buf) {
117 auto common_slice = row_batch->GetCommonSlice();
118 if (common_slice->empty()) {
119 request->set_common_slices(0);
120 } else {
121 if (!codec::EncodeRpcRow(reinterpret_cast<const int8_t*>(common_slice->data()),
122 common_slice->size(), io_buf)) {
123 LOG(WARNING) << "encode common row buf failed";
124 return false;
125 }
126 request->add_row_sizes(common_slice->size());
127 request->set_common_slices(1);
128 }
129 for (int i = 0; i < row_batch->Size(); ++i) {
130 auto non_common_slice = row_batch->GetNonCommonSlice(i);
131 if (!codec::EncodeRpcRow(reinterpret_cast<const int8_t*>(non_common_slice->data()),
132 non_common_slice->size(), io_buf)) {
133 LOG(WARNING) << "encode common row buf failed";
134 return false;
135 }
136 request->add_row_sizes(non_common_slice->size());
137 request->set_non_common_slices(1);
138 }
139 return true;
140}
141
142bool TabletClient::SQLBatchRequestQuery(const std::string& db, const std::string& sql,
143 std::shared_ptr<::fedb::sdk::SQLRequestRowBatch> row_batch,

Callers 2

SQLBatchRequestQueryMethod · 0.85

Calls 7

EncodeRpcRowFunction · 0.85
GetCommonSliceMethod · 0.80
dataMethod · 0.80
GetNonCommonSliceMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected