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

Method NewSimpleBatch

src/sdk/sql_request_row_test.cc:183–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181class SQLRequestRowBatchTest : public ::testing::Test {
182 public:
183 SQLRequestRowBatch* NewSimpleBatch(const std::vector<size_t>& common_column_indices) {
184 ::hybridse::vm::Schema schema;
185 InitSimpleSchema(&schema);
186
187 ::hybridse::sdk::SchemaImpl* schema_impl =
188 new ::hybridse::sdk::SchemaImpl(schema);
189 std::shared_ptr<::hybridse::sdk::Schema> schema_shared(schema_impl);
190
191 auto r1 = std::make_shared<SQLRequestRow>(schema_shared, std::set<std::string>());
192 r1->Init(5);
193 r1->AppendInt32(32);
194 r1->AppendString("hello");
195 r1->AppendInt64(64);
196 r1->Build();
197
198 auto r2 = std::make_shared<SQLRequestRow>(schema_shared, std::set<std::string>());
199 r2->Init(5);
200 r2->AppendInt32(32);
201 r2->AppendString("world");
202 r2->AppendInt64(64);
203 r2->Build();
204
205 common_schema.Clear();
206 non_common_schema.Clear();
207 for (int i = 0; i < schema.size(); ++i) {
208 if (std::find(common_column_indices.begin(), common_column_indices.end(), i)
209 != common_column_indices.end() &&
210 common_column_indices.size() != static_cast<size_t>(schema.size())) {
211 *common_schema.Add() = schema.Get(i);
212 } else {
213 *non_common_schema.Add() = schema.Get(i);
214 }
215 }
216
217 auto indice_set = std::make_shared<ColumnIndicesSet>(schema_shared);
218 for (size_t idx : common_column_indices) {
219 indice_set->AddCommonColumnIdx(idx);
220 }
221
222 auto batch = new SQLRequestRowBatch(schema_shared, indice_set);
223 batch->AddRow(r1);
224 batch->AddRow(r2);
225 return batch;
226 }
227
228 ::hybridse::vm::Schema common_schema;
229 ::hybridse::vm::Schema non_common_schema;

Callers

nothing calls this directly

Calls 11

InitSimpleSchemaFunction · 0.85
AddCommonColumnIdxMethod · 0.80
AddRowMethod · 0.80
InitMethod · 0.45
AppendInt32Method · 0.45
AppendStringMethod · 0.45
AppendInt64Method · 0.45
BuildMethod · 0.45
ClearMethod · 0.45
sizeMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected