parent
647d789caa
commit
4db4bb651c
|
@ -77,7 +77,7 @@ bool Database::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
(this->kvstore)->open();
|
(this->kvstore)->open();
|
||||||
//cout << "finish load" << endl;
|
cout << "finish load" << endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -103,37 +103,37 @@ bool Database::query(const string _query, ResultSet& _result_set)
|
||||||
_parser.sparqlParser(_query, _sparql_q);
|
_parser.sparqlParser(_query, _sparql_q);
|
||||||
|
|
||||||
long tv_parse = util::get_cur_time();
|
long tv_parse = util::get_cur_time();
|
||||||
//cout << "after Parsing, used " << (tv_parse - tv_begin) << endl;
|
cout << "after Parsing, used " << (tv_parse - tv_begin) << endl;
|
||||||
//cout << "after Parsing..." << endl << _sparql_q.triple_str() << endl;
|
cout << "after Parsing..." << endl << _sparql_q.triple_str() << endl;
|
||||||
|
|
||||||
_sparql_q.encodeQuery(this->kvstore);
|
_sparql_q.encodeQuery(this->kvstore);
|
||||||
|
|
||||||
//cout << "sparqlSTR:\t" << _sparql_q.to_str() << endl;
|
cout << "sparqlSTR:\t" << _sparql_q.to_str() << endl;
|
||||||
|
|
||||||
long tv_encode = util::get_cur_time();
|
long tv_encode = util::get_cur_time();
|
||||||
//cout << "after Encode, used " << (tv_encode - tv_parse) << "ms." << endl;
|
cout << "after Encode, used " << (tv_encode - tv_parse) << "ms." << endl;
|
||||||
|
|
||||||
_result_set.select_var_num = _sparql_q.getQueryVarNum();
|
_result_set.select_var_num = _sparql_q.getQueryVarNum();
|
||||||
|
|
||||||
(this->vstree)->retrieve(_sparql_q);
|
(this->vstree)->retrieve(_sparql_q);
|
||||||
|
|
||||||
long tv_retrieve = util::get_cur_time();
|
long tv_retrieve = util::get_cur_time();
|
||||||
//cout << "after Retrieve, used " << (tv_retrieve - tv_encode) << "ms." << endl;
|
cout << "after Retrieve, used " << (tv_retrieve - tv_encode) << "ms." << endl;
|
||||||
|
|
||||||
this->join(_sparql_q);
|
this->join(_sparql_q);
|
||||||
|
|
||||||
long tv_join = util::get_cur_time();
|
long tv_join = util::get_cur_time();
|
||||||
//cout << "after Join, used " << (tv_join - tv_retrieve) << "ms." << endl;
|
cout << "after Join, used " << (tv_join - tv_retrieve) << "ms." << endl;
|
||||||
|
|
||||||
this->getFinalResult(_sparql_q, _result_set);
|
this->getFinalResult(_sparql_q, _result_set);
|
||||||
|
|
||||||
long tv_final = util::get_cur_time();
|
long tv_final = util::get_cur_time();
|
||||||
//cout << "after finalResult, used " << (tv_final - tv_join) << "ms." << endl;
|
cout << "after finalResult, used " << (tv_final - tv_join) << "ms." << endl;
|
||||||
|
|
||||||
//cout << "Total time used: " << (tv_final - tv_begin) << "ms." << endl;
|
cout << "Total time used: " << (tv_final - tv_begin) << "ms." << endl;
|
||||||
|
|
||||||
//testing...
|
//testing...
|
||||||
//cout << "final result is : " << endl;
|
cout << "final result is : " << endl;
|
||||||
cout << _result_set.to_str() << endl;
|
cout << _result_set.to_str() << endl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ bool Database::insert(const string& _insert_rdf_file)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//cout << "finish loading" << endl;
|
cout << "finish loading" << endl;
|
||||||
|
|
||||||
long tv_load = util::get_cur_time();
|
long tv_load = util::get_cur_time();
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ bool Database::insert(const string& _insert_rdf_file)
|
||||||
stringstream _ss;
|
stringstream _ss;
|
||||||
_ss << "finish rdfparser" << insert_triple_num << endl;
|
_ss << "finish rdfparser" << insert_triple_num << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parse_triple_num == 0)
|
if(parse_triple_num == 0)
|
||||||
|
@ -208,7 +208,7 @@ bool Database::insert(const string& _insert_rdf_file)
|
||||||
}
|
}
|
||||||
|
|
||||||
long tv_insert = util::get_cur_time();
|
long tv_insert = util::get_cur_time();
|
||||||
//cout << "after insert, used " << (tv_insert - tv_load) << "ms." << endl;
|
cout << "after insert, used " << (tv_insert - tv_load) << "ms." << endl;
|
||||||
|
|
||||||
flag = this->vstree->saveTree();
|
flag = this->vstree->saveTree();
|
||||||
if (!flag)
|
if (!flag)
|
||||||
|
@ -223,7 +223,7 @@ bool Database::insert(const string& _insert_rdf_file)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "insert rdf triples done." << endl;
|
cout << "insert rdf triples done." << endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -247,20 +247,20 @@ bool Database::build(const string& _rdf_file)
|
||||||
std::string vstree_store_path = store_path + "/vs_store";
|
std::string vstree_store_path = store_path + "/vs_store";
|
||||||
util::create_dir(vstree_store_path);
|
util::create_dir(vstree_store_path);
|
||||||
|
|
||||||
//cout << "begin encode RDF from : " << _rdf_file << " ..." << endl;
|
cout << "begin encode RDF from : " << _rdf_file << " ..." << endl;
|
||||||
// to be switched to new encodeRDF method.
|
// to be switched to new encodeRDF method.
|
||||||
// this->encodeRDF(_rdf_file);
|
// this->encodeRDF(_rdf_file);
|
||||||
this->encodeRDF_new(_rdf_file);
|
this->encodeRDF_new(_rdf_file);
|
||||||
//cout << "finish encode." << endl;
|
cout << "finish encode." << endl;
|
||||||
std::string _entry_file = this->getSignatureBFile();
|
std::string _entry_file = this->getSignatureBFile();
|
||||||
(this->kvstore)->open();
|
(this->kvstore)->open();
|
||||||
|
|
||||||
//cout << "begin build VS-Tree on " << _rdf_file << "..." << endl;
|
cout << "begin build VS-Tree on " << _rdf_file << "..." << endl;
|
||||||
(this->vstree)->buildTree(_entry_file);
|
(this->vstree)->buildTree(_entry_file);
|
||||||
|
|
||||||
long tv_build_end = util::get_cur_time();
|
long tv_build_end = util::get_cur_time();
|
||||||
//cout << "after build, used " << (tv_build_end - tv_build_begin) << "ms." << endl;
|
cout << "after build, used " << (tv_build_end - tv_build_begin) << "ms." << endl;
|
||||||
//cout << "finish build VS-Tree." << endl;
|
cout << "finish build VS-Tree." << endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ bool Database::sub2id_pre2id_obj2id_RDFintoSignature(const string _rdf_file, int
|
||||||
stringstream _ss;
|
stringstream _ss;
|
||||||
_ss << "finish rdfparser" << this->triples_num << endl;
|
_ss << "finish rdfparser" << this->triples_num << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
if(parse_triple_num == 0){
|
if(parse_triple_num == 0){
|
||||||
break;
|
break;
|
||||||
|
@ -753,7 +753,7 @@ bool Database::sub2id_pre2id_obj2id_RDFintoSignature(const string _rdf_file, int
|
||||||
_ss << "preNum is " << this->pre_num << endl;
|
_ss << "preNum is " << this->pre_num << endl;
|
||||||
_ss << "literalNum is " << this->literal_num << endl;
|
_ss << "literalNum is " << this->literal_num << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -809,7 +809,7 @@ bool Database::sub2id_pre2id(const string _rdf_file, int**& _p_id_tuples, int &
|
||||||
stringstream _ss;
|
stringstream _ss;
|
||||||
_ss << "finish rdfparser" << this->triples_num << endl;
|
_ss << "finish rdfparser" << this->triples_num << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
if(parse_triple_num == 0){
|
if(parse_triple_num == 0){
|
||||||
break;
|
break;
|
||||||
|
@ -880,7 +880,7 @@ bool Database::sub2id_pre2id(const string _rdf_file, int**& _p_id_tuples, int &
|
||||||
_ss << "subNum is " << this->sub_num << endl;
|
_ss << "subNum is " << this->sub_num << endl;
|
||||||
_ss << "preNum is " << this->pre_num << endl;
|
_ss << "preNum is " << this->pre_num << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -937,7 +937,7 @@ bool Database::literal2id_RDFintoSignature(const string _rdf_file, int** _p_id_t
|
||||||
stringstream _ss;
|
stringstream _ss;
|
||||||
_ss << "finish rdfparser" << _i_tuples << endl;
|
_ss << "finish rdfparser" << _i_tuples << endl;
|
||||||
Database::log(_ss.str());
|
Database::log(_ss.str());
|
||||||
//cout << _ss.str() << endl;
|
cout << _ss.str() << endl;
|
||||||
}
|
}
|
||||||
if(parse_triple_num == 0){
|
if(parse_triple_num == 0){
|
||||||
break;
|
break;
|
||||||
|
@ -1021,7 +1021,7 @@ bool Database::literal2id_RDFintoSignature(const string _rdf_file, int** _p_id_t
|
||||||
|
|
||||||
}/* end for while(true) */
|
}/* end for while(true) */
|
||||||
|
|
||||||
//cout << "end for while" << endl;
|
cout << "end for while" << endl;
|
||||||
delete[] triple_array;
|
delete[] triple_array;
|
||||||
_six_tuples_fout.close();
|
_six_tuples_fout.close();
|
||||||
_fin.close();
|
_fin.close();
|
||||||
|
@ -1764,13 +1764,13 @@ bool Database::join
|
||||||
// Database::log(_ss.str());
|
// Database::log(_ss.str());
|
||||||
}
|
}
|
||||||
// cout << _result_list[0][0] << " & " << _result_list[0][1] << endl;
|
// cout << _result_list[0][0] << " & " << _result_list[0][1] << endl;
|
||||||
//std::cout << "*****Join done" << std::endl;
|
std::cout << "*****Join done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::select(vector<int*>& _result_list,int _var_id,int _pre_id,int _var_id2,const char _edge_type,int _var_num)
|
bool Database::select(vector<int*>& _result_list,int _var_id,int _pre_id,int _var_id2,const char _edge_type,int _var_num)
|
||||||
{
|
{
|
||||||
//cout << "*****In select" << endl;
|
cout << "*****In select" << endl;
|
||||||
|
|
||||||
int* id_list;
|
int* id_list;
|
||||||
int id_list_len;
|
int id_list_len;
|
||||||
|
@ -1840,9 +1840,9 @@ bool Database::select(vector<int*>& _result_list,int _var_id,int _pre_id,int _va
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "\t\tresult size: " << _result_list.size() << " invalid:" << invalid_num << endl;
|
cout << "\t\tresult size: " << _result_list.size() << " invalid:" << invalid_num << endl;
|
||||||
//
|
//
|
||||||
//cout << "*****Select done" << endl;
|
cout << "*****Select done" << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1857,33 +1857,33 @@ bool Database::join(SPARQLquery& _sparql_query)
|
||||||
|
|
||||||
//join each basic query
|
//join each basic query
|
||||||
for (int i=0; i< basic_query_num; i++){
|
for (int i=0; i< basic_query_num; i++){
|
||||||
//cout<<"Basic query "<<i<<endl;
|
cout<<"Basic query "<<i<<endl;
|
||||||
BasicQuery* basic_query;
|
BasicQuery* basic_query;
|
||||||
basic_query=&(_sparql_query.getBasicQuery(i));
|
basic_query=&(_sparql_query.getBasicQuery(i));
|
||||||
long begin = util::get_cur_time();
|
long begin = util::get_cur_time();
|
||||||
this->filter_before_join(basic_query);
|
this->filter_before_join(basic_query);
|
||||||
long after_filter = util::get_cur_time();
|
long after_filter = util::get_cur_time();
|
||||||
//cout << "after filter_before_join: used " << (after_filter-begin) << " ms" << endl;
|
cout << "after filter_before_join: used " << (after_filter-begin) << " ms" << endl;
|
||||||
this->add_literal_candidate(basic_query);
|
this->add_literal_candidate(basic_query);
|
||||||
long after_add_literal = util::get_cur_time();
|
long after_add_literal = util::get_cur_time();
|
||||||
//cout << "after add_literal_candidate: used " << (after_add_literal-after_filter) << " ms" << endl;
|
cout << "after add_literal_candidate: used " << (after_add_literal-after_filter) << " ms" << endl;
|
||||||
this->join_basic(basic_query);
|
this->join_basic(basic_query);
|
||||||
long after_joinbasic = util::get_cur_time();
|
long after_joinbasic = util::get_cur_time();
|
||||||
//cout << "after join_basic : used " << (after_joinbasic-after_add_literal) << " ms" << endl;
|
cout << "after join_basic : used " << (after_joinbasic-after_add_literal) << " ms" << endl;
|
||||||
this->only_pre_filter_after_join(basic_query);
|
this->only_pre_filter_after_join(basic_query);
|
||||||
long after_pre_filter_after_join = util::get_cur_time();
|
long after_pre_filter_after_join = util::get_cur_time();
|
||||||
//cout << "after only_pre_filter_after_join : used " << (after_pre_filter_after_join-after_joinbasic) << " ms" << endl;
|
cout << "after only_pre_filter_after_join : used " << (after_pre_filter_after_join-after_joinbasic) << " ms" << endl;
|
||||||
|
|
||||||
// remove invalid and duplicate result at the end.
|
// remove invalid and duplicate result at the end.
|
||||||
basic_query->dupRemoval_invalidRemoval();
|
basic_query->dupRemoval_invalidRemoval();
|
||||||
//std::cout << "Final result:" << (basic_query->getResultList()).size() << std::endl;
|
std::cout << "Final result:" << (basic_query->getResultList()).size() << std::endl;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::join_basic(BasicQuery* basic_query)
|
bool Database::join_basic(BasicQuery* basic_query)
|
||||||
{
|
{
|
||||||
//cout << "IIIIIIN join basic" << endl;
|
cout << "IIIIIIN join basic" << endl;
|
||||||
|
|
||||||
int var_num = basic_query->getVarNum();
|
int var_num = basic_query->getVarNum();
|
||||||
int triple_num = basic_query->getTripleNum();
|
int triple_num = basic_query->getTripleNum();
|
||||||
|
@ -1974,34 +1974,34 @@ bool Database::join_basic(BasicQuery* basic_query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "OOOOOUT join basic" << endl;
|
cout << "OOOOOUT join basic" << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::filter_before_join(BasicQuery* basic_query)
|
void Database::filter_before_join(BasicQuery* basic_query)
|
||||||
{
|
{
|
||||||
|
|
||||||
//cout << "*****IIIIIIN filter_before_join" << endl;
|
cout << "*****IIIIIIN filter_before_join" << endl;
|
||||||
|
|
||||||
int var_num = 0;
|
int var_num = 0;
|
||||||
var_num = basic_query->getVarNum();
|
var_num = basic_query->getVarNum();
|
||||||
|
|
||||||
for (int i = 0; i < var_num; i++)
|
for (int i = 0; i < var_num; i++)
|
||||||
{
|
{
|
||||||
//std::cout << "\tVar" << i << " " << basic_query->getVarName(i) << std::endl;
|
std::cout << "\tVar" << i << " " << basic_query->getVarName(i) << std::endl;
|
||||||
IDList &can_list = basic_query->getCandidateList(i);
|
IDList &can_list = basic_query->getCandidateList(i);
|
||||||
//cout << "\t\tsize of canlist before filter: " << can_list.size() << endl;
|
cout << "\t\tsize of canlist before filter: " << can_list.size() << endl;
|
||||||
// must sort before using binary search.
|
// must sort before using binary search.
|
||||||
can_list.sort();
|
can_list.sort();
|
||||||
|
|
||||||
long begin = util::get_cur_time();
|
long begin = util::get_cur_time();
|
||||||
this->literal_edge_filter(basic_query, i);
|
this->literal_edge_filter(basic_query, i);
|
||||||
long after_literal_edge_filter = util::get_cur_time();
|
long after_literal_edge_filter = util::get_cur_time();
|
||||||
//cout << "\t\tliteral_edge_filter: used " << (after_literal_edge_filter-begin) << " ms" << endl;
|
cout << "\t\tliteral_edge_filter: used " << (after_literal_edge_filter-begin) << " ms" << endl;
|
||||||
// this->preid_filter(basic_query, i);
|
// this->preid_filter(basic_query, i);
|
||||||
// long after_preid_filter = util::get_cur_time();
|
// long after_preid_filter = util::get_cur_time();
|
||||||
// cout << "\t\tafter_preid_filter: used " << (after_preid_filter-after_literal_edge_filter) << " ms" << endl;
|
// cout << "\t\tafter_preid_filter: used " << (after_preid_filter-after_literal_edge_filter) << " ms" << endl;
|
||||||
//cout << "\t\t[" << i << "] after filter, candidate size = " << can_list.size() << endl << endl << endl;
|
cout << "\t\t[" << i << "] after filter, candidate size = " << can_list.size() << endl << endl << endl;
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
// {
|
// {
|
||||||
|
@ -2017,7 +2017,7 @@ void Database::filter_before_join(BasicQuery* basic_query)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "OOOOOOUT filter_before_join" << endl;
|
cout << "OOOOOOUT filter_before_join" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::literal_edge_filter(BasicQuery* basic_query, int _var_i)
|
void Database::literal_edge_filter(BasicQuery* basic_query, int _var_i)
|
||||||
|
@ -2029,7 +2029,7 @@ void Database::literal_edge_filter(BasicQuery* basic_query, int _var_i)
|
||||||
{
|
{
|
||||||
int neighbor_id = basic_query->getEdgeNeighborID(_var_i, j);
|
int neighbor_id = basic_query->getEdgeNeighborID(_var_i, j);
|
||||||
// continue;
|
// continue;
|
||||||
//cout << "\t\t\tneighbor_id=" << neighbor_id << endl;
|
cout << "\t\t\tneighbor_id=" << neighbor_id << endl;
|
||||||
if (neighbor_id != -1)
|
if (neighbor_id != -1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -2164,7 +2164,7 @@ void Database::preid_filter(BasicQuery* basic_query, int _var_i)
|
||||||
{
|
{
|
||||||
int neighbor_id = basic_query->getEdgeNeighborID(_var_i, j);
|
int neighbor_id = basic_query->getEdgeNeighborID(_var_i, j);
|
||||||
// continue;
|
// continue;
|
||||||
//cout << "\t\t\tneighbor_id=" << neighbor_id << endl;
|
cout << "\t\t\tneighbor_id=" << neighbor_id << endl;
|
||||||
if (neighbor_id != -1)
|
if (neighbor_id != -1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -2783,5 +2783,5 @@ void Database::test_join()
|
||||||
this->join(_q);
|
this->join(_q);
|
||||||
ResultSet _rs;
|
ResultSet _rs;
|
||||||
this->getFinalResult(_q, _rs);
|
this->getFinalResult(_q, _rs);
|
||||||
//cout << _rs.to_str() << endl;
|
cout << _rs.to_str() << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -991,7 +991,7 @@ void KVstore::flush(){
|
||||||
* has not been modified will do nothing
|
* has not been modified will do nothing
|
||||||
* */
|
* */
|
||||||
void KVstore::release(){
|
void KVstore::release(){
|
||||||
//cout << "release of KVstore..." << endl;
|
cout << "release of KVstore..." << endl;
|
||||||
this->release(this->entity2id);
|
this->release(this->entity2id);
|
||||||
this->release(this->id2entity);
|
this->release(this->id2entity);
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ void KVstore::release(){
|
||||||
|
|
||||||
void KVstore::open()
|
void KVstore::open()
|
||||||
{
|
{
|
||||||
//cout << "open KVstore" << endl;
|
cout << "open KVstore" << endl;
|
||||||
|
|
||||||
this->open(this->entity2id, KVstore::s_entity2id, KVstore::READ_WRITE_MODE);
|
this->open(this->entity2id, KVstore::s_entity2id, KVstore::READ_WRITE_MODE);
|
||||||
this->open(this->id2entity, KVstore::s_id2entity, KVstore::READ_WRITE_MODE);
|
this->open(this->id2entity, KVstore::s_id2entity, KVstore::READ_WRITE_MODE);
|
||||||
|
@ -1074,7 +1074,7 @@ bool KVstore::open(Tree* & _p_btree, const string _tree_name, const int _mode){
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//cout << "bug in open mode of : " << _tree_name << " with mode=" << _mode << endl;
|
cout << "bug in open mode of : " << _tree_name << " with mode=" << _mode << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -187,13 +187,13 @@ int DBparser::replacePrefix(string& str){
|
||||||
if (str[0]!='<'){
|
if (str[0]!='<'){
|
||||||
int sep=str.find(":");
|
int sep=str.find(":");
|
||||||
std::string prefix=str.substr(0,sep+1);
|
std::string prefix=str.substr(0,sep+1);
|
||||||
//std::cout<<"prefix: "<<prefix<<std::endl;
|
std::cout<<"prefix: "<<prefix<<std::endl;
|
||||||
if (_prefix_map.find(prefix)!=_prefix_map.end()){
|
if (_prefix_map.find(prefix)!=_prefix_map.end()){
|
||||||
str=_prefix_map[prefix].substr(0,_prefix_map[prefix].length()-1)+str.substr(sep+1,str.length()-sep-1)+">";
|
str=_prefix_map[prefix].substr(0,_prefix_map[prefix].length()-1)+str.substr(sep+1,str.length()-sep-1)+">";
|
||||||
//std::cout<<"str: "<<str<<std::endl;
|
std::cout<<"str: "<<str<<std::endl;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//std::cout<<"prefix not found..."<<std::endl;
|
std::cout<<"prefix not found..."<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ int DBparser::parseTriple(pANTLR3_BASE_TREE node,Triple& triple){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triple=Triple(subject,predicate,object);
|
triple=Triple(subject,predicate,object);
|
||||||
//std::cout<<"Triple: \n\ts|"<<subject<<"|\n\tp|"<<predicate<<"|\n\to|"<<object<<"|"<<std::endl;
|
std::cout<<"Triple: \n\ts|"<<subject<<"|\n\tp|"<<predicate<<"|\n\to|"<<object<<"|"<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ int DBparser::parseBasicQuery(pANTLR3_BASE_TREE node,BasicQuery& basicQuery){
|
||||||
for (unsigned int j=0;j<node->getChildCount(node);j++){
|
for (unsigned int j=0;j<node->getChildCount(node);j++){
|
||||||
pANTLR3_BASE_TREE childNode=(pANTLR3_BASE_TREE) node->getChild(node,j);
|
pANTLR3_BASE_TREE childNode=(pANTLR3_BASE_TREE) node->getChild(node,j);
|
||||||
//basicQuery 185
|
//basicQuery 185
|
||||||
//std::cout<<"Child type: "<<childNode->getType(childNode)<<endl;
|
std::cout<<"Child type: "<<childNode->getType(childNode)<<endl;
|
||||||
if (childNode->getType(childNode)==185){
|
if (childNode->getType(childNode)==185){
|
||||||
parseTriple(childNode,triple);
|
parseTriple(childNode,triple);
|
||||||
basicQuery.addTriple(triple);
|
basicQuery.addTriple(triple);
|
||||||
|
|
|
@ -239,13 +239,13 @@ void BasicQuery::updateObjSig(int _obj_id, int _pre_id, int _sub_id, std::string
|
||||||
bool sub_is_str = (_sub_id == -1) && (_sub.at(0) != '?');
|
bool sub_is_str = (_sub_id == -1) && (_sub.at(0) != '?');
|
||||||
if(sub_is_str)
|
if(sub_is_str)
|
||||||
{
|
{
|
||||||
//cout << "str2entity" << endl;
|
cout << "str2entity" << endl;
|
||||||
Signature::encodeStr2Entity(_sub.c_str(), this->var_sig[_obj_id]);
|
Signature::encodeStr2Entity(_sub.c_str(), this->var_sig[_obj_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_pre_id != -1)
|
if(_pre_id != -1)
|
||||||
{
|
{
|
||||||
//cout << "pre2entity" << endl;
|
cout << "pre2entity" << endl;
|
||||||
Signature::encodePredicate2Entity(_pre_id, this->var_sig[_obj_id], BasicQuery::EDGE_IN);
|
Signature::encodePredicate2Entity(_pre_id, this->var_sig[_obj_id], BasicQuery::EDGE_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,12 +262,12 @@ void BasicQuery::updateObjSig(int _obj_id, int _pre_id, int _sub_id, std::string
|
||||||
/* encode relative signature data of the query graph */
|
/* encode relative signature data of the query graph */
|
||||||
void BasicQuery::encodeBasicQuery(KVstore* _p_kvstore, const std::vector<std::string>& _query_var)
|
void BasicQuery::encodeBasicQuery(KVstore* _p_kvstore, const std::vector<std::string>& _query_var)
|
||||||
{
|
{
|
||||||
//cout << "IN buildBasicSignature" << endl;
|
cout << "IN buildBasicSignature" << endl;
|
||||||
/* initial */
|
/* initial */
|
||||||
this->initial();
|
this->initial();
|
||||||
|
|
||||||
|
|
||||||
//cout << "after init" << endl;
|
cout << "after init" << endl;
|
||||||
|
|
||||||
this->buildTuple2Freq();
|
this->buildTuple2Freq();
|
||||||
|
|
||||||
|
@ -290,12 +290,12 @@ void BasicQuery::encodeBasicQuery(KVstore* _p_kvstore, const std::vector<std::st
|
||||||
this->var_name[i] = _var;
|
this->var_name[i] = _var;
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "select variables: ";
|
cout << "select variables: ";
|
||||||
for(int i = 0; i < this->var_str2id.size(); i ++)
|
for(int i = 0; i < this->var_str2id.size(); i ++)
|
||||||
{
|
{
|
||||||
//cout << "[" << this->var_name[i] << ", " << i << " " << this->var_str2id[this->var_name[i]] << "]\t";
|
cout << "[" << this->var_name[i] << ", " << i << " " << this->var_str2id[this->var_name[i]] << "]\t";
|
||||||
}
|
}
|
||||||
//cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
if(this->encode_method == BasicQuery::SELECT_VAR)
|
if(this->encode_method == BasicQuery::SELECT_VAR)
|
||||||
{
|
{
|
||||||
|
@ -308,13 +308,13 @@ void BasicQuery::encodeBasicQuery(KVstore* _p_kvstore, const std::vector<std::st
|
||||||
/* assign the this->var_num */
|
/* assign the this->var_num */
|
||||||
this->graph_var_num = this->var_str2id.size();
|
this->graph_var_num = this->var_str2id.size();
|
||||||
|
|
||||||
//cout<< "graph variables: ";
|
cout<< "graph variables: ";
|
||||||
for(int i = 0; i < this->var_str2id.size(); i ++)
|
for(int i = 0; i < this->var_str2id.size(); i ++)
|
||||||
{
|
{
|
||||||
//cout << "[" << this->var_name[i] << ", " << i << " " << this->var_str2id[this->var_name[i]] << "]\t";
|
cout << "[" << this->var_name[i] << ", " << i << " " << this->var_str2id[this->var_name[i]] << "]\t";
|
||||||
}
|
}
|
||||||
//cout << endl;
|
cout << endl;
|
||||||
//cout << "before new IDList!" << endl; //just for debug
|
cout << "before new IDList!" << endl; //just for debug
|
||||||
|
|
||||||
this->candidate_list = new IDList[this->graph_var_num];
|
this->candidate_list = new IDList[this->graph_var_num];
|
||||||
|
|
||||||
|
@ -382,14 +382,14 @@ void BasicQuery::encodeBasicQuery(KVstore* _p_kvstore, const std::vector<std::st
|
||||||
{
|
{
|
||||||
if(pre_id != -1)
|
if(pre_id != -1)
|
||||||
{
|
{
|
||||||
//cout << "pre2edge" << endl;
|
cout << "pre2edge" << endl;
|
||||||
Signature::encodePredicate2Edge(pre_id, this->edge_sig[sub_id][obj_id]);
|
Signature::encodePredicate2Edge(pre_id, this->edge_sig[sub_id][obj_id]);
|
||||||
// this->edge_pre_id[sub_id][obj_id] = pre_id;
|
// this->edge_pre_id[sub_id][obj_id] = pre_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//cout << "OUT encodeBasicQuery" << endl;
|
cout << "OUT encodeBasicQuery" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ struct BasicQuery::ResultCmp
|
||||||
|
|
||||||
bool BasicQuery::dupRemoval_invalidRemoval()
|
bool BasicQuery::dupRemoval_invalidRemoval()
|
||||||
{
|
{
|
||||||
//std::cout << "IN dupRemoval_invalidRemoval" << std::endl;
|
std::cout << "IN dupRemoval_invalidRemoval" << std::endl;
|
||||||
|
|
||||||
ResultCmp resCmp(this->graph_var_num);
|
ResultCmp resCmp(this->graph_var_num);
|
||||||
ResultEqual resEqual(this->select_var_num);
|
ResultEqual resEqual(this->select_var_num);
|
||||||
|
@ -731,10 +731,10 @@ bool BasicQuery::dupRemoval_invalidRemoval()
|
||||||
}
|
}
|
||||||
this->result_list.resize(valid_num);
|
this->result_list.resize(valid_num);
|
||||||
|
|
||||||
//std::cout << "dup_num: " << dup_num << std::endl;
|
std::cout << "dup_num: " << dup_num << std::endl;
|
||||||
//std::cout << "invalid_num: " << result_size - valid_num << std::endl;
|
std::cout << "invalid_num: " << result_size - valid_num << std::endl;
|
||||||
|
|
||||||
//std::cout << "OUT dupRemoval_invalidRemoval" << std::endl;
|
std::cout << "OUT dupRemoval_invalidRemoval" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,14 +86,14 @@ vector<BasicQuery*>& SPARQLquery::getBasicQueryVec()
|
||||||
|
|
||||||
void SPARQLquery::print(ostream& _out_stream){
|
void SPARQLquery::print(ostream& _out_stream){
|
||||||
int k=getQueryVarNum();
|
int k=getQueryVarNum();
|
||||||
//std::cout<<"QueryVar "<<k<<":"<<std::endl;
|
std::cout<<"QueryVar "<<k<<":"<<std::endl;
|
||||||
for (int i=0;i<k;i++){
|
for (int i=0;i<k;i++){
|
||||||
//std::cout<<getQueryVar(i)<<std::endl;
|
std::cout<<getQueryVar(i)<<std::endl;
|
||||||
}
|
}
|
||||||
k=getBasicQueryNum();
|
k=getBasicQueryNum();
|
||||||
//std::cout<<"Block "<<k<<" in total."<<std::endl;
|
std::cout<<"Block "<<k<<" in total."<<std::endl;
|
||||||
for (int i=0;i<k;i++){
|
for (int i=0;i<k;i++){
|
||||||
//std::cout<<"Block "<<i<<std::endl;
|
std::cout<<"Block "<<i<<std::endl;
|
||||||
getBasicQuery(i).print(_out_stream);
|
getBasicQuery(i).print(_out_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue