style: add get_data_time to print query logs
This commit is contained in:
parent
f21d1e0f8f
commit
11edefed54
|
@ -2630,10 +2630,10 @@ Database::insertTriple(const TripleWithObjType& _triple, vector<unsigned>* _vert
|
|||
long tv_vs_store_end = Util::get_cur_time();
|
||||
|
||||
//debug
|
||||
{
|
||||
cout << "update kv_store, used " << (tv_kv_store_end - tv_kv_store_begin) << "ms." << endl;
|
||||
cout << "update vs_store, used " << (tv_vs_store_end - tv_kv_store_end) << "ms." << endl;
|
||||
}
|
||||
//{
|
||||
//cout << "update kv_store, used " << (tv_kv_store_end - tv_kv_store_begin) << "ms." << endl;
|
||||
//cout << "update vs_store, used " << (tv_vs_store_end - tv_kv_store_end) << "ms." << endl;
|
||||
//}
|
||||
|
||||
return true;
|
||||
//return updateLen;
|
||||
|
@ -2677,12 +2677,12 @@ Database::removeTriple(const TripleWithObjType& _triple, vector<unsigned>* _vert
|
|||
this->triples_num--;
|
||||
}
|
||||
|
||||
cout << "triple existence checked" << endl;
|
||||
//cout << "triple existence checked" << endl;
|
||||
|
||||
//remove from sp2o op2s s2po o2ps s2o o2s
|
||||
//sub2id, pre2id and obj2id will not be updated
|
||||
(this->kvstore)->updateTupleslist_remove(_sub_id, _pre_id, _obj_id);
|
||||
cout << "11 trees updated" << endl;
|
||||
//cout << "11 trees updated" << endl;
|
||||
|
||||
long tv_kv_store_end = Util::get_cur_time();
|
||||
|
||||
|
@ -2690,8 +2690,8 @@ Database::removeTriple(const TripleWithObjType& _triple, vector<unsigned>* _vert
|
|||
//if subject become an isolated point, remove its corresponding entry
|
||||
if (sub_degree == 0)
|
||||
{
|
||||
cout<<"to remove entry for sub"<<endl;
|
||||
cout<<_sub_id << " "<<this->kvstore->getEntityByID(_sub_id)<<endl;
|
||||
//cout<<"to remove entry for sub"<<endl;
|
||||
//cout<<_sub_id << " "<<this->kvstore->getEntityByID(_sub_id)<<endl;
|
||||
this->kvstore->subEntityByID(_sub_id);
|
||||
this->kvstore->subIDByEntity(_triple.subject);
|
||||
//(this->vstree)->removeEntry(_sub_id);
|
||||
|
@ -2784,10 +2784,10 @@ Database::removeTriple(const TripleWithObjType& _triple, vector<unsigned>* _vert
|
|||
long tv_vs_store_end = Util::get_cur_time();
|
||||
|
||||
//debug
|
||||
{
|
||||
cout << "update kv_store, used " << (tv_kv_store_end - tv_kv_store_begin) << "ms." << endl;
|
||||
cout << "update vs_store, used " << (tv_vs_store_end - tv_kv_store_end) << "ms." << endl;
|
||||
}
|
||||
//{
|
||||
//cout << "update kv_store, used " << (tv_kv_store_end - tv_kv_store_begin) << "ms." << endl;
|
||||
//cout << "update vs_store, used " << (tv_vs_store_end - tv_kv_store_end) << "ms." << endl;
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,19 +244,14 @@ int initialize(int argc, char *argv[])
|
|||
//server.resource["^/load/(.*)$"]["GET"]=[&server](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> request) {
|
||||
|
||||
string database = db_name;
|
||||
if(database != "")
|
||||
if(current_database == NULL && database != "")
|
||||
{
|
||||
if(database.length() > 3 && database.substr(database.length()-3, 3) == ".db")
|
||||
{
|
||||
cout << "Your db name to be built should not end with \".db\"." << endl;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(current_database != NULL)
|
||||
{
|
||||
cout << "Please unload your current database first." << endl;
|
||||
return 0;
|
||||
}
|
||||
cout << database << endl;
|
||||
current_database = new Database(database);
|
||||
bool flag = current_database->load();
|
||||
|
@ -265,7 +260,7 @@ int initialize(int argc, char *argv[])
|
|||
cout << "Failed to load the database."<<endl;
|
||||
delete current_database;
|
||||
current_database = NULL;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
//string success = db_name;
|
||||
cout << "Database loaded successfully."<<endl;
|
||||
|
@ -768,7 +763,9 @@ bool query_handler(const HttpServer& server, const shared_ptr<HttpServer::Respon
|
|||
}
|
||||
|
||||
ResultSet rs;
|
||||
int query_time = Util::get_cur_time();
|
||||
bool ret = current_database->query(sparql, rs, output);
|
||||
query_time = Util::get_cur_time() - query_time;
|
||||
if (timer != 0 && !stop_thread(timer)) {
|
||||
cerr << "Failed to stop timer." << endl;
|
||||
}
|
||||
|
@ -810,8 +807,10 @@ bool query_handler(const HttpServer& server, const shared_ptr<HttpServer::Respon
|
|||
cout << queryLog << "can't open." << endl;
|
||||
return false;
|
||||
}
|
||||
outlog << Util::get_date_time() << endl;
|
||||
outlog << sparql << endl << endl;
|
||||
outlog << "answer num: "<<rs.ansNum << endl;
|
||||
outlog << "query time: "<<query_time <<" ms"<< endl;
|
||||
outlog << "-----------------------------------------------------------" << endl;
|
||||
outlog.close();
|
||||
|
||||
|
|
|
@ -750,6 +750,16 @@ Util::get_cur_time()
|
|||
return (tv.tv_sec*1000 + tv.tv_usec/1000);
|
||||
}
|
||||
|
||||
string
|
||||
Util::get_date_time()
|
||||
{
|
||||
time_t timep;
|
||||
time(&timep);
|
||||
char tmp[64];
|
||||
strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S",localtime(&timep) );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
bool
|
||||
Util::save_to_file(const char* _dir, const string _content)
|
||||
{
|
||||
|
|
|
@ -320,6 +320,7 @@ public:
|
|||
static bool create_file(const std::string _file);
|
||||
|
||||
static long get_cur_time();
|
||||
static std::string get_date_time();
|
||||
static bool save_to_file(const char*, const std::string _content);
|
||||
static bool isValidPort(std::string);
|
||||
static bool isValidIP(std::string);
|
||||
|
|
Loading…
Reference in New Issue