sqliteprinter.cpp
Go to the documentation of this file.
103 printer_error().raise(LOCAL_INFO, "No 'output_file' entry specified in the options section of the Printer category of the input YAML file. Please add a name there for the output sqlite database file of the scan."); 111 // Delete final target file if one with same name already exists? (and if we are restarting the run) 122 logger() << LogTags::printers << LogTags::info << "Running shell command: " << command.str() << EOM; 128 errmsg << "rank "<<getRank()<<": Error deleting existing output file (requested by 'delete_file_on_restart' printer option; target filename is "<<database_file<<")! popen failed to run the command (command was '"<<command.str()<<"')"; 135 errmsg << "rank "<<getRank()<<": Error deleting existing output file (requested by 'delete_file_on_restart' printer option; target filename is "<<database_file<<")! Shell command failed to executed successfully, see stderr (command was '"<<command.str()<<"')."; 141 // Make sure no processes try to open database until we are sure it won't be deleted and replaced 153 // If we are resuming and this is the primary printer, need to read the database and find the previous 158 // Construct the SQLite3 statement to retrieve highest existing pointID in the database for this rank 167 err<<"Encountered SQLite error while preparing to retrieve previous pointIDs: "<<sqlite3_errmsg(get_db()); 177 err<<"SQLite statement to retrieve highest existing pointID returned more than one result! This doesn't make sense, so there is probably a bug in the statement that was used. Statement was: "<<sql.str(); 277 void SQLitePrinter::ensure_column_exists(const std::string& sql_col_name, const std::string& sql_col_type) 310 std::map<std::string, std::string, Utils::ci_less> colnames; // Will be passed to and filled by the callback function 315 err << "Failed to check SQL column names in output table, after failing to add a new column '"<<sql_col_name<<"' to that table."<<std::endl; 337 err << "Failed to add new column '"<<sql_col_name<<"' to output SQL table! The ALTER TABLE operation failed, however it was not because the column already existed (we successfully checked and the column was not found). The SQL error was: " << zErrMsg << std::endl; 352 // err << "Failed to add new column '"<<sql_col_name<<"' to output SQL table! The column already exists, but it has the wrong type (existing column has type '"<<jt->second<<"', but we expected it to have type '"<<sql_col_type<<"'!"; 360 // Column should exist now. Need to add the fact of this columns existence to our internal record. 370 // err << "SQLitePrinter records indicated that the column '"<<sql_col_name<<"' already exists in the output table, but with a different type than has been requested (existing type is '"<<it->second<<"', requested type was '"<<sql_col_type<<"'). This indicates either duplicate names in the printer output, or an inconsistency in how the print commands have been issued."; 377 void SQLitePrinter::insert_data(const unsigned int mpirank, const unsigned long pointID, const std::string& col_name, const std::string& col_type, const std::string& data) 420 err<<"Size of buffer_header ("<<buffer_header.size()<<") does not match buffer_info ("<<buffer_info.size()<<"). This is a bug, please report it."; 438 err<<"Size of a row in the transaction_data_buffer ("<<row.size()<<") does not match buffer_header ("<<buffer_info.size()<<"). This is a bug, please report it."; 455 err<<"Attempted to add data for column '"<<col_name<<"' to SQLitePrinter transaction buffer, but the type of the new data ("<<col_type<<") does not match the type already recorded for this column in the buffer ("<<buffer_col_type<<")."; 546 sql<<" WHERE EXISTS ( SELECT * FROM temp_table WHERE temp_table.pairID = "<<get_table_name()<<".pairID);\n"; void set_table_name(const std::string &table_name) Definition: sqlitebase.cpp:324 int submit_sql(const std::string &local_info, const std::string &sqlstr, bool allow_fail=false, sql_callback_fptr callback=NULL, void *data=NULL, char **zErrMsg=NULL) Definition: sqlitebase.cpp:258 void dump_buffer_as_UPDATE() Definition: sqliteprinter.cpp:511 std::string get_database_file() Definition: sqlitebase.cpp:322 void initialise(const std::vector< int > &) Virtual function overloads: Definition: sqliteprinter.cpp:205 std::map< std::size_t, std::vector< std::string > > transaction_data_buffer Definition: sqliteprinter.hpp:118 STL namespace. Logging access header for GAMBIT. EXPORT_SYMBOLS unsigned long long int & get_point_id() Returns unigue pointid;. Definition: printer_id_tools.cpp:13 Options resume_reader_options() Definition: sqliteprinter.cpp:247 void finalise(bool abnormal=false) Definition: sqliteprinter.cpp:234 std::map< std::string, std::string, Utils::ci_less > column_record Definition: sqliteprinter.hpp:104 Definition: log_tags.hpp:38 bool hasKey(const args &... keys) const Getters for key/value pairs (which is all the options node should contain) Definition: yaml_options.hpp:67 std::string get_table_name() Definition: sqlitebase.cpp:323 SQLite printer class declaration. std::vector< std::string > buffer_header Definition: sqliteprinter.hpp:114 EXPORT_SYMBOLS bool iequals(const std::string &a, const std::string &b, bool case_sensitive=false) Perform a (possibly) case-insensitive string comparison. Definition: util_functions.cpp:195 Definition: log_tags.hpp:36 const Logging::endofmessage EOM Explicit const instance of the end of message struct in Gambit namespace. Definition: logger.hpp:100 SQLitePrinter * primary_printer Definition: sqliteprinter.hpp:101 void require_output_ready() Definition: sqlitebase.cpp:230 EXPORT_SYMBOLS Logging::LogMaster & logger() Function to retrieve a reference to the Gambit global log object. Definition: logger.cpp:95 std::string comma_unless_last(Iter it, const Cont &c) Definition: sqlitebase.hpp:82 int col_name_callback(void *colmap_in, int, char **data, char **) Definition: sqlitebase.cpp:43 TYPE getValueOrDef(TYPE def, const args &... keys) const Definition: yaml_options.hpp:115 Definition: log_tags.hpp:53 void turn_buffer_into_insert(std::stringstream &sql, const std::string &table) Definition: sqliteprinter.cpp:474 void make_table(const std::string &) Definition: sqliteprinter.cpp:259 void open_db(const std::string &, char access='r') Definition: sqlitebase.cpp:164 std::map< std::string, std::pair< std::size_t, std::string >, Utils::ci_less > buffer_info Definition: sqliteprinter.hpp:111 std::size_t get_max_buffer_length() Definition: sqliteprinter.cpp:203 void insert_data(const unsigned int mpirank, const unsigned long pointID, const std::string &col_name, const std::string &col_type, const std::string &data) Definition: sqliteprinter.cpp:377 void setValue(const KEYTYPE &key, const VALTYPE &val) Basic setter, for adding extra options. Definition: yaml_options.hpp:135 The main printer class for output to SQLite database. Definition: sqliteprinter.hpp:39 void ensure_column_exists(const std::string &, const std::string &) Definition: sqliteprinter.cpp:277 SQLite base class for both reader and writer. Definition: sqlitebase.hpp:93 std::size_t pairfunc(const std::size_t i, const std::size_t j) Definition: sqlitebase.hpp:36 void dump_buffer_as_INSERT() Definition: sqliteprinter.cpp:499 SQLitePrinter(const Options &, BasePrinter *const primary=NULL) Constructor (for construction via inifile options) Definition: sqliteprinter.cpp:42 |