| 180 | } |
| 181 | |
| 182 | static void save_nodes(QSqlDatabase *db, const Execution *ex) |
| 183 | { |
| 184 | const char *insert_query = "INSERT INTO Nodes \ |
| 185 | (NodeID, ParentID, Alternative, NKids, Status, Label) \ |
| 186 | VALUES (?,?,?,?,?,?);"; |
| 187 | |
| 188 | QSqlQuery insert_bm(*db); |
| 189 | insert_bm.prepare(insert_query); |
| 190 | |
| 191 | const auto &tree = ex->tree(); |
| 192 | const auto order = utils::pre_order(tree); |
| 193 | |
| 194 | constexpr static int TRANSACTION_SIZE = 50000; |
| 195 | |
| 196 | db->transaction(); |
| 197 | for (auto i = 0u; i < order.size(); ++i) |
| 198 | { |
| 199 | const auto nid = order[i]; |
| 200 | const auto pid = tree.getParent(nid); |
| 201 | const auto alt = tree.getAlternative(nid); |
| 202 | const auto kids = tree.childrenCount(nid); |
| 203 | const auto status = tree.getStatus(nid); |
| 204 | const auto label = tree.getLabel(nid); |
| 205 | |
| 206 | insert_node(&insert_bm, {nid, pid, alt, kids, status, label}); |
| 207 | |
| 208 | if (i % TRANSACTION_SIZE == TRANSACTION_SIZE - 1) |
| 209 | { |
| 210 | db->commit(); |
| 211 | db->transaction(); |
| 212 | } |
| 213 | } |
| 214 | db->commit(); |
| 215 | } |
| 216 | |
| 217 | static void insert_bookmark(QSqlQuery *stmt, BookmarkItem bi) |
| 218 | { |
no test coverage detected