Ejemplo n.º 1
0
            void callback_final() {
                unlink("count.db");
                Sqlite::Database *db = new Sqlite::Database("count.db");

                sqlite3 *sqlite_db = db->get_sqlite3();
                if (SQLITE_OK != sqlite3_exec(sqlite_db, \
                                              "CREATE TABLE stats (" \
                                              "  key    TEXT, " \
                                              "  value  INT64 " \
                                              ");", 0, 0, 0)) {
                    std::cerr << "Database error: " << sqlite3_errmsg(sqlite_db) << "\n";
                    sqlite3_close(sqlite_db);
                    exit(1);
                }

                Sqlite::Statement *statement_insert_into_main_stats = db->prepare("INSERT INTO stats (key, value) VALUES (?, ?);");
                db->begin_transaction();

//                std::ofstream out_stats("stats.csv");
                for (int i=0; stat_names[i]; i++) {
//                    out_stats << stat_names[i] << '\t' << ((uint64_t *) &stats)[i] << '\n';
                    statement_insert_into_main_stats
                    ->bind_text(stat_names[i])
                    ->bind_int64( ((uint64_t *) &stats)[i] )
                    ->execute();
                }
                statement_insert_into_main_stats
                ->bind_text("nodes_with_tags")
                ->bind_int64( ((uint64_t *) &stats)[0] - ((uint64_t *) &stats)[1] )
                ->execute();

//                out_stats.close();

                db->commit();

//                db->close();

                delete statement_insert_into_main_stats;
                delete db;
            }
Ejemplo n.º 2
0
                m_stats.relation_members += member_count;
                if (m_tag_count > (int64_t) m_stats.max_tags_on_relation) {
                    m_stats.max_tags_on_relation = m_tag_count;
                }
                if (member_count > (int64_t) m_stats.max_members_on_relation) {
                    m_stats.max_members_on_relation = member_count;
                }
                if (m_version > (int64_t) m_stats.max_relation_version) {
                    m_stats.max_relation_version = m_version;
                }
                m_stats.sum_relation_version += m_version;
            }

            void final() {
                unlink("count.db");
                Sqlite::Database db("count.db");

                sqlite3* sqlite_db = db.get_sqlite3();
                if (SQLITE_OK != sqlite3_exec(sqlite_db, \
                                              "CREATE TABLE stats (" \
                                              "  key    TEXT, " \
                                              "  value  INT64 " \
                                              ");", 0, 0, 0)) {
                    std::cerr << "Database error: " << sqlite3_errmsg(sqlite_db) << "\n";
                    sqlite3_close(sqlite_db);
                    exit(1);
                }

                Sqlite::Statement* statement_insert_into_main_stats = db.prepare("INSERT INTO stats (key, value) VALUES (?, ?);");
                db.begin_transaction();