diff --git a/Database/Database.cpp b/Database/Database.cpp index bcc12a26..f647c8a7 100644 --- a/Database/Database.cpp +++ b/Database/Database.cpp @@ -857,7 +857,7 @@ Database::load_cache() } cout << "Value File Preload used " << Util::get_cur_time() - t0 << " ms" << endl; /* - cout << "Get in" << endl; + cerr << "Get in" << endl; { pid_t p = getpid(); char file[64] = { 0 };//�ļ��� @@ -1384,7 +1384,7 @@ bool Database::save() this->stringindex->flush(); this->clear_update_log(); - //cout<<"database checkpoint: "<getName()<getName()<store_path; if (!Util::dir_exist(Util::backup_path)) { - cout << "Failed to restore!" << endl; + cerr << "Failed to restore!" << endl; return false; } @@ -4340,7 +4340,7 @@ Database::restore() if (!this->load()) { this->clear(); - cout << "Failed to restore from backup file." << endl; + cerr << "Failed to restore from backup file." << endl; return false; } @@ -4355,7 +4355,7 @@ Database::restore() if (!this->restore_update(insertions, removals)) { - cout << "Failed to restore updates" << endl; + cerr << "Failed to restore updates" << endl; return false; } @@ -4373,7 +4373,7 @@ Database::read_update_log(const string _path, multiset& _i, multiset& _i, multiset& _i, multiset& _r) ofstream out_i; out_i.open(tmp_path.c_str(), ios::out); if (!out_i) { - cout << "Failed to open temp file, restore failed!" << endl; + cerr << "Failed to open temp file, restore failed!" << endl; return false; } for (multiset::iterator it = _i.begin(); it != _i.end(); it++) { @@ -4448,7 +4448,7 @@ Database::restore_update(multiset& _i, multiset& _r) ofstream out_r; out_r.open(tmp_path.c_str(), ios::out); if (!out_r) { - cout << "Failed to open temp file!" << endl; + cerr << "Failed to open temp file!" << endl; return false; } for (multiset::iterator it = _r.begin(); it != _r.end(); it++) { diff --git a/KVstore/ISTree/ISTree.cpp b/KVstore/ISTree/ISTree.cpp index 25f3a56b..e890bf05 100644 --- a/KVstore/ISTree/ISTree.cpp +++ b/KVstore/ISTree/ISTree.cpp @@ -275,7 +275,7 @@ ISTree::modify(unsigned _key, char* _str, unsigned _len) ISNode* ret = this->find(_key, &store, true); if (ret == NULL || store == -1 || _key != ret->getKey(store)) //tree is empty or not found { - cout << "tree is empty or not found" << endl; + cerr << "tree is empty or not found" << endl; return false; } //cout<<"ISTree::modify() - key is found, now to remove"<find(_key, &store, true); if (ret == NULL || store == -1 || _key != ret->getKey(store)) //tree is empty or not found { - cout << "tree is empty or not found" << endl; + cerr << "tree is empty or not found" << endl; return false; } //cout<<"IVTree::modify() - key is found, now to remove"< 2) { - cout << "Nonsense to add more parameters!" << endl; + cerr << "Nonsense to add more parameters!" << endl; } return 0; } @@ -190,14 +190,14 @@ main(int argc, char **argv) { if (argc != 3) { - cout << "You should just add one script file to be sourced!" << endl; + cerr << "You should just add one script file to be sourced!" << endl; return 1; } return deal_with_script(argv[2]); } else { - cout << "Wrong option used, please see the help info first!" << endl; + cerr << "Wrong option used, please see the help info first!" << endl; return 1; } } @@ -227,7 +227,7 @@ main(int argc, char **argv) { if (current_database != NULL) { - cout << endl << "Please unload your database before quiting!" << endl << endl; + cerr << endl << "Please unload your database before quiting!" << endl << endl; continue; } cout << endl << endl; @@ -406,7 +406,7 @@ int deal_with_script(char* file) { FILE* fp = NULL; if ((fp = fopen(file, "r")) == NULL) { - cout << "Open error: " << file << endl; + cerr << "Open error: " << file << endl; return -1; } @@ -429,12 +429,12 @@ int deal_with_script(char* file) { //end of file if (current_database != NULL) { - cout << endl << "Please unload your database before quitting!" << endl << endl; + cerr << endl << "Please unload your database before quitting!" << endl << endl; //TODO } if (gc != NULL) { - cout << endl << "Please return to native mode before quitting!" << endl << endl; + cerr << endl << "Please return to native mode before quitting!" << endl << endl; //TODO } @@ -468,7 +468,7 @@ bool parse_arguments(char* word, vector& args) { continue; } else { - cout << "Invalid arguments!" << endl; + cerr << "Invalid arguments!" << endl; return false; } } @@ -642,7 +642,7 @@ int help_handler(const vector& args) { } if (printed == 0) { - cout << "No commands match \"" << args[0] << "\". Possibilities are:" << endl; + cerr << "No commands match \"" << args[0] << "\". Possibilities are:" << endl; for (i = 0; current_commands[i].name; i++) { @@ -665,7 +665,7 @@ int help_handler(const vector& args) { } default: { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } } @@ -675,7 +675,7 @@ int help_handler(const vector& args) { //NOTICE:the SPARQL file to be used should be placed in the local machine even when in remote mode int source_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } @@ -687,17 +687,17 @@ int source_handler(const vector& args) { int quit_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc != NULL) { - cout << "This command cannot be used when in remote mode." << endl; + cerr << "This command cannot be used when in remote mode." << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database before quitting." << endl; + cerr << "Please unload your database before quitting." << endl; return -1; } @@ -707,17 +707,17 @@ int quit_handler(const vector& args) { int connect_handler(const vector& args) { if (args.size() > 2) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc != NULL) { - cout << "This command cannot be used when in remote mode." << endl; + cerr << "This command cannot be used when in remote mode." << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database before entering remote mode." << endl; + cerr << "Please unload your database before entering remote mode." << endl; return -1; } @@ -726,12 +726,12 @@ int connect_handler(const vector& args) { if (args.size() == 2) { if (!Util::isValidIP(args[0])) { - cout << "Invalid IP: " << args[0] << endl; + cerr << "Invalid IP: " << args[0] << endl; return -1; } if (!Util::isValidPort(args[1])) { - cout << "Invalid Port: " << args[1] << endl; + cerr << "Invalid Port: " << args[1] << endl; return -1; } @@ -746,7 +746,7 @@ int connect_handler(const vector& args) { stringstream(args[0]) >> port; } else { - cout << "Invalid argument, neither IP nor port: " << args[0] << endl; + cerr << "Invalid argument, neither IP nor port: " << args[0] << endl; return -1; } } @@ -755,7 +755,7 @@ int connect_handler(const vector& args) { gc = new GstoreConnector(ip, port); if (!gc->test()) { - cout << "Failed to connect to server at " << ip << ':' << port << endl; + cerr << "Failed to connect to server at " << ip << ':' << port << endl; delete gc; gc = NULL; return -1; @@ -769,12 +769,12 @@ int connect_handler(const vector& args) { int disconnect_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc == NULL) { - cout << "This command cannot be used when in native mode." << endl; + cerr << "This command cannot be used when in native mode." << endl; return -1; } @@ -782,7 +782,7 @@ int disconnect_handler(const vector& args) { if (show_ret != "connect to server error" && show_ret != "send show command error." && show_ret != "\n[empty]\n") { - cout << "Please unload your server database before entering native mode." << endl; + cerr << "Please unload your server database before entering native mode." << endl; return -1; } @@ -797,7 +797,7 @@ int disconnect_handler(const vector& args) { int show_handler(const vector& args) { if (args.size() > 1) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } @@ -807,7 +807,7 @@ int show_handler(const vector& args) flag = true; } else { - cout << "Invalid argument: " << args[0] << endl; + cerr << "Invalid argument: " << args[0] << endl; return -1; } } @@ -843,7 +843,7 @@ int show_handler(const vector& args) //NOTICE: for build() and load(), always keep database in the root of gStore int build_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } @@ -851,7 +851,7 @@ int build_handler(const vector& args) { //WARN:user better not end with ".db" by themselves!!! if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "Your db name to be built should not end with \".db\"." << endl; + cerr << "Your db name to be built should not end with \".db\"." << endl; return -1; } @@ -877,7 +877,7 @@ int build_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please unload your database first." << endl; + cerr << "Please unload your database first." << endl; return -1; } @@ -887,7 +887,7 @@ int build_handler(const vector& args) { if(database.substr(len-3, 3) == ".db") { - cout<<"your database can not end with .db"<& args) { current_database = NULL; if (!flag) { - cout << "Import RDF file to database failed." << endl; + cerr << "Import RDF file to database failed." << endl; string cmd = "rm -rf " + database; system(cmd.c_str()); return -1; @@ -909,14 +909,14 @@ int build_handler(const vector& args) { int drop_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } //only drop when *.db, avoid other files be removed string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } //database += ".db"; @@ -932,7 +932,7 @@ int drop_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please do not use this command when you are using a database." << endl; + cerr << "Please do not use this command when you are using a database." << endl; return -1; } @@ -949,13 +949,13 @@ int drop_handler(const vector& args) { int load_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument is required!" << endl; + cerr << "Exactly 1 argument is required!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } @@ -973,14 +973,14 @@ int load_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } current_database = new Database(database); bool flag = current_database->load(); if (!flag) { - cout << "Failed to load the database." << endl; + cerr << "Failed to load the database." << endl; delete current_database; current_database = NULL; return -1; @@ -993,7 +993,7 @@ int load_handler(const vector& args) { int unload_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } @@ -1003,7 +1003,7 @@ int unload_handler(const vector& args) { string database = gc->show(); if (database == "\n[empty]\n") { - cout << "No database used now." << endl; + cerr << "No database used now." << endl; return -1; } if (gc->unload(database.substr(1, database.length() - 2))) { @@ -1016,7 +1016,7 @@ int unload_handler(const vector& args) { if (current_database == NULL) { - cout << "No database used now." << endl; + cerr << "No database used now." << endl; return -1; } @@ -1030,16 +1030,16 @@ int unload_handler(const vector& args) { int query_handler(const vector& args) { if (gc == NULL) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } if (current_database == NULL) { - cout << "No database in use!" << endl; + cerr << "No database in use!" << endl; return -1; } } else if (args.size() != 1 && !(args.size() == 3 && args[1] == "-r")) { - cout << "Invalid arguments!" << endl; + cerr << "Invalid arguments!" << endl; return -1; } @@ -1054,7 +1054,7 @@ int query_handler(const vector& args) { const char *path = ret.c_str(); if (path == NULL) { - cout << "Invalid path of query." << endl; + cerr << "Invalid path of query." << endl; return -1; } #ifdef DEBUG @@ -1064,7 +1064,7 @@ int query_handler(const vector& args) { } if (sparql.empty()) { - cout << "Empty SPARQL." << endl; + cerr << "Empty SPARQL." << endl; return -1; } @@ -1106,22 +1106,22 @@ int query_handler(const vector& args) { int add_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } //database += ".db"; Database _db(database); if (!_db.insert(args[1])) { - cout << "Failed to insert!" << endl; + cerr << "Failed to insert!" << endl; return -1; } return 0; @@ -1129,22 +1129,22 @@ int add_handler(const vector& args) { int sub_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } //database += ".db"; Database _db(database); if (!_db.remove(args[1])) { - cout << "Failed to remove!" << endl; + cerr << "Failed to remove!" << endl; return -1; } return 0; @@ -1152,7 +1152,7 @@ int sub_handler(const vector& args) { int start_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -s"); @@ -1160,7 +1160,7 @@ int start_handler(const vector& args) { int stop_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -t"); @@ -1168,7 +1168,7 @@ int stop_handler(const vector& args) { int restart_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -r"); @@ -1176,14 +1176,14 @@ int restart_handler(const vector& args) { int port_handler(const vector& args) { if (args.size() > 1) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (args.empty()) { return system("bin/gserver -p"); } if (!Util::isValidPort(args[0])) { - cout << "Invalid port: " << args[0] << endl; + cerr << "Invalid port: " << args[0] << endl; return -1; } string cmd = "bin/gserver -p " + args[0]; @@ -1192,7 +1192,7 @@ int port_handler(const vector& args) { int printport_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -P"); @@ -1200,11 +1200,11 @@ int printport_handler(const vector& args) { int backup_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (current_database == NULL) { - cout << "No database loaded!" << endl; + cerr << "No database loaded!" << endl; return -1; } current_database->backup(); @@ -1213,16 +1213,16 @@ int backup_handler(const vector& args) { int restore_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } //database += ".db"; diff --git a/Main/ghttp.cpp b/Main/ghttp.cpp index c65b36f9..860413e4 100644 --- a/Main/ghttp.cpp +++ b/Main/ghttp.cpp @@ -688,13 +688,13 @@ int main(int argc, char *argv[]) } else { - cout << "Server stopped abnormally, restarting server..." << endl; + cerr << "Server stopped abnormally, restarting server..." << endl; //break; } } else { - cout << "Failed to start server: deamon fork failure." << endl; + cerr << "Failed to start server: deamon fork failure." << endl; return -1; } @@ -904,7 +904,7 @@ int initialize(int argc, char *argv[]) query_logfp = fopen(queryLog.c_str(), "a"); if(query_logfp == NULL) { - cout << "open query log error"<_TurtleParser.discardLine(); continue; } diff --git a/Server/Client.cpp b/Server/Client.cpp index 571975ea..d023ae02 100644 --- a/Server/Client.cpp +++ b/Server/Client.cpp @@ -37,7 +37,7 @@ bool Client::connectServer() bool flag = this->socket.create(); if (!flag) { - cout << "cannot create socket. @Client::connectServer" << endl; + cerr << "cannot create socket. @Client::connectServer" << endl; return false; } @@ -45,7 +45,7 @@ bool Client::connectServer() if (!flag) { - cout << "cannot connect to server. @Client::connectServer" << endl; + cerr << "cannot connect to server. @Client::connectServer" << endl; return false; } @@ -244,7 +244,7 @@ void Client::run() bool flag = this->connectServer(); if(!flag) { - cout << "connect server error. @Client::run" << endl; + cerr << "connect server error. @Client::run" << endl; if(ifredirect) fclose(fp); continue; @@ -253,7 +253,7 @@ void Client::run() flag = this->send(cmd); if(!flag) { - cout << "sent message error. @Client::run" << endl; + cerr << "sent message error. @Client::run" << endl; if(ifredirect) fclose(fp); continue; @@ -267,7 +267,7 @@ void Client::run() this->disconnectServer(); if(!flag) { - cout << "disconnect server error. @Client::run" << endl; + cerr << "disconnect server error. @Client::run" << endl; if(ifredirect) fclose(fp); continue; @@ -302,14 +302,14 @@ void Client::run() // bool flag = this->connectServer(); // if (!flag) // { - // cout << "connect server error. @Client::run" << endl; + // cerr << "connect server error. @Client::run" << endl; // continue; // } // // flag = this->send(cmd); // if (!flag) // { - // cout << "sent message error. @Client::run" << endl; + // cerr << "sent message error. @Client::run" << endl; // continue; // } // @@ -320,7 +320,7 @@ void Client::run() // this->disconnectServer(); // if (!flag) // { - // cout << "disconnect server error. @Client::run" << endl; + // cerr << "disconnect server error. @Client::run" << endl; // continue; // } //} diff --git a/Server/Operation.cpp b/Server/Operation.cpp index ae901f8b..f6a8c0d4 100644 --- a/Server/Operation.cpp +++ b/Server/Operation.cpp @@ -56,7 +56,7 @@ std::string Operation::getParameter(int _idx) } else { - std::cout << "beyond index error. @Operation::getParameter" << std::endl; + std::cerr << "beyond index error. @Operation::getParameter" << std::endl; return *this->parameters.end(); } } diff --git a/Server/Server.cpp b/Server/Server.cpp index 50e2c94c..896c2de9 100644 --- a/Server/Server.cpp +++ b/Server/Server.cpp @@ -45,21 +45,21 @@ Server::createConnection() flag = this->socket.create(); if (!flag) { - cout << Util::getTimeString() << "cannot create socket. @Server::createConnection" << endl; + cerr << Util::getTimeString() << "cannot create socket. @Server::createConnection" << endl; return false; } flag = this->socket.bind(this->connectionPort); if (!flag) { - cout << Util::getTimeString() << "cannot bind to port " << this->connectionPort << ". @Server::createConnection" << endl; + cerr << Util::getTimeString() << "cannot bind to port " << this->connectionPort << ". @Server::createConnection" << endl; return false; } flag = this->socket.listen(); if (!flag) { - cout << Util::getTimeString() << "cannot listen to port" << this->connectionPort << ". @Server::createConnection" << endl; + cerr << Util::getTimeString() << "cannot listen to port" << this->connectionPort << ". @Server::createConnection" << endl; return false; } @@ -99,7 +99,7 @@ Server::listen() bool recv_return = new_server_socket.recv(recv_cmd); if (!recv_return) { - cout << Util::getTimeString() << "receive command from client error. @Server::listen" << endl; + cerr << Util::getTimeString() << "receive command from client error. @Server::listen" << endl; continue; } @@ -157,11 +157,11 @@ Server::listen() string query = operation.getParameter(0); pthread_t timer = Server::start_timer(); if (timer == 0) { - cout << Util::getTimeString() << "Failed to start timer." << endl; + cerr << Util::getTimeString() << "Failed to start timer." << endl; } this->query(query, ret_msg); if (timer != 0 && !Server::stop_timer(timer)) { - cout << Util::getTimeString() << "Failed to stop timer." << endl; + cerr << Util::getTimeString() << "Failed to stop timer." << endl; } break; } @@ -211,7 +211,7 @@ Server::listen() break; } default: - cout << Util::getTimeString() << "this command is not supported by now. @Server::listen" << endl; + cerr << Util::getTimeString() << "this command is not supported by now. @Server::listen" << endl; } this->response(new_server_socket, ret_msg); @@ -445,7 +445,7 @@ Server::loadDatabase(std::string _db_name, std::string _ac_name, std::string& _r } // fork failure else if (fpid < 0) { - cout << Util::getTimeString() << "Database will not be backed-up automatically." << endl; + cerr << Util::getTimeString() << "Database will not be backed-up automatically." << endl; } //_ret_msg = "load database done."; @@ -651,7 +651,7 @@ bool Server::stop_timer(pthread_t _timer) { void* Server::timer(void* _args) { signal(SIGTERM, Server::timer_sigterm_handler); sleep(Util::gserver_query_timeout); - cout << Util::getTimeString() << "Query out of time." << endl; + cerr << Util::getTimeString() << "Query out of time." << endl; abort(); } diff --git a/Server/Socket.cpp b/Server/Socket.cpp index 875f8887..1e4259bb 100644 --- a/Server/Socket.cpp +++ b/Server/Socket.cpp @@ -32,7 +32,7 @@ bool Socket::create() if (!this->isValid()) { - std::cout << "create socket failed. @Socket::create" << std::endl; + std::cerr << "create socket failed. @Socket::create" << std::endl; return false; } @@ -49,7 +49,7 @@ bool Socket::create() setsockopt_RCVBUF_return == -1 || setsockopt_SNDBUF_return == -1) { - std::cout << "set socket options failed. @Socket::create" << std::endl; + std::cerr << "set socket options failed. @Socket::create" << std::endl; return false; } @@ -133,7 +133,7 @@ bool Socket::send(const std::string& _msg)const int send_return = ::send(this->sock, &msg_len, sizeof(msg_len), 0); if (send_return == -1) { - std::cout << "send message length error. @Socket::send" << std::endl; + std::cerr << "send message length error. @Socket::send" << std::endl; return false; } @@ -146,7 +146,7 @@ bool Socket::send(const std::string& _msg)const if (send_return == -1) { - std::cout << "send message context error. @Socket::send" << std::endl; + std::cerr << "send message context error. @Socket::send" << std::endl; return false; } @@ -165,7 +165,7 @@ int Socket::recv(std::string& _msg)const if (recv_return == -1) { - std::cout << "receive message length error, errno=" << errno << ".@Socket::recv" << std::endl; + std::cerr << "receive message length error, errno=" << errno << ".@Socket::recv" << std::endl; return 0; } @@ -183,7 +183,7 @@ int Socket::recv(std::string& _msg)const if (cur_len == -1) { - std::cout << "receive message context error, errno=" << errno << ".@Socket::recv" << std::endl; + std::cerr << "receive message context error, errno=" << errno << ".@Socket::recv" << std::endl; delete[] buf; return 0; @@ -213,7 +213,7 @@ bool Socket::connect(const std::string _hostname, const unsigned short _port) int status = inet_aton(_hostname.c_str(), &(this->addr).sin_addr); if (status == 0) { - std::cout << "bad IP address. @Socket::connect" << std::endl; + std::cerr << "bad IP address. @Socket::connect" << std::endl; return false; } diff --git a/Signature/Signature.cpp b/Signature/Signature.cpp index 8da42df6..a8aed492 100644 --- a/Signature/Signature.cpp +++ b/Signature/Signature.cpp @@ -213,7 +213,7 @@ Signature::encodeStr2Entity(EntityBitSet& _entity_bs, TYPE_ENTITY_LITERAL_ID _ne //else if (_str[0] != '<') //{ //#ifdef DEBUG_VSTREE - //cout << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; + //cerr << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; //#endif //} //_entity_bs.set(pos); diff --git a/StringIndex/StringIndex.cpp b/StringIndex/StringIndex.cpp index 5197c6d5..50770ad2 100644 --- a/StringIndex/StringIndex.cpp +++ b/StringIndex/StringIndex.cpp @@ -38,13 +38,13 @@ void StringIndexFile::save(KVstore &kv_store) this->index_file = fopen((this->loc + "index").c_str(), "wb"); if (this->index_file == NULL) { - cout << "save " << this->loc + "index" << " for wb error." << endl; + cerr << "save " << this->loc + "index" << " for wb error." << endl; return; } this->value_file = fopen((this->loc + "value").c_str(), "wb"); if (this->value_file == NULL) { - cout << "save " << this->loc + "value" << " for wb error." << endl; + cerr << "save " << this->loc + "value" << " for wb error." << endl; return; } @@ -80,13 +80,13 @@ void StringIndexFile::load() this->index_file = fopen((this->loc + "index").c_str(), "rb+"); if (this->index_file == NULL) { - cout << "load " << this->loc + "index" << " for rb+ error." << endl; + cerr << "load " << this->loc + "index" << " for rb+ error." << endl; return; } this->value_file = fopen((this->loc + "value").c_str(), "rb+"); if (this->value_file == NULL) { - cout << "load " << this->loc + "value" << " for rb+ error." << endl; + cerr << "load " << this->loc + "value" << " for rb+ error." << endl; return; } diff --git a/Trie/Trie.h b/Trie/Trie.h index c9b2a8b7..cbb430bc 100644 --- a/Trie/Trie.h +++ b/Trie/Trie.h @@ -69,8 +69,8 @@ class Trie loc += 2; if (t >= this->prefixnum) { - cout << "t=" << t << " prefix=" << prefixnum << endl; - cout << "err" << endl; + cerr << "t=" << t << " prefix=" << prefixnum << endl; + cerr << "err" << endl; target_string = ""; return; } diff --git a/Trie/TrieNode.cpp b/Trie/TrieNode.cpp index 544d7e0e..0465aafd 100644 --- a/Trie/TrieNode.cpp +++ b/Trie/TrieNode.cpp @@ -102,10 +102,10 @@ TrieNode::compress(string& _str, const int& lowbound) if (this->ID < 0) { - cout << "TrieNode::compress error. ID = " << ID << " str = " << + cerr << "TrieNode::compress error. ID = " << ID << " str = " << strPiece << endl; - cout << this->getString() << endl; - cout << this->getCount() << endl; + cerr << this->getString() << endl; + cerr << this->getCount() << endl; return ""; } diff --git a/Util/Bstr.cpp b/Util/Bstr.cpp index 98ce3c0d..af086915 100644 --- a/Util/Bstr.cpp +++ b/Util/Bstr.cpp @@ -158,10 +158,10 @@ Bstr::copy(const Bstr* _bp) { //DEBUG!!! //if(_bp == NULL) - //cout<<"fatal error is Bstr::copy() -- null pointer"<length = _bp->getLen(); //DEBUG!!! - //cout<<"bstr length: "<length<length<str = (char*)malloc(this->length); this->str = new char[this->length]; diff --git a/Util/Util.cpp b/Util/Util.cpp index 22b45bca..57316c9e 100644 --- a/Util/Util.cpp +++ b/Util/Util.cpp @@ -354,7 +354,7 @@ Util::Util() this->debug_kvstore = fopen(s.c_str(), "w+"); if(this->debug_kvstore == NULL) { - cout << "open error: kv.log\n"; + cerr << "open error: kv.log\n"; this->debug_kvstore = stderr; } } @@ -366,7 +366,7 @@ Util::Util() this->debug_database = fopen(s.c_str(), "w+"); if(this->debug_database == NULL) { - cout << "open error: db.log\n"; + cerr << "open error: db.log\n"; this->debug_database = stderr; } } @@ -378,7 +378,7 @@ Util::Util() this->debug_vstree = fopen(s.c_str(), "w+"); if(this->debug_vstree == NULL) { - cout << "open error: vs.log\n"; + cerr << "open error: vs.log\n"; this->debug_vstree = stderr; } } @@ -972,7 +972,7 @@ string Util::getQueryFromFile(const char* _file_path) { #ifdef DEBUG_PRECISE - cout << "file to open: " << _file_path <isFull()) { - cout << "error, entry buffer is full, can not insert now in EntryBuffer::insert." << endl; + cerr << "error, entry buffer is full, can not insert now in EntryBuffer::insert." << endl; return false; } diff --git a/VSTree/LRUCache.cpp b/VSTree/LRUCache.cpp index 35b43a70..0d6cec8c 100644 --- a/VSTree/LRUCache.cpp +++ b/VSTree/LRUCache.cpp @@ -96,7 +96,7 @@ bool LRUCache::loadCache(string _filePath) FILE* filePtr = fopen(this->dataFilePath.c_str(), "rb"); if (filePtr == NULL) { - cout << "error, can not load an exist data file. @LRUCache::loadCache" << endl; + cerr << "error, can not load an exist data file. @LRUCache::loadCache" << endl; return false; } @@ -111,7 +111,7 @@ bool LRUCache::loadCache(string _filePath) if (flag != 0) { - cout << "error,can't seek to the fileLine. @LRUCache::loadCache" << endl; + cerr << "error,can't seek to the fileLine. @LRUCache::loadCache" << endl; return false; } @@ -175,7 +175,7 @@ bool LRUCache::createCache(string _filePath) FILE* filePtr = fopen(this->dataFilePath.c_str(), "wb"); if (filePtr == NULL) { - cout << "error, can not create a new data file. @LRUCache::createCache" << endl; + cerr << "error, can not create a new data file. @LRUCache::createCache" << endl; return false; } fclose(filePtr); @@ -404,10 +404,10 @@ bool LRUCache::update(int _key, VNode* _value) if (valuePtr != NULL) { int pos = this->key2pos[_key]; - //BETTER:remove the below cout + //BETTER:remove the below cerr if (this->keys[pos] != _key) { - cout << "error, the pos is wrong. @LRUCache::update" << endl; + cerr << "error, the pos is wrong. @LRUCache::update" << endl; #ifdef THREAD_VSTREE_ON pthread_rwlock_unlock(&(this->cache_lock)); @@ -425,7 +425,7 @@ bool LRUCache::update(int _key, VNode* _value) return true; } - cout << "error:the key not exist!"<cache_lock)); #endif @@ -513,7 +513,7 @@ void LRUCache::freeElem(int _pos) { if(_pos < LRUCache::DEFAULT_NUM || _pos >= LRUCache::DEFAULT_NUM + this->size) { - cout << "error in LRUCache::freeElem() -- invalid pos" << endl; + cerr << "error in LRUCache::freeElem() -- invalid pos" << endl; return; } @@ -612,12 +612,12 @@ LRUCache::freeDisk(int _pos) if (nodePtr == NULL) { - cout << "error, VNode do not exist. @LRUCache::freeDisk" << endl; + cerr << "error, VNode do not exist. @LRUCache::freeDisk" << endl; return false; } if (filePtr == NULL) { - cout << "error, can't open file. @LRUCache::freeDisk" << endl; + cerr << "error, can't open file. @LRUCache::freeDisk" << endl; return false; } @@ -631,7 +631,7 @@ LRUCache::freeDisk(int _pos) if (flag != 0) { - cout << "error, can't seek to the fileLine. @LRUCache::writeOut" << endl; + cerr << "error, can't seek to the fileLine. @LRUCache::writeOut" << endl; return false; } @@ -653,18 +653,18 @@ LRUCache::writeOut(int _pos, int _fileLine) if (nodePtr == NULL) { - cout << "error, VNode do not exist. @LRUCache::writeOut" << endl; + cerr << "error, VNode do not exist. @LRUCache::writeOut" << endl; return false; } if (filePtr == NULL) { - cout << "error, can't open file. @LRUCache::writeOut" << endl; + cerr << "error, can't open file. @LRUCache::writeOut" << endl; return false; } if (nodePtr->getFileLine() != _fileLine) { - cout << "error, fileLine " << _fileLine <<" "<< nodePtr->getFileLine() << " wrong. @LRUCache::writeOut" << endl; + cerr << "error, fileLine " << _fileLine <<" "<< nodePtr->getFileLine() << " wrong. @LRUCache::writeOut" << endl; } if(!nodePtr->isDirty()) @@ -688,7 +688,7 @@ LRUCache::writeOut(int _pos, int _fileLine) if (flag != 0) { - cout << "error, can't seek to the fileLine. @LRUCache::writeOut" << endl; + cerr << "error, can't seek to the fileLine. @LRUCache::writeOut" << endl; return false; } @@ -712,13 +712,13 @@ bool LRUCache::readIn(int _pos, int _fileLine) //if (nodePtr == NULL) //{ - //cout << "error, can not new a VNode. @LRUCache::readIn" << endl; + //cerr << "error, can not new a VNode. @LRUCache::readIn" << endl; //return false; //} if (filePtr == NULL) { - cout << "error, can't open " << + cerr << "error, can't open " << "[" << this->dataFilePath << "]" << ". @LRUCache::readIn" << endl; return false; @@ -734,7 +734,7 @@ bool LRUCache::readIn(int _pos, int _fileLine) if (flag != 0) { - cout << "error,can't seek to the fileLine. @LRUCache::readIn" << endl; + cerr << "error,can't seek to the fileLine. @LRUCache::readIn" << endl; return false; } @@ -746,7 +746,7 @@ bool LRUCache::readIn(int _pos, int _fileLine) if (nodePtr == NULL || nodePtr->getFileLine() != _fileLine) { cout<<"node file line: "<getFileLine()<setElem(_pos, _fileLine, nodePtr); @@ -765,7 +765,7 @@ bool LRUCache::flush() if (filePtr == NULL) { - cout << "error, can't open file. @LRUCache::flush" << endl; + cerr << "error, can't open file. @LRUCache::flush" << endl; return false; } @@ -790,7 +790,7 @@ bool LRUCache::flush() if (nodePtr == NULL) { - cout << "error, VNode do not exist. @LRUCache::flush" << endl; + cerr << "error, VNode do not exist. @LRUCache::flush" << endl; return false; } @@ -805,7 +805,7 @@ bool LRUCache::flush() if (flag != 0) { - cout << "error, can't seek to the fileLine. @LRUCache::flush" << endl; + cerr << "error, can't seek to the fileLine. @LRUCache::flush" << endl; return false; } diff --git a/VSTree/VNode.cpp b/VSTree/VNode.cpp index b04c68c7..f9982304 100644 --- a/VSTree/VNode.cpp +++ b/VSTree/VNode.cpp @@ -260,7 +260,7 @@ bool VNode::addChildEntry(const SigEntry _entry, bool _is_splitting) { //if (this->isFull() && !_is_splitting) //{ - //cout<< "error, can not add child entry when the node is full, in VNode::addChildEntry." << endl; + //cerr<< "error, can not add child entry when the node is full, in VNode::addChildEntry." << endl; //return false; //} @@ -277,13 +277,13 @@ bool VNode::addChildNode(VNode* _p_child_node, bool _is_splitting) { //if (this->isFull() && !_is_splitting) //{ - //cout<< "error, can not add child when the node is full. @VNode::addChildNode" << endl; + //cerr<< "error, can not add child when the node is full. @VNode::addChildNode" << endl; //return false; //} //if (_p_child_node == NULL) //{ - //cout<< "error, can not add child when the child node pointer is NULL. @VNode::addChildNode" << endl; + //cerr<< "error, can not add child when the child node pointer is NULL. @VNode::addChildNode" << endl; //return false; //} @@ -303,7 +303,7 @@ bool VNode::removeChild(int _i) int child_num = this->getChildNum(); if (_i < 0 || _i >= child_num) { - cout<< "error, illegal child index. @VNode::removeChild" << endl; + cerr<< "error, illegal child index. @VNode::removeChild" << endl; return false; } @@ -354,7 +354,7 @@ int VNode::getIndexInFatherNode(LRUCache& _nodeBuffer) #ifdef THREAD_VSTREE_ON pthread_mutex_unlock(&(fatherNodePtr->node_lock)); #endif - cout << "error, can not find rank in father node. @VNode::getIndexInFatherNode" << endl; + cerr << "error, can not find rank in father node. @VNode::getIndexInFatherNode" << endl; return 0; } @@ -390,7 +390,7 @@ void VNode::refreshAncestorSignature(LRUCache& _nodeBuffer) if (fatherNodePtr == NULL) { if (!this->isRoot()) - cout << "error, can not find father node. @VNode::refreshSignature" << endl; + cerr << "error, can not find father node. @VNode::refreshSignature" << endl; return; } @@ -410,7 +410,7 @@ bool VNode::retrieveChild(vector& _child_vec, const EntitySig _filter_si { if (this->isLeaf()) { - cout << "error, can not retrieve children from a leaf node.@VNode::retrieveChild" << endl; + cerr << "error, can not retrieve children from a leaf node.@VNode::retrieveChild" << endl; return false; } @@ -430,7 +430,7 @@ bool VNode::retrieveEntry(vector& _entry_vec, const EntitySig _filter_ { if (!this->isLeaf()) { - cout << "error, can not retrieve entries from a non-leaf node. @VNode::retrieveEntry" << endl; + cerr << "error, can not retrieve entries from a non-leaf node. @VNode::retrieveEntry" << endl; return false; } diff --git a/VSTree/VSTree.cpp b/VSTree/VSTree.cpp index f11647e3..f4514f33 100644 --- a/VSTree/VSTree.cpp +++ b/VSTree/VSTree.cpp @@ -70,7 +70,7 @@ VSTree::getNode(int _line) if (_line >= this->max_nid_alloc) { //cout<<_line <<" "<max_nid_alloc<getLeafNodeByEntityID(_entity_id); if (leafNodePtr == NULL) { - cout << "error, can not find the mapping leaf node. @VSTree::updateEntry" << endl; - cout << "the entity id: "<<_entity_id << endl; + cerr << "error, can not find the mapping leaf node. @VSTree::updateEntry" << endl; + cerr << "the entity id: "<<_entity_id << endl; return false; } @@ -328,7 +328,7 @@ bool VSTree::updateEntry(int _entity_id, const EntityBitSet& _bitset) if (!findFlag) { - cout<< "error, can not find the mapping child entry in the leaf node. @VSTree::updateEntry" << endl; + cerr<< "error, can not find the mapping child entry in the leaf node. @VSTree::updateEntry" << endl; #ifdef THREAD_VSTREE_ON pthread_mutex_unlock(&(leafNodePtr->node_lock)); #endif @@ -359,7 +359,7 @@ VSTree::replaceEntry(int _entity_id, const EntityBitSet& _bitset) if (leafNodePtr == NULL) { - cout << "error, can not find the mapping leaf node. @VSTree::replaceEntry" << endl; + cerr << "error, can not find the mapping leaf node. @VSTree::replaceEntry" << endl; return false; } @@ -396,7 +396,7 @@ VSTree::replaceEntry(int _entity_id, const EntityBitSet& _bitset) if (!findFlag) { - cout << "error, can not find the mapping child entry in the leaf node. @VSTree::replaceEntry" << endl; + cerr << "error, can not find the mapping child entry in the leaf node. @VSTree::replaceEntry" << endl; #ifdef THREAD_VSTREE_ON pthread_mutex_unlock(&(leafNodePtr->node_lock)); #endif @@ -455,7 +455,7 @@ VSTree::insertEntry(const SigEntry& _entry) if(choosedNodePtr == NULL) { - cout << "error, can not choose a leaf node to insert entry. @VSTree::insert" << endl; + cerr << "error, can not choose a leaf node to insert entry. @VSTree::insert" << endl; return false; } @@ -522,7 +522,7 @@ VSTree::removeEntry(int _entity_id) if (leafNodePtr == NULL) { - cout<< "error, can not find the mapping leaf node. @VSTree::removeEntry" << endl; + cerr<< "error, can not find the mapping leaf node. @VSTree::removeEntry" << endl; return false; } @@ -544,7 +544,7 @@ VSTree::removeEntry(int _entity_id) if(entryIndex == -1) { - cout << "error, can not find the entry in leaf node. @VSTree::removeEntry" << endl; + cerr << "error, can not find the entry in leaf node. @VSTree::removeEntry" << endl; return false; } @@ -584,7 +584,7 @@ VSTree::removeEntry(int _entity_id) { if(childNum <= VNode::MIN_CHILD_NUM) { - //cout << "In VSTree::remove() -- the node is invalid" << endl; + //cerr << "In VSTree::remove() -- the node is invalid" << endl; //TODO+BETTER:this may search again, too costly //VNode* fatherNodePtr = leafNodePtr->getFather(*(this->node_buffer)); ////int index = leafNodePtr->getIndexInFatherNode(*(this->node_buffer)); @@ -1197,7 +1197,7 @@ VSTree::coalesce(VNode*& _child, int _entry_index) } if(i == fn) { - cout << "not found the leaf node in VSTree::coalesce()" << endl; + cerr << "not found the leaf node in VSTree::coalesce()" << endl; return; } else @@ -1547,7 +1547,7 @@ VSTree::saveTreeInfo() if (filePtr == NULL) { - //cout << "error, can not create tree info file. @VSTree::saveTreeInfo" << endl; + //cerr << "error, can not create tree info file. @VSTree::saveTreeInfo" << endl; return false; } @@ -1599,7 +1599,7 @@ VSTree::loadTreeInfo() if (filePtr == NULL) { - cout << "error, can not open tree file:[" << + cerr << "error, can not open tree file:[" << VSTree::tree_info_file_path << "]@VSTree::loadTreeInfo" << endl; fclose(filePtr); @@ -1622,7 +1622,7 @@ VSTree::loadTreeInfo() if (sigLength > Signature::ENTITY_SIG_LENGTH) { - cout << "WARNING: signature length is too short. @VSTree::loadTreeInfo" << endl; + cerr << "WARNING: signature length is too short. @VSTree::loadTreeInfo" << endl; } fread(&this->entry_num, sizeof(int), 1, filePtr); @@ -1631,7 +1631,7 @@ VSTree::loadTreeInfo() if (nodeBufferSize > this->node_buffer->getCapacity()) { - cout << "WARNING: node buffer size may be too small. @VSTree::loadTreeInfo" << endl; + cerr << "WARNING: node buffer size may be too small. @VSTree::loadTreeInfo" << endl; } //read max id and free id list @@ -1670,7 +1670,7 @@ VSTree::loadEntityID2FileLineMap() if (filePtr == NULL) { - cout << "error, can not open tree node file. @VSTree::loadEntityID2FileLineMap" << endl; + cerr << "error, can not open tree node file. @VSTree::loadEntityID2FileLineMap" << endl; return false; } @@ -1682,7 +1682,7 @@ VSTree::loadEntityID2FileLineMap() if (flag != 0) { - cout << "error,can't seek to the fileLine. @VSTree::loadEntityID2FileLineMap" << endl; + cerr << "error,can't seek to the fileLine. @VSTree::loadEntityID2FileLineMap" << endl; return false; } @@ -1757,7 +1757,7 @@ VSTree::getLeafNodeByEntityID(int _entityID) if (iter == this->entityID2FileLineMap.end()) { - cout << "error,can not find the _entityID's mapping fileLine. @VSTree::getLeafNodeByEntityID" << endl; + cerr << "error,can not find the _entityID's mapping fileLine. @VSTree::getLeafNodeByEntityID" << endl; return NULL; } @@ -1779,7 +1779,7 @@ VSTree::retrieveEntity(const EntityBitSet& _entity_bit_set, IDList* _p_id_list) //Util::logging("IN retrieveEntity"); EntitySig filterSig(_entity_bit_set); #ifdef DEBUG_VSTREE - cout << "the filter signature: " << filterSig.to_str() << endl; + cerr << "the filter signature: " << filterSig.to_str() << endl; #endif queue nodeQueue; //searching node file line queue. @@ -1842,7 +1842,7 @@ VSTree::retrieveEntity(const EntityBitSet& _entity_bit_set, IDList* _p_id_list) const SigEntry& entry = currentNodePtr->getChildEntry(i); #ifdef DEBUG_VSTREE - //cout << "current entry: " << entry.to_str() << endl; + //cerr << "current entry: " << entry.to_str() << endl; #endif if (entry.cover(filterSig)) @@ -1885,7 +1885,7 @@ VSTree::retrieveEntity(const EntityBitSet& _entity_bit_set, IDList* _p_id_list) } } #ifdef DEBUG_VSTREE - //cout << "child num: " << childNum << " valid num: " << valid << endl; + //cerr << "child num: " << childNum << " valid num: " << valid << endl; #endif #ifdef THREAD_VSTREE_ON diff --git a/api/http/cpp/src/GstoreConnector.cpp b/api/http/cpp/src/GstoreConnector.cpp index 9367d041..fa533b48 100644 --- a/api/http/cpp/src/GstoreConnector.cpp +++ b/api/http/cpp/src/GstoreConnector.cpp @@ -48,14 +48,14 @@ GstoreConnector::~GstoreConnector() bool GstoreConnector::test() { bool connect_return = this->connect(); if (!connect_return) { - cout << "failed to connect to server. @GstoreConnector::test" << endl; + cerr << "failed to connect to server. @GstoreConnector::test" << endl; return false; } string cmd = "test"; bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send test command error. @GstoreConnector::test" << endl; + cerr << "send test command error. @GstoreConnector::test" << endl; return false; } @@ -115,7 +115,7 @@ GstoreConnector::build(string _db_name, string _rdf_file_path, string username, string cmd = url + "/?operation=build&db_name=" + _db_name + "&ds_path=" + _rdf_file_path + "&username=" + username + "&password=" + password; string recv_msg; int ret = hc.Get(cmd, recv_msg); - cout << recv_msg << endl; + cerr << recv_msg << endl; if (recv_msg == "import RDF file to database done.") { return true; @@ -130,7 +130,7 @@ GstoreConnector::drop(string _db_name) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::unload" << endl; + cerr << "connect to server error. @GstoreConnector::unload" << endl; return false; } @@ -138,7 +138,7 @@ GstoreConnector::drop(string _db_name) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send unload command error. @GstoreConnector::unload" << endl; + cerr << "send unload command error. @GstoreConnector::unload" << endl; return false; } @@ -191,7 +191,7 @@ GstoreConnector::connect() bool flag = this->socket.create(); if (!flag) { - cout << "cannot create socket. @GstoreConnector::connect" << endl; + cerr << "cannot create socket. @GstoreConnector::connect" << endl; return false; } @@ -199,7 +199,7 @@ GstoreConnector::connect() if (!flag) { - cout << "cannot connect to server. @GstoreConnector::connect" << endl; + cerr << "cannot connect to server. @GstoreConnector::connect" << endl; return false; } diff --git a/api/socket/cpp/src/GstoreConnector.cpp b/api/socket/cpp/src/GstoreConnector.cpp index 31244a9a..69346e6b 100644 --- a/api/socket/cpp/src/GstoreConnector.cpp +++ b/api/socket/cpp/src/GstoreConnector.cpp @@ -48,14 +48,14 @@ GstoreConnector::~GstoreConnector() bool GstoreConnector::test() { bool connect_return = this->connect(); if (!connect_return) { - cout << "failed to connect to server. @GstoreConnector::test" << endl; + cerr << "failed to connect to server. @GstoreConnector::test" << endl; return false; } string cmd = "test"; bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send test command error. @GstoreConnector::test" << endl; + cerr << "send test command error. @GstoreConnector::test" << endl; return false; } @@ -77,7 +77,7 @@ GstoreConnector::load(string _db_name) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::load" << endl; + cerr << "connect to server error. @GstoreConnector::load" << endl; return false; } @@ -85,7 +85,7 @@ GstoreConnector::load(string _db_name) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send load command error. @GstoreConnector.load" << endl; + cerr << "send load command error. @GstoreConnector.load" << endl; return false; } @@ -109,7 +109,7 @@ GstoreConnector::unload(string _db_name) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::unload" << endl; + cerr << "connect to server error. @GstoreConnector::unload" << endl; return false; } @@ -117,7 +117,7 @@ GstoreConnector::unload(string _db_name) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send unload command error. @GstoreConnector::unload" << endl; + cerr << "send unload command error. @GstoreConnector::unload" << endl; return false; } @@ -141,7 +141,7 @@ GstoreConnector::build(string _db_name, string _rdf_file_path) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::build" << endl; + cerr << "connect to server error. @GstoreConnector::build" << endl; return false; } @@ -149,7 +149,7 @@ GstoreConnector::build(string _db_name, string _rdf_file_path) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send import command error. @GstoreConnector::build" << endl; + cerr << "send import command error. @GstoreConnector::build" << endl; return false; } @@ -158,7 +158,7 @@ GstoreConnector::build(string _db_name, string _rdf_file_path) this->disconnect(); - cout << recv_msg << endl; + cerr << recv_msg << endl; if (recv_msg == "import RDF file to database done.") { return true; @@ -173,7 +173,7 @@ GstoreConnector::drop(string _db_name) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::unload" << endl; + cerr << "connect to server error. @GstoreConnector::unload" << endl; return false; } @@ -181,7 +181,7 @@ GstoreConnector::drop(string _db_name) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send unload command error. @GstoreConnector::unload" << endl; + cerr << "send unload command error. @GstoreConnector::unload" << endl; return false; } @@ -204,7 +204,7 @@ GstoreConnector::query(string _sparql, string _output) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::query" << endl; + cerr << "connect to server error. @GstoreConnector::query" << endl; return "connect to server error."; } @@ -212,7 +212,7 @@ GstoreConnector::query(string _sparql, string _output) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send query command error. @GstoreConnector::query"; + cerr << "send query command error. @GstoreConnector::query"; return "send query command error."; } @@ -230,7 +230,7 @@ GstoreConnector::show(bool _type) bool connect_return = this->connect(); if (!connect_return) { - cout << "connect to server error. @GstoreConnector::show" << endl; + cerr << "connect to server error. @GstoreConnector::show" << endl; return "connect to server error."; } @@ -246,7 +246,7 @@ GstoreConnector::show(bool _type) bool send_return = this->socket.send(cmd); if (!send_return) { - cout << "send show command error. @GstoreConnector::show"; + cerr << "send show command error. @GstoreConnector::show"; return "send show command error."; } @@ -263,7 +263,7 @@ GstoreConnector::connect() bool flag = this->socket.create(); if (!flag) { - cout << "cannot create socket. @GstoreConnector::connect" << endl; + cerr << "cannot create socket. @GstoreConnector::connect" << endl; return false; } @@ -271,7 +271,7 @@ GstoreConnector::connect() if (!flag) { - cout << "cannot connect to server. @GstoreConnector::connect" << endl; + cerr << "cannot connect to server. @GstoreConnector::connect" << endl; return false; } diff --git a/garbage/IndexJoin.cpp b/garbage/IndexJoin.cpp index c6a1caf3..1677763b 100644 --- a/garbage/IndexJoin.cpp +++ b/garbage/IndexJoin.cpp @@ -126,7 +126,7 @@ Join::select() } #ifdef DEBUG_JOIN //printf("the start id is: %d\n", this->start_id); - cout << "the start id is: " << this->start_id << endl; + cerr << "the start id is: " << this->start_id << endl; #endif } @@ -140,10 +140,10 @@ Join::join_sparql(SPARQLquery& _sparql_query) for (int i = 0; i < basic_query_num; i++) { //fprintf(stderr, "Basic query %d\n", i); - cout << "Basic query " << i << endl; + cerr << "Basic query " << i << endl; bool ret = this->join_basic(&(_sparql_query.getBasicQuery(i))); if (!ret) - cout << "end directly for this basic query: " << i << endl; + cerr << "end directly for this basic query: " << i << endl; } return true; @@ -157,7 +157,7 @@ Join::join_basic(BasicQuery* _basic_query) bool ret1 = this->filter_before_join(); long after_constant_filter = Util::get_cur_time(); //fprintf(stderr, "after filter_before_join: used %ld ms\n", after_filter - begin); - cout << "after filter_before_join: used " << (after_constant_filter - begin) << " ms" << endl; + cerr << "after filter_before_join: used " << (after_constant_filter - begin) << " ms" << endl; if (!ret1) { this->clear(); @@ -166,12 +166,12 @@ Join::join_basic(BasicQuery* _basic_query) this->add_literal_candidate(); long after_add_literal = Util::get_cur_time(); - cout << "after add_literal_candidate: used " << (after_add_literal - after_constant_filter) << " ms" << endl; + cerr << "after add_literal_candidate: used " << (after_add_literal - after_constant_filter) << " ms" << endl; bool ret2 = this->allFilterByPres(); //bool ret2 = true; long after_pre_filter = Util::get_cur_time(); - cout << "after allFilterByPres: used " << (after_pre_filter - after_add_literal) << " ms" << endl; + cerr << "after allFilterByPres: used " << (after_pre_filter - after_add_literal) << " ms" << endl; if (!ret2) { this->clear(); @@ -180,7 +180,7 @@ Join::join_basic(BasicQuery* _basic_query) bool ret3 = this->join(); long after_joinbasic = Util::get_cur_time(); - cout << "after join_basic: used " << (after_joinbasic - after_pre_filter) << " ms" << endl; + cerr << "after join_basic: used " << (after_joinbasic - after_pre_filter) << " ms" << endl; if (!ret3) { this->clear(); @@ -196,7 +196,7 @@ Join::join_basic(BasicQuery* _basic_query) // //this->generateAllSatellites(); //long after_generate_satellite = Util::get_cur_time(); - //cout<<"after generate satellite: used "<<(after_generate_satellite - after_joinbasic)<<" ms"<pre_var_handler(); //TODO+BETTER:maybe also reduce to empty, return false long after_pre_var = Util::get_cur_time(); - cout << "after pre var: used " << (after_pre_var - after_joinbasic) << " ms" << endl; + cerr << "after pre var: used " << (after_pre_var - after_joinbasic) << " ms" << endl; this->copyToResult(); long after_copy = Util::get_cur_time(); - cout << "after copy to result list: used " << (after_copy - after_pre_var) << " ms" << endl; + cerr << "after copy to result list: used " << (after_copy - after_pre_var) << " ms" << endl; - cout << "Final result size: " << this->basic_query->getResultList().size() << endl; + cerr << "Final result size: " << this->basic_query->getResultList().size() << endl; this->clear(); return true; } @@ -251,18 +251,18 @@ Join::pre_var_handler() //int core_var_num = this->basic_query->getRetrievedVarNum(); unsigned pre_var_num = this->basic_query->getPreVarNum(); #ifdef DEBUG_JOIN - cout << "pre var num: " << pre_var_num << endl; + cerr << "pre var num: " << pre_var_num << endl; #endif //QUERY+BETTER:filter by pre vars one by one or each record together? for (unsigned i = 0; i < pre_var_num; ++i) { #ifdef DEBUG_JOIN - cout << "current pre var id: " << i << endl; + cerr << "current pre var id: " << i << endl; #endif const PreVar& pre_var = this->basic_query->getPreVarByID(i); #ifdef DEBUG_JOIN - cout << "current table size: " << this->current_table.size() << endl; + cerr << "current table size: " << this->current_table.size() << endl; #endif //WARN:do not conflict with original var id @@ -280,7 +280,7 @@ Join::pre_var_handler() //bool ok = true; unsigned triple_num = pre_var.triples.size(); #ifdef DEBUG_JOIN - //cout<<"triple num for this var: "<kvstore->getobjIDlistBysubID((*it)[this->id2pos[var1]], oid_list, oid_list_len); //this->kvstore->getpreIDlistBysubID((*it)[this->id2pos[var1]], id_list, id_list_len); //} - //cout<<"sub str: "<kvstore->getEntityByID((*it)[this->id2pos[var1]])<kvstore->getEntityByID((*it)[this->id2pos[var2]])<kvstore->getEntityByID((*it)[this->id2pos[var1]])<kvstore->getEntityByID((*it)[this->id2pos[var2]])<kvstore->getpreIDlistBysubIDobjID((*it)[this->id2pos[var1]], (*it)[this->id2pos[var2]], id_list, id_list_len); int sid = (*it)[this->id2pos[var1]], oid = (*it)[this->id2pos[var2]]; this->kvstore->getpreIDlistBysubIDobjID(sid, oid, id_list, id_list_len, true); @@ -428,7 +428,7 @@ Join::pre_var_handler() if (valid_ans.size() == 0) { #ifdef DEBUG_JOIN - cout << "already empty!" << endl; + cerr << "already empty!" << endl; #endif //ok = false; break; @@ -437,7 +437,7 @@ Join::pre_var_handler() { #ifdef DEBUG_JOIN //for(int k = 0; k < valid_ans.size(); ++k) - //cout << this->kvstore->getPredicateByID(valid_ans[k])<kvstore->getPredicateByID(valid_ans[k])<id_pos != core_var_num + selected_pre_var_num) { - cout << "terrible error in copyToResult!" << endl; + cerr << "terrible error in copyToResult!" << endl; return; } #ifdef DEBUG_JOIN - cout << "core var num: " << core_var_num << " select var num: " << select_var_num << endl; + cerr << "core var num: " << core_var_num << " select var num: " << select_var_num << endl; #endif this->record_len = select_var_num + pre_var_num; this->record = new int[this->record_len]; @@ -515,7 +515,7 @@ Join::copyToResult() } #ifdef DEBUG_JOIN - //cout<<"current id_pos: "<id_pos<id_pos<id_pos) @@ -543,7 +543,7 @@ Join::copyToResult() if (this->basic_query->isSatelliteInJoin(id2) == false) continue; #ifdef DEBUG_JOIN - //cout << "to generate "<satellites.push_back(Satellite(id2, idlist, idlist_len)); #ifdef DEBUG_JOIN - //cout<<"push a new satellite in"<cartesian(0, size); #ifdef DEBUG_JOIN - //cout<<"after cartesian"<satellites.clear(); #ifdef DEBUG_JOIN - //cout<<"after clear the satellites"<record; #ifdef DEBUG_JOIN - //cout<<"after delete the record"<record = NULL; this->record_len = 0; @@ -723,17 +723,17 @@ Join::join() { case 0: //printf("use multi-join here!\n"); - cout << "use multi-join here!" << endl; + cerr << "use multi-join here!" << endl; ret = this->multi_join(); break; case 1: //printf("use index-join here!\n"); - cout << "use index-join here!" << endl; + cerr << "use index-join here!" << endl; ret = this->index_join(); break; default: //printf("ERROR: no method found!\n"); - cout << "ERROR: no method found!" << endl; + cerr << "ERROR: no method found!" << endl; break; } @@ -938,27 +938,27 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li if (this->new_start != this->current_table.end()) { //printf("now the new_start is:"); - cout << "now the new_start is:"; + cerr << "now the new_start is:"; for (RecordIterator it1 = this->new_start->begin(); it1 != this->new_start->end(); ++it1) { //printf(" %d", *it1); - cout << " " << *it1; + cerr << " " << *it1; } //printf("\n"); - cout << endl; + cerr << endl; } else //printf("new_start still in end?!\n"); - cout << "new_start still in end?!" << endl; + cerr << "new_start still in end?!" << endl; //printf("now the record is:"); - cout << "now the record is:"; + cerr << "now the record is:"; for (RecordIterator it1 = it0->begin(); it1 != it0->end(); ++it1) { //printf(" %d", *it1); - cout << " " << *it1; + cerr << " " << *it1; } //printf("\n"); - cout << endl; + cerr << endl; #endif int cnt = 0; @@ -973,7 +973,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li { #ifdef DEBUG_JOIN //printf("cnt is: %d\n", cnt); - cout << "cnt is: " << cnt << endl; + cerr << "cnt is: " << cnt << endl; #endif int edge_index = _edges[cnt]; if (edge_index == -1) @@ -981,7 +981,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li continue; } #ifdef DEBUG_JOIN - cout << "edge exists!" << endl; + cerr << "edge exists!" << endl; #endif int ele = *it1; int edge_type = this->basic_query->getEdgeType(_id, edge_index); @@ -990,7 +990,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li if (pre_id == -2) //predicate var { #ifdef DEBUG_JOIN - cout << "this is a predicate var!" << endl; + cerr << "this is a predicate var!" << endl; #endif //if(valid_ans_list == NULL) //{ @@ -1008,7 +1008,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li { #ifdef DEBUG_JOIN //printf("this is an edge to our id to join!\n"); - cout << "this is an edge to our id to join!" << endl; + cerr << "this is an edge to our id to join!" << endl; #endif if (pre_id == -2) this->kvstore->getobjIDlistBysubID(ele, id_list, id_list_len, true); @@ -1020,7 +1020,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li { #ifdef DEBUG_JOIN //printf("this is an edge from our id to join!\n"); - cout << "this is an edge from our id to join!" << endl; + cerr << "this is an edge from our id to join!" << endl; #endif if (pre_id == -2) this->kvstore->getsubIDlistByobjID(ele, id_list, id_list_len, true); @@ -1033,7 +1033,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li matched = false; #ifdef DEBUG_JOIN //printf("this id_list is empty!\n"); - cout << "this id_list is empty!" << endl; + cerr << "this id_list is empty!" << endl; #endif break; } @@ -1126,7 +1126,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li { #ifdef DEBUG_JOIN //printf("this record is matched!!\n"); - cout << "this record is matched!!" << endl; + cerr << "this record is matched!!" << endl; #endif found = true; //bool added = false; @@ -1158,7 +1158,7 @@ Join::new_join_with_multi_vars_not_prepared(vector& _edges, IDList& _can_li it0 = this->current_table.erase(it0); #ifdef DEBUG_JOIN //printf("this record is not matched!\n"); - cout << "this record is not matched!" << endl; + cerr << "this record is not matched!" << endl; #endif } delete valid_ans_list; @@ -1225,7 +1225,7 @@ Join::multi_join() IDList& start_table = this->basic_query->getCandidateList(this->start_id); int start_size = this->basic_query->getCandidateSize(this->start_id); #ifdef DEBUG_JOIN - cout << "the start size " << start_size << endl; + cerr << "the start size " << start_size << endl; #endif for (int i = 0; i < start_size; ++i) { @@ -1253,7 +1253,7 @@ Join::multi_join() this->mystack.push(this->start_id); #ifdef DEBUG_JOIN //fprintf(stderr, "now to start the stack loop\n"); - cout << "now to start the stack loop" << endl; + cerr << "now to start the stack loop" << endl; #endif while (!this->mystack.empty()) { @@ -1261,7 +1261,7 @@ Join::multi_join() #ifdef DEBUG_JOIN //fprintf(stderr, "the current id: %d\n", id); - cout << "the current id: " << id << endl; + cerr << "the current id: " << id << endl; #endif //int id = mystack[top]; int maxi = this->choose_next_node(id); @@ -1269,7 +1269,7 @@ Join::multi_join() { #ifdef DEBUG_JOIN //fprintf(stderr, "the node is totally dealed: %d\n", id); - cout << "the node is totally dealed: " << id << endl; + cerr << "the node is totally dealed: " << id << endl; #endif //top--; this->mystack.pop(); @@ -1278,11 +1278,11 @@ Join::multi_join() int id2 = this->basic_query->getEdgeNeighborID(id, maxi); #ifdef DEBUG_JOIN //fprintf(stderr, "the next node id to join: %d\n", id2); - cout << "the next node id to join: " << id2 << endl; + cerr << "the next node id to join: " << id2 << endl; #endif //this->filterBySatellites(id2); #ifdef DEBUG_JOIN - cout << "the start size " << this->basic_query->getCandidateSize(id2) << endl; + cerr << "the start size " << this->basic_query->getCandidateSize(id2) << endl; #endif //pre_id == -1 means we cannot find such predicate in rdf file, so the result set of this sparql should be empty. @@ -1329,7 +1329,7 @@ Join::multi_join() { #ifdef DEBUG_PRECISE //fprintf(stderr, "this var may contain literals: %d\n", id2); - cout << "this var may contain literals: " << id2 << endl; + cerr << "this var may contain literals: " << id2 << endl; #endif this->basic_query->setReady(id2); } @@ -1337,7 +1337,7 @@ Join::multi_join() { #ifdef DEBUG_PRECISE //fprintf(stderr, "this var not contain literals: %d\n", id2); - cout << "this var not contain literals: " << id2 << endl; + cerr << "this var not contain literals: " << id2 << endl; #endif } @@ -1351,7 +1351,7 @@ Join::multi_join() { #ifdef DEBUG_PRECISE //fprintf(stderr, "this edge uses prepared-join way\n"); - cout << "this edge uses prepared-join way" << endl; + cerr << "this edge uses prepared-join way" << endl; #endif this->acquire_all_id_lists(id_lists, id_lists_len, can_list, edges, id2, can_list_size); flag = this->new_join_with_multi_vars_prepared(id_lists, id_lists_len, edges, can_list, can_list_size); @@ -1368,7 +1368,7 @@ Join::multi_join() { #ifdef DEBUG_PRECISE //fprintf(stderr, "this edge uses not-prepared-join way\n"); - cout << "this edge uses not-prepared-join way" << endl; + cerr << "this edge uses not-prepared-join way" << endl; #endif flag = this->new_join_with_multi_vars_not_prepared(edges, can_list, can_list_size, id2, is_literal); } @@ -1378,7 +1378,7 @@ Join::multi_join() { #ifdef DEBUG_JOIN //fprintf(stderr, "the result is already empty!!\n"); - cout << "the result is already empty!!" << endl; + cerr << "the result is already empty!!" << endl; #endif //break; return false; //to avoid later invalid copy @@ -1400,7 +1400,7 @@ Join::multi_join() } #ifdef DEBUG_JOIN //fprintf(stderr, "now end the stack loop\n"); - cout << "now end the stack loop" << endl; + cerr << "now end the stack loop" << endl; #endif //BETTER?:though the whole current_table is ordered here, the @@ -1465,7 +1465,7 @@ Join::index_link(int _nid, int _idx) { #ifdef DEBUG_JOIN //fprintf(stderr, "this is an edge to our id to join!\n"); - cout << "this is an edge to our id to join!" << endl; + cerr << "this is an edge to our id to join!" << endl; #endif this->kvstore->getobjIDlistBysubIDpreID(it->value, pre_id, id_list, id_list_len, true); } @@ -1473,7 +1473,7 @@ Join::index_link(int _nid, int _idx) { #ifdef DEBUG_JOIN //fprintf(stderr, "this is an edge from our id to join!\n"); - cout << "this is an edge from our id to join!" << endl; + cerr << "this is an edge from our id to join!" << endl; #endif this->kvstore->getsubIDlistByobjIDpreID(it->value, pre_id, id_list, id_list_len, true); } @@ -1482,7 +1482,7 @@ Join::index_link(int _nid, int _idx) //id_list is NULL in this case #ifdef DEBUG_JOIN //fprintf(stderr, "this id_list is empty!\n"); - cout << "this id_list is empty!" << endl; + cerr << "this id_list is empty!" << endl; #endif continue; } @@ -1506,7 +1506,7 @@ Join::index_link(int _nid, int _idx) ret = --can2.end(); #ifdef DEBUG_JOIN //fprintf(stderr, "to add literal for free variable!\n"); - cout << "to add literal for free variable!" << endl; + cerr << "to add literal for free variable!" << endl; #endif } } @@ -1679,22 +1679,22 @@ Join::index_travel_two() //fprintf(stderr, "now to travel and store in current table\n"); - cout << "now to travel and store in current table" << endl; + cerr << "now to travel and store in current table" << endl; while (!this->mystack.empty()) { int id = this->mystack.top(); //fprintf(stderr, "the current id: %d\n", id); - cout << "the current id: " << id << endl; + cerr << "the current id: " << id << endl; if (this->index_lists[id].end()) //all linking of this index list are travelled { //fprintf(stderr, "the list is totally dealed: %d\n", id); - cout << "the list is totally dealed: " << id << endl; + cerr << "the list is totally dealed: " << id << endl; this->mystack.pop(); continue; } int id2 = this->index_lists[id].next(); //fprintf(stderr, "the next list id to travel: %d\n", id2); - cout << "the next list id to travel: " << id2 << endl; + cerr << "the next list id to travel: " << id2 << endl; bool flag = true; //NOTICE: we assume that the former node is all ok, scanning it to border @@ -1703,7 +1703,7 @@ Join::index_travel_two() if (!flag) { //fprintf(stderr, "the result is already empty!!\n"); - cout << "the result is already empty!!" << endl; + cerr << "the result is already empty!!" << endl; return false; //to avoid later invalid copy } int size = this->index_lists[id2].check_map.size(); @@ -1713,7 +1713,7 @@ Join::index_travel_two() if (!flag) { //fprintf(stderr, "the result is already empty!!\n"); - cout << "the result is already empty!!" << endl; + cerr << "the result is already empty!!" << endl; return false; //to avoid later invalid copy } } @@ -1747,23 +1747,23 @@ Join::index_join() this->add_id_pos_mapping(this->start_id); //fprintf(stderr, "now to start the stack loop\n"); - cout << "now to start the stack loop" << endl; + cerr << "now to start the stack loop" << endl; while (!this->mystack.empty()) { int id = this->mystack.top(); //fprintf(stderr, "the current id: %d\n", id); - cout << "the current id: " << id << endl; + cerr << "the current id: " << id << endl; int maxi = this->choose_next_node(id); if (maxi == -1) //all edges of this node are dealed { //fprintf(stderr, "the node is totally dealed: %d\n", id); - cout << "theh node is totally dealed: " << id << endl; + cerr << "theh node is totally dealed: " << id << endl; this->mystack.pop(); continue; } int id2 = this->basic_query->getEdgeNeighborID(id, maxi); //fprintf(stderr, "the next node id to join: %d\n", id2); - cout << "the next node id to join: " << id2 << endl; + cerr << "the next node id to join: " << id2 << endl; IDList& can_list = this->basic_query->getCandidateList(id2); //int can_list_size = can_list.size(); @@ -1771,10 +1771,10 @@ Join::index_join() bool is_literal = this->is_literal_var(id2); if (is_literal) //fprintf(stderr, "this var may contain literals: %d\n", id2); - cout << "this var may contain literals: " << id2 << endl; + cerr << "this var may contain literals: " << id2 << endl; else //fprintf(stderr, "this var not contain literals: %d\n", id2); - cout << "this var not contain literals: " << id2 << endl; + cerr << "this var not contain literals: " << id2 << endl; bool flag = true; //NOTICE: we assume that the former node is all ok, scanning it to border @@ -1784,7 +1784,7 @@ Join::index_join() if (!flag) { //fprintf(stderr, "the result is already empty!!\n"); - cout << "the result is already empty!!" << endl; + cerr << "the result is already empty!!" << endl; return false; //to avoid later invalid copy } int edge_index, edge_id = this->basic_query->getEdgeID(id, maxi); @@ -1801,7 +1801,7 @@ Join::index_join() if (!flag) { //fprintf(stderr, "the result is already empty!!\n"); - cout << "the result is already empty!!" << endl; + cerr << "the result is already empty!!" << endl; return false; //to avoid later invalid copy } @@ -1813,13 +1813,13 @@ Join::index_join() this->mystack.push(id2); } //fprintf(stderr, "now end the stack loop\n"); - cout << "now end the stack loop" << endl; + cerr << "now end the stack loop" << endl; // To travel and store in current_table, then do the last filter if (this->index_travel() == false) return false; //printf("now to filter through only_pre_filter_after_join\n"); - cout << "now to filter through only_pre_filter_after_join" << endl; + cerr << "now to filter through only_pre_filter_after_join" << endl; this->only_pre_filter_after_join(); //copy to result list, adjust the vars order @@ -1853,16 +1853,16 @@ bool Join::filter_before_join() { //fprintf(stderr, "*****IIIIIIN filter_before_join\n"); - cout << "*****IN filter_before_join" << endl; + cerr << "*****IN filter_before_join" << endl; for (int i = 0; i < this->var_num; i++) { bool flag = this->basic_query->isLiteralVariable(i); //fprintf(stderr, "\tVar%d %s\n", i, this->basic_query->getVarName(i).c_str()); - cout << "\tVar" << i << " " << this->basic_query->getVarName(i) << endl; + cerr << "\tVar" << i << " " << this->basic_query->getVarName(i) << endl; IDList &can_list = this->basic_query->getCandidateList(i); //fprintf(stderr, "\t\tsize of canlist before filter: %d\n", can_list.size()); - cout << "\t\tsize of canlist before filter: " << can_list.size() << endl; + cerr << "\t\tsize of canlist before filter: " << can_list.size() << endl; //NOTICE:must sort before using binary search. can_list.sort(); @@ -1870,12 +1870,12 @@ Join::filter_before_join() bool ret = this->constant_edge_filter(i); long after_constant_edge_filter = Util::get_cur_time(); //fprintf(stderr, "\t\tconstant_edge_filter: used %ld ms\n", after_constant_edge_filter - begin); - cout << "\t\tconstant_edge_filter: used " << (after_constant_edge_filter - begin) << " ms" << endl; + cerr << "\t\tconstant_edge_filter: used " << (after_constant_edge_filter - begin) << " ms" << endl; // this->preid_filter(this->basic_query, i); // long after_preid_filter = Util::get_cur_time(); //cout << "\t\tafter_preid_filter: used " << (after_preid_filter-after_literal_edge_filter) << " ms" << endl; //fprintf(stderr, "\t\t[%d] after filter, candidate size = %d\n\n\n", i, can_list.size()); - cout << "\t\t[" << i << "] after filter, candidate size= " << can_list.size() << endl << endl << endl; + cerr << "\t\t[" << i << "] after filter, candidate size= " << can_list.size() << endl << endl << endl; //debug // { @@ -1895,7 +1895,7 @@ Join::filter_before_join() } } //fprintf(stderr, "OOOOOOUT filter_before_join\n"); - cout << "OUT filter_before_join" << endl; + cerr << "OUT filter_before_join" << endl; return true; } @@ -1911,7 +1911,7 @@ Join::constant_edge_filter(int _var_i) { int neighbor_id = this->basic_query->getEdgeNeighborID(_var_i, j); //fprintf(stderr, "\t\t\tneighbor_id=%d\n", neighbor_id); - cout << "\t\t\tneighbor_id=" << neighbor_id << endl; + cerr << "\t\t\tneighbor_id=" << neighbor_id << endl; if (neighbor_id != -1) //variables in join not considered here { continue; @@ -2259,11 +2259,11 @@ Join::filterBySatellites(int _var) //not consider edge with constant neighbors here if (neighbor[0] != '?') { - //cout << "not to filter: " << neighbor_name << endl; + //cerr << "not to filter: " << neighbor_name << endl; continue; } //else - //cout << "need to filter: " << neighbor_name << endl; + //cerr << "need to filter: " << neighbor_name << endl; int pre_id = this->basic_query->getEdgePreID(_var, i); //WARN+BETTER:invalid(should be discarded in Query) or ?p(should not be considered here) @@ -2368,7 +2368,7 @@ Join::filterBySatellites(int _var) //if (!is_literal_var(_var) && valid_list != NULL && valid_list->empty()) //{ - // //cout << "quit when empty in edge"<kvstore->getsubIDlistBypreID(preid, list, len); - // //cout<<"p2s len "< len) @@ -2433,7 +2433,7 @@ Join::filterBySatellites(int _var) //if (!is_literal_var(_var) && valid_list->empty()) //{ - // //cout << "quit when empty out edge"<basic_query->isOneDegreeNotJoinVar(neighbor_name)); if (!only_preid_filter) { - //cout << "not to filter: " << neighbor_name << endl; + //cerr << "not to filter: " << neighbor_name << endl; continue; } //else - //cout << "need to filter: " << neighbor_name << endl; + //cerr << "need to filter: " << neighbor_name << endl; int pre_id = this->basic_query->getEdgePreID(var_id, i); if (pre_id < 0) diff --git a/garbage/SSTree/storage/Storage.cpp b/garbage/SSTree/storage/Storage.cpp index 93bf5b19..3fb40d13 100644 --- a/garbage/SSTree/storage/Storage.cpp +++ b/garbage/SSTree/storage/Storage.cpp @@ -205,7 +205,7 @@ Storage::AllocBlock() } if(this->cur_block_num >= Storage::MAX_BLOCK_NUM) { - cout << "Error in ISStorage::AllocBlock() - cur_block_num overflow" << endl; + cerr << "Error in ISStorage::AllocBlock() - cur_block_num overflow" << endl; } p = this->freelist->next; } diff --git a/garbage/gconsole.cpp b/garbage/gconsole.cpp index ae061488..5018af20 100644 --- a/garbage/gconsole.cpp +++ b/garbage/gconsole.cpp @@ -144,7 +144,7 @@ main(int argc, char **argv) { cout << "Type \"?\" or \"help\" in the console to see info of all commands" << endl; if (argc > 2) { - cout << "Nonsense to add more parameters!" << endl; + cerr << "Nonsense to add more parameters!" << endl; } return 0; } @@ -152,14 +152,14 @@ main(int argc, char **argv) { if (argc != 3) { - cout << "You should just add one script file to be sourced!" << endl; + cerr << "You should just add one script file to be sourced!" << endl; return 1; } return deal_with_script(argv[2]); } else { - cout << "Wrong option used, please see the help info first!" << endl; + cerr << "Wrong option used, please see the help info first!" << endl; return 1; } } @@ -189,7 +189,7 @@ main(int argc, char **argv) { if (current_database != NULL) { - cout << endl << "Please unload your database before quiting!" << endl << endl; + cerr << endl << "Please unload your database before quiting!" << endl << endl; continue; } cout << endl << endl; @@ -368,7 +368,7 @@ int deal_with_script(char* file) { FILE* fp = NULL; if ((fp = fopen(file, "r")) == NULL) { - cout << "Open error: " << file << endl; + cerr << "Open error: " << file << endl; return -1; } @@ -391,12 +391,12 @@ int deal_with_script(char* file) { //end of file if (current_database != NULL) { - cout << endl << "Please unload your database before quitting!" << endl << endl; + cerr << endl << "Please unload your database before quitting!" << endl << endl; //TODO } if (gc != NULL) { - cout << endl << "Please return to native mode before quitting!" << endl << endl; + cerr << endl << "Please return to native mode before quitting!" << endl << endl; //TODO } @@ -430,7 +430,7 @@ bool parse_arguments(char* word, vector& args) { continue; } else { - cout << "Invalid arguments!" << endl; + cerr << "Invalid arguments!" << endl; return false; } } @@ -604,7 +604,7 @@ int help_handler(const vector& args) { } if (printed == 0) { - cout << "No commands match \"" << args[0] << "\". Possibilities are:" << endl; + cerr << "No commands match \"" << args[0] << "\". Possibilities are:" << endl; for (i = 0; current_commands[i].name; i++) { @@ -627,7 +627,7 @@ int help_handler(const vector& args) { } default: { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } } @@ -637,7 +637,7 @@ int help_handler(const vector& args) { //NOTICE:the SPARQL file to be used should be placed in the local machine even when in remote mode int source_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } @@ -649,17 +649,17 @@ int source_handler(const vector& args) { int quit_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc != NULL) { - cout << "This command cannot be used when in remote mode." << endl; + cerr << "This command cannot be used when in remote mode." << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database before quitting." << endl; + cerr << "Please unload your database before quitting." << endl; return -1; } @@ -669,17 +669,17 @@ int quit_handler(const vector& args) { int connect_handler(const vector& args) { if (args.size() > 2) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc != NULL) { - cout << "This command cannot be used when in remote mode." << endl; + cerr << "This command cannot be used when in remote mode." << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database before entering remote mode." << endl; + cerr << "Please unload your database before entering remote mode." << endl; return -1; } @@ -688,12 +688,12 @@ int connect_handler(const vector& args) { if (args.size() == 2) { if (!Util::isValidIP(args[0])) { - cout << "Invalid IP: " << args[0] << endl; + cerr << "Invalid IP: " << args[0] << endl; return -1; } if (!Util::isValidPort(args[1])) { - cout << "Invalid Port: " << args[1] << endl; + cerr << "Invalid Port: " << args[1] << endl; return -1; } @@ -708,7 +708,7 @@ int connect_handler(const vector& args) { stringstream(args[0]) >> port; } else { - cout << "Invalid argument, neither IP nor port: " << args[0] << endl; + cerr << "Invalid argument, neither IP nor port: " << args[0] << endl; return -1; } } @@ -717,7 +717,7 @@ int connect_handler(const vector& args) { gc = new GstoreConnector(ip, port); if (!gc->test()) { - cout << "Failed to connect to server at " << ip << ':' << port << endl; + cerr << "Failed to connect to server at " << ip << ':' << port << endl; delete gc; gc = NULL; return -1; @@ -731,12 +731,12 @@ int connect_handler(const vector& args) { int disconnect_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (gc == NULL) { - cout << "This command cannot be used when in native mode." << endl; + cerr << "This command cannot be used when in native mode." << endl; return -1; } @@ -744,7 +744,7 @@ int disconnect_handler(const vector& args) { if (show_ret != "connect to server error" && show_ret != "send show command error." && show_ret != "\n[empty]\n") { - cout << "Please unload your server database before entering native mode." << endl; + cerr << "Please unload your server database before entering native mode." << endl; return -1; } @@ -759,7 +759,7 @@ int disconnect_handler(const vector& args) { int show_handler(const vector& args) { if (args.size() > 1) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } @@ -769,7 +769,7 @@ int show_handler(const vector& args) flag = true; } else { - cout << "Invalid argument: " << args[0] << endl; + cerr << "Invalid argument: " << args[0] << endl; return -1; } } @@ -803,7 +803,7 @@ int show_handler(const vector& args) //NOTICE: for build() and load(), always keep database in the root of gStore int build_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } @@ -811,7 +811,7 @@ int build_handler(const vector& args) { //WARN:user better not end with ".db" by themselves!!! if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "Your db name to be built should not end with \".db\"." << endl; + cerr << "Your db name to be built should not end with \".db\"." << endl; return -1; } database += ".db"; @@ -835,7 +835,7 @@ int build_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please unload your database first." << endl; + cerr << "Please unload your database first." << endl; return -1; } @@ -847,7 +847,7 @@ int build_handler(const vector& args) { current_database = NULL; if (!flag) { - cout << "Import RDF file to database failed." << endl; + cerr << "Import RDF file to database failed." << endl; string cmd = "rm -rf " + database; system(cmd.c_str()); return -1; @@ -859,14 +859,14 @@ int build_handler(const vector& args) { int drop_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } //only drop when *.db, avoid other files be removed string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } database += ".db"; @@ -882,7 +882,7 @@ int drop_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please do not use this command when you are using a database." << endl; + cerr << "Please do not use this command when you are using a database." << endl; return -1; } @@ -899,13 +899,13 @@ int drop_handler(const vector& args) { int load_handler(const vector& args) { if (args.size() != 1) { - cout << "Exactly 1 argument is required!" << endl; + cerr << "Exactly 1 argument is required!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } database += ".db"; @@ -921,14 +921,14 @@ int load_handler(const vector& args) { } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } current_database = new Database(database); bool flag = current_database->load(); if (!flag) { - cout << "Failed to load the database." << endl; + cerr << "Failed to load the database." << endl; delete current_database; current_database = NULL; return -1; @@ -941,7 +941,7 @@ int load_handler(const vector& args) { int unload_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } @@ -951,7 +951,7 @@ int unload_handler(const vector& args) { string database = gc->show(); if (database == "\n[empty]\n") { - cout << "No database used now." << endl; + cerr << "No database used now." << endl; return -1; } if (gc->unload(database.substr(1, database.length() - 2))) { @@ -964,7 +964,7 @@ int unload_handler(const vector& args) { if (current_database == NULL) { - cout << "No database used now." << endl; + cerr << "No database used now." << endl; return -1; } @@ -978,16 +978,16 @@ int unload_handler(const vector& args) { int query_handler(const vector& args) { if (gc == NULL) { if (args.size() != 1) { - cout << "Exactly 1 argument required!" << endl; + cerr << "Exactly 1 argument required!" << endl; return -1; } if (current_database == NULL) { - cout << "No database in use!" << endl; + cerr << "No database in use!" << endl; return -1; } } else if (args.size() != 1 && !(args.size() == 3 && args[1] == "-r")) { - cout << "Invalid arguments!" << endl; + cerr << "Invalid arguments!" << endl; return -1; } @@ -1002,7 +1002,7 @@ int query_handler(const vector& args) { const char *path = ret.c_str(); if (path == NULL) { - cout << "Invalid path of query." << endl; + cerr << "Invalid path of query." << endl; return -1; } #ifdef DEBUG @@ -1012,7 +1012,7 @@ int query_handler(const vector& args) { } if (sparql.empty()) { - cout << "Empty SPARQL." << endl; + cerr << "Empty SPARQL." << endl; return -1; } @@ -1053,22 +1053,22 @@ int query_handler(const vector& args) { int add_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } database += ".db"; Database _db(database); if (!_db.insert(args[1])) { - cout << "Failed to insert!" << endl; + cerr << "Failed to insert!" << endl; return -1; } return 0; @@ -1076,21 +1076,21 @@ int add_handler(const vector& args) { int sub_handler(const vector& args) { if (args.size() != 2) { - cout << "Exactly 2 arguments required!" << endl; + cerr << "Exactly 2 arguments required!" << endl; return -1; } if (current_database != NULL) { - cout << "Please unload your database first!" << endl; + cerr << "Please unload your database first!" << endl; return -1; } string database = args[0]; if (database.length() > 3 && database.substr(database.length() - 3, 3) == ".db") { - cout << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; + cerr << "You should use exactly the same db name as building, which should not end with \".db\"" << endl; return -1; } database += ".db"; Database _db(database); if (!_db.remove(args[1])) { - cout << "Failed to remove!" << endl; + cerr << "Failed to remove!" << endl; return -1; } return 0; @@ -1098,7 +1098,7 @@ int sub_handler(const vector& args) { int start_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -s"); @@ -1106,7 +1106,7 @@ int start_handler(const vector& args) { int stop_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -t"); @@ -1114,7 +1114,7 @@ int stop_handler(const vector& args) { int restart_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -r"); @@ -1122,14 +1122,14 @@ int restart_handler(const vector& args) { int port_handler(const vector& args) { if (args.size() > 1) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } if (args.empty()) { return system("bin/gserver -p"); } if (!Util::isValidPort(args[0])) { - cout << "Invalid port: " << args[0] << endl; + cerr << "Invalid port: " << args[0] << endl; return -1; } string cmd = "bin/gserver -p " + args[0]; @@ -1138,7 +1138,7 @@ int port_handler(const vector& args) { int printport_handler(const vector& args) { if (!args.empty()) { - cout << "Too many arguments!" << endl; + cerr << "Too many arguments!" << endl; return -1; } return system("bin/gserver -P"); diff --git a/garbage/signature_bind/Signature.cpp b/garbage/signature_bind/Signature.cpp index c2e3d197..03ca645a 100644 --- a/garbage/signature_bind/Signature.cpp +++ b/garbage/signature_bind/Signature.cpp @@ -139,7 +139,7 @@ Signature::BitSet2str(const EntityBitSet& _bitset) //else if (_str[0] != '<') //{ //#ifdef DEBUG_VSTREE - //cout << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; + //cerr << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; //#endif //} //_entity_bs.set(pos); diff --git a/garbage/signature_separate/Signature.cpp b/garbage/signature_separate/Signature.cpp index 92becd86..4c9e7ee8 100644 --- a/garbage/signature_separate/Signature.cpp +++ b/garbage/signature_separate/Signature.cpp @@ -139,7 +139,7 @@ Signature::encodeStr2Entity(const char* _str, EntityBitSet& _entity_bs) else if (_str[0] != '<') { #ifdef DEBUG_VSTREE - cout << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; + cerr << "error in encodeStr2Entity(): neighbor is neither a literal or entity!" << endl; #endif } _entity_bs.set(pos); diff --git a/scripts/dataset_test.cpp b/scripts/dataset_test.cpp index 63fd053a..16282b14 100644 --- a/scripts/dataset_test.cpp +++ b/scripts/dataset_test.cpp @@ -52,7 +52,7 @@ int main(int argc, char * argv[]) if (flag) { string msg = db_name + ".db is built done."; - cout << msg << endl; + cerr << msg << endl; ofstream f; f.open("./" + db_name + ".db/success.txt"); f.close(); @@ -62,7 +62,7 @@ int main(int argc, char * argv[]) else //if fails, drop databsase and return { string msg = db_name + ".db is built failed."; - cout << msg << endl; + cerr << msg << endl; string cmd = "rm -r " + db_name + ".db"; system(cmd.c_str()); delete db; @@ -95,7 +95,7 @@ int main(int argc, char * argv[]) if (!file.eof()) { string msg = "query " + sparql.top() + " in " + db_name + ".db exists errors"; - cout << msg << endl; + cerr << msg << endl; string cmd = "rm ans_sorted.txt diff.txt"; system(cmd.c_str()); sparql.pop(); @@ -107,7 +107,7 @@ int main(int argc, char * argv[]) else { string msg = "query " + sparql.top() + " in " + db_name + ".db has passed"; - cout << msg << endl; + cerr << msg << endl; string cmd = "rm ans_sorted.txt diff.txt"; system(cmd.c_str()); sparql.pop(); @@ -119,6 +119,6 @@ int main(int argc, char * argv[]) string cmd = "rm -r " + db_name + ".db"; system(cmd.c_str()); string msg = db_name + ".db test passed"; - cout << msg << endl; + cerr << msg << endl; return 0; } diff --git a/scripts/update_test.cpp b/scripts/update_test.cpp index be7b09c9..339dd63d 100644 --- a/scripts/update_test.cpp +++ b/scripts/update_test.cpp @@ -88,14 +88,14 @@ Database* db; void print() { - cout << "update_triples:" << endl; + cerr << "update_triples:" << endl; std::set::iterator it1; for (it1 = update_triples.begin(); it1 != update_triples.end(); it1++) - cout << it1->subject << " " << it1->predicate << "" << it1->object << endl; - cout << "db_triples:" << endl; + cerr << it1->subject << " " << it1->predicate << "" << it1->object << endl; + cerr << "db_triples:" << endl; std::set::iterator it2; for (it2 = db_triples.begin(); it2 != db_triples.end(); it2++) - cout << it2->subject << " " << it2->predicate << "" << it2->object << endl; + cerr << it2->subject << " " << it2->predicate << "" << it2->object << endl; } int main(int argc, char * argv[]) @@ -180,7 +180,7 @@ int main(int argc, char * argv[]) if (flag) { string msg = db_name + ".db is built done."; - cout << msg << endl; + cerr << msg << endl; ofstream f; f.open("./" + db_name + ".db/success.txt"); f.close(); @@ -188,7 +188,7 @@ int main(int argc, char * argv[]) else //if fails, drop database and return { string msg = db_name + ".db is built failed."; - cout << msg << endl; + cerr << msg << endl; string cmd = "rm -r " + db_name + ".db"; system(cmd.c_str()); delete db; @@ -254,7 +254,7 @@ int main(int argc, char * argv[]) //print(); if (update_triples.size() != db_triples.size()) { - cout << "Update triples exist errors." << endl; + cerr << "Update triples exist errors." << endl; delete db; db = NULL; string cmd = "rm -r " + db_name + ".db"; @@ -269,7 +269,7 @@ int main(int argc, char * argv[]) continue; else { - cout << "Update triples exist errors." << endl; + cerr << "Update triples exist errors." << endl; delete db; db = NULL; string cmd = "rm -r " + db_name + ".db"; @@ -325,7 +325,7 @@ int main(int argc, char * argv[]) int ret = db->query(query, delete_rs, delete_ofp); if (triple_num != (update_num + db->getTripleNum())) { - cout << "Delete triples exist errors." << endl; + cerr << "Delete triples exist errors." << endl; delete update; update = NULL; delete db; @@ -343,7 +343,7 @@ int main(int argc, char * argv[]) int ret = db->query(query, ask_rs, ask_ofp); if (ask_rs.answer[0][0] == "true") { - cout << "Delete triples exist errors." << endl; + cerr << "Delete triples exist errors." << endl; delete update; update = NULL; delete db; @@ -362,7 +362,7 @@ int main(int argc, char * argv[]) ret = db->query(query, insert_rs, insert_ofp); if (temp_num != (db->getTripleNum() - update_num)) { - cout << "Insert triples exist errors." << endl; + cerr << "Insert triples exist errors." << endl; delete update; update = NULL; delete db; @@ -380,7 +380,7 @@ int main(int argc, char * argv[]) ret = db->query(query, ask_rs, ask_ofp); if (ask_rs.answer[0][0] == "false") { - cout << "Insert triples exist errors." << endl; + cerr << "Insert triples exist errors." << endl; delete update; update = NULL; delete db; @@ -397,6 +397,6 @@ int main(int argc, char * argv[]) string cmd = "rm -r " + db_name + ".db"; system(cmd.c_str()); } - cout << "Test passed!" << endl; + cerr << "Test passed!" << endl; return 0; } \ No newline at end of file