* Utility function to encode row batch data into rpc attachment buffer */
| 112 | * Utility function to encode row batch data into rpc attachment buffer |
| 113 | */ |
| 114 | static 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 | |
| 142 | bool TabletClient::SQLBatchRequestQuery(const std::string& db, const std::string& sql, |
| 143 | std::shared_ptr<::fedb::sdk::SQLRequestRowBatch> row_batch, |
no test coverage detected