| 48 | } |
| 49 | |
| 50 | ExampleInfo mergeExampleInfo(const ExampleInfo& A, const ExampleInfo& B) { |
| 51 | std::map<int, SlotInfo> slots; |
| 52 | for (int i = 0; i < A.slot_size(); ++i) { |
| 53 | slots[A.slot(i).id()] = A.slot(i); |
| 54 | } |
| 55 | |
| 56 | for (int i = 0; i < B.slot_size(); ++i) { |
| 57 | int id = B.slot(i).id(); |
| 58 | if (slots.count(id) == 0) { slots[id] = B.slot(i); continue; } |
| 59 | auto a = slots[id]; |
| 60 | auto b = B.slot(i); |
| 61 | CHECK_EQ(a.format(), b.format()); |
| 62 | a.set_min_key(std::min(a.min_key(), b.min_key())); |
| 63 | a.set_max_key(std::max(a.max_key(), b.max_key())); |
| 64 | a.set_nnz_ele(a.nnz_ele() + b.nnz_ele()); |
| 65 | a.set_nnz_ex(a.nnz_ex() + b.nnz_ex()); |
| 66 | slots[id] = a; |
| 67 | } |
| 68 | |
| 69 | ExampleInfo C; |
| 70 | C.set_num_ex(A.num_ex() + B.num_ex()); |
| 71 | for (const auto& it : slots) *C.add_slot() = it.second; |
| 72 | return C; |
| 73 | } |
| 74 | |
| 75 | // InstanceInfo mergeInstanceInfo(const InstanceInfo& A, const InstanceInfo& B) { |
| 76 | // auto as = A.fea_grp_size(); |
no test coverage detected