fix: bug in KVstore and Join;
mess code in KVstore due to read after request() release the pointer; lack of empty judgement in Join::pre_handler; by zengli
This commit is contained in:
parent
09a30931d4
commit
ae5e610acc
|
@ -732,18 +732,19 @@ Database::load_vstree(unsigned _vstree_size)
|
|||
void
|
||||
Database::check()
|
||||
{
|
||||
//string tstr;
|
||||
string tstr;
|
||||
//unsigned pid = this->kvstore->getIDByPredicate("<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>");
|
||||
//cout<<"check: pre "<<pid<<endl;
|
||||
//this->stringindex->randomAccess(pid, &tstr, false);
|
||||
//cout<<"string index: "<<tstr<<endl;
|
||||
////cout<<"kvstore: "<<this->kvstore->getPredicateByID(pid)<<endl;
|
||||
|
||||
//unsigned sid = this->kvstore->getIDByEntity("<http://www.Department4.University1821.edu/Course50>");
|
||||
//cout<<"check: sub "<<sid<<endl;
|
||||
//this->stringindex->randomAccess(sid, &tstr, true);
|
||||
//cout<<"string index: "<<tstr<<endl;
|
||||
//cout<<"kvstore: "<<this->kvstore->getEntityByID(sid)<<endl;
|
||||
cout<<"right pair: "<<62<<" "<<"<http://www.Department0.University0.edu/GraduateCourse11>"<<endl;
|
||||
unsigned sid = this->kvstore->getIDByEntity("<http://www.Department0.University0.edu/GraduateCourse11>");
|
||||
cout<<"check: sub "<<sid<<endl;
|
||||
this->stringindex->randomAccess(sid, &tstr, true);
|
||||
cout<<"string index: "<<tstr<<endl;
|
||||
cout<<"kvstore: "<<this->kvstore->getEntityByID(sid)<<endl;
|
||||
|
||||
//unsigned oid = this->kvstore->getIDByString("<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#Course>");
|
||||
//cout<<"check: obj "<<oid<<endl;
|
||||
|
|
|
@ -196,8 +196,9 @@ Join::join_sparql(SPARQLquery& _sparql_query)
|
|||
return true;
|
||||
}
|
||||
|
||||
//TODO: consider a node with multiple same predicates(not pre var), use getXXX(...false) to do this
|
||||
//TODO: consider a node with multiple same predicates(not pre var), use p2s(...false) to do this
|
||||
//BETTER?: ?s-p-?o, use p2so instead of p2s and p2o to get candidates for ?s and ?o will be better??
|
||||
//TODO: deal with predicate variables, maybe not ready like literals
|
||||
bool
|
||||
Join::pre_handler()
|
||||
{
|
||||
|
@ -214,12 +215,12 @@ Join::pre_handler()
|
|||
for (int j = 0; j < var_degree; j++)
|
||||
{
|
||||
int neighbor_id = this->basic_query->getEdgeNeighborID(_var_i, j);
|
||||
if (neighbor_id != -1) //TODO:what does it mean???variables in join not considered here
|
||||
//-1: constant or variable not in join; otherwise, variable in join
|
||||
if (neighbor_id != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//TODO set ready here?
|
||||
this->basic_query->setReady(_var_i);
|
||||
|
||||
char edge_type = this->basic_query->getEdgeType(_var_i, j);
|
||||
int triple_id = this->basic_query->getEdgeID(_var_i, j);
|
||||
Triple triple = this->basic_query->getTriple(triple_id);
|
||||
|
@ -234,8 +235,8 @@ Join::pre_handler()
|
|||
neighbor_name = triple.subject;
|
||||
}
|
||||
|
||||
//TODO : consider or not??
|
||||
bool only_preid_filter = (this->basic_query->isOneDegreeNotJoinVar(neighbor_name));
|
||||
//NOTICE: we only need to consider constants here
|
||||
if(only_preid_filter)
|
||||
{
|
||||
continue;
|
||||
|
@ -243,11 +244,11 @@ Join::pre_handler()
|
|||
else
|
||||
{
|
||||
this->dealed_triple[triple_id] = true;
|
||||
this->basic_query->setReady(_var_i);
|
||||
}
|
||||
|
||||
TYPE_PREDICATE_ID pre_id = this->basic_query->getEdgePreID(_var_i, j);
|
||||
|
||||
//TODO : cancle the literal
|
||||
TYPE_ENTITY_LITERAL_ID lit_id = (this->kvstore)->getIDByEntity(neighbor_name);
|
||||
if (lit_id == INVALID_ENTITY_LITERAL_ID)
|
||||
{
|
||||
|
@ -284,19 +285,20 @@ Join::pre_handler()
|
|||
id_list_len = 0;
|
||||
}
|
||||
|
||||
//WARN: this may need to check, end directly
|
||||
if (id_list_len == 0)
|
||||
{
|
||||
_list.clear();
|
||||
delete[] id_list;
|
||||
return false;
|
||||
}
|
||||
//TODO : correct ways to intersect
|
||||
//updateList(_list, id_list, id_list_len);
|
||||
if (_list.size() == 0)
|
||||
_list.unionList(id_list,id_list_len);
|
||||
else
|
||||
_list.intersectList(id_list, id_list_len);
|
||||
delete[] id_list;
|
||||
|
||||
if (_list.size() == 0)
|
||||
{
|
||||
return false;
|
||||
|
@ -305,7 +307,9 @@ Join::pre_handler()
|
|||
|
||||
cout << "\t\t[" << _var_i << "] after constant filter, candidate size = " << _list.size() << endl << endl << endl;
|
||||
}
|
||||
cout << "pre var filter start here" << endl;
|
||||
|
||||
cout << "pre filter start here" << endl;
|
||||
//TODO:use vector instead of set
|
||||
for(int _var = 0; _var < this->var_num; _var++)
|
||||
{
|
||||
if(this->basic_query->isSatelliteInJoin(_var))
|
||||
|
@ -316,7 +320,6 @@ Join::pre_handler()
|
|||
unsigned size = this->basic_query->getCandidateSize(_var);
|
||||
|
||||
//result if already empty for non-literal variable
|
||||
//TODO: whether use this
|
||||
/*
|
||||
if (size == 0)
|
||||
{
|
||||
|
@ -362,8 +365,6 @@ Join::pre_handler()
|
|||
continue;
|
||||
}
|
||||
|
||||
//TODO+BETTER: is any pre really used? do we need to losen the restrictions?
|
||||
|
||||
//size:m<n; time:mlgn < n-m
|
||||
//The former time is computed because the m should be small if we select this p, tending to use binary-search
|
||||
//when doing intersectList operation(mlgn < m+n).
|
||||
|
@ -393,7 +394,6 @@ Join::pre_handler()
|
|||
{
|
||||
continue;
|
||||
}
|
||||
//TODO : set ready here ?
|
||||
this->basic_query->setReady(_var);
|
||||
//NOTICE:use p2s here, use s2p in only_pre_filter_after_join because pres there are not efficient
|
||||
set<TYPE_PREDICATE_ID>::iterator it;
|
||||
|
@ -407,6 +407,10 @@ Join::pre_handler()
|
|||
else
|
||||
cans.intersectList(list, len);
|
||||
delete[] list;
|
||||
if(cans.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(in_edge_pre_id.size() != 0 && cans.size() == 0)
|
||||
|
@ -423,6 +427,10 @@ Join::pre_handler()
|
|||
else
|
||||
cans.intersectList(list, len);
|
||||
delete[] list;
|
||||
if(cans.size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -432,8 +440,8 @@ Join::pre_handler()
|
|||
return false;
|
||||
}
|
||||
cout << "\t\t[" << _var << "] after pre var filter, candidate size = " << cans.size() << endl << endl << endl;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
|
|
@ -129,7 +129,20 @@ ISTree::search(unsigned _key, char*& _str, unsigned& _len)
|
|||
_str = val->getStr();
|
||||
_len = val->getLen();
|
||||
|
||||
char* debug = new char[_len];
|
||||
memcpy(debug, _str, _len);
|
||||
// debug[_len] = '\0';
|
||||
_str = debug;
|
||||
|
||||
//if(_key==62)
|
||||
//{
|
||||
//cout<<"check in search: "<<string(_str, _len)<<endl;
|
||||
//}
|
||||
this->TSM->request(request);
|
||||
//if(_key==62)
|
||||
//{
|
||||
//cout<<"check in search: "<<string(_str, _len)<<endl;
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ ISHeap::ISHeap(unsigned _size)
|
|||
{
|
||||
this->length = 0;
|
||||
this->size = _size;
|
||||
//this->heap = (Node**)malloc(this->size * sizeof(Node*)); //not use 4 or 8
|
||||
this->heap = new ISNode*[this->size];
|
||||
this->heap = (ISNode**)malloc(this->size * sizeof(ISNode*)); //not use 4 or 8
|
||||
//this->heap = new ISNode*[this->size];
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
this->print("error in ISHeap: Allocation fail!");
|
||||
|
@ -69,6 +69,10 @@ ISHeap::insert(ISNode* _np)
|
|||
{
|
||||
if (this->length == this->size) //when full, reallocate
|
||||
{
|
||||
cout<<"check: double the heap"<<endl;
|
||||
//WARN: realloc should be combined with malloc instead of new
|
||||
//http://bbs.csdn.net/topics/320148799
|
||||
//For new, use placement new to enlarge space: http://blog.csdn.net/vangoals/article/details/4252833
|
||||
this->heap = (ISNode**)realloc(this->heap, 2 * this->size * sizeof(ISNode*));
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
|
@ -173,7 +177,8 @@ ISHeap::modify(ISNode* _np, bool _flag) //control direction
|
|||
|
||||
ISHeap::~ISHeap()
|
||||
{
|
||||
delete[] this->heap;
|
||||
//delete[] this->heap;
|
||||
free(this->heap);
|
||||
this->heap = NULL;
|
||||
this->length = this->size = 0;
|
||||
}
|
||||
|
@ -183,4 +188,4 @@ ISHeap::print(string s)
|
|||
{
|
||||
#ifdef DEBUG_KVSTORE
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,6 +223,7 @@ ISLeafNode::split(ISNode* _father, int _index)
|
|||
p->addNum();
|
||||
}
|
||||
unsigned tp = this->keys[MIN_KEY_NUM];
|
||||
//cout<<"split: "<<tp<<" "<<this->values[MIN_KEY_NUM].getStr()<<endl;
|
||||
this->setNum(MIN_KEY_NUM);
|
||||
_father->addKey(tp, _index);
|
||||
_father->addChild(p, _index + 1); //DEBUG(check the index)
|
||||
|
|
|
@ -137,6 +137,13 @@ IVTree::search(unsigned _key, char*& _str, unsigned& _len)
|
|||
//_str = this->transfer[0].getStr();
|
||||
//_len = this->transfer[0].getLen();
|
||||
|
||||
if (!VList::isLongList(_len))
|
||||
{
|
||||
char* debug = new char [_len];
|
||||
memcpy(debug, _str, _len);
|
||||
_str = debug;
|
||||
}
|
||||
|
||||
this->TSM->request(request);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ IVHeap::IVHeap(unsigned _size)
|
|||
{
|
||||
this->length = 0;
|
||||
this->size = _size;
|
||||
//this->heap = (Node**)malloc(this->size * sizeof(Node*)); //not use 4 or 8
|
||||
this->heap = new IVNode*[this->size];
|
||||
this->heap = (IVNode**)malloc(this->size * sizeof(IVNode*)); //not use 4 or 8
|
||||
//this->heap = new IVNode*[this->size];
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
this->print("error in IVHeap: Allocation fail!");
|
||||
|
@ -69,6 +69,7 @@ IVHeap::insert(IVNode* _np)
|
|||
{
|
||||
if (this->length == this->size) //when full, reallocate
|
||||
{
|
||||
cout<<"check: double the heap"<<endl;
|
||||
this->heap = (IVNode**)realloc(this->heap, 2 * this->size * sizeof(IVNode*));
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
|
@ -173,7 +174,8 @@ IVHeap::modify(IVNode* _np, bool _flag) //control direction
|
|||
|
||||
IVHeap::~IVHeap()
|
||||
{
|
||||
delete[] this->heap;
|
||||
//delete[] this->heap;
|
||||
free(this->heap);
|
||||
this->heap = NULL;
|
||||
this->length = this->size = 0;
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ IVLeafNode::split(IVNode* _father, int _index)
|
|||
p->addValue(this->values + i, k);
|
||||
p->addNum();
|
||||
}
|
||||
int tp = this->keys[MIN_KEY_NUM];
|
||||
unsigned tp = this->keys[MIN_KEY_NUM];
|
||||
this->setNum(MIN_KEY_NUM);
|
||||
_father->addKey(tp, _index);
|
||||
_father->addChild(p, _index + 1); //DEBUG(check the index)
|
||||
|
|
|
@ -1154,6 +1154,38 @@ KVstore::getEntityByID(TYPE_ENTITY_LITERAL_ID _id) const
|
|||
|
||||
//NOTICE: no need to add \0 at last if we indicate the length
|
||||
string _ret = string(_tmp, _len);
|
||||
delete[] _tmp;
|
||||
//CONSIDER: represent "abc" by 4 chars with length=4, and construct with string(str) directly
|
||||
|
||||
//if(_id == 62)
|
||||
//{
|
||||
//cout<<"check 62: "<<_ret<<endl;
|
||||
//char* nstr = new char[_len+1];
|
||||
//memcpy(nstr, _tmp, _len);
|
||||
//nstr[_len] = '\0';
|
||||
//cout<<"check 62: "<<nstr<<endl;
|
||||
//for(int k = 0; k < _len; ++k)
|
||||
//{
|
||||
//cout<<_tmp[k]<<" ";
|
||||
//}cout<<endl;
|
||||
//delete[] nstr;
|
||||
//}
|
||||
|
||||
//NOTICE: if there is messy code, then int(char) will < 0, otherwise not
|
||||
//bool invalid = false;
|
||||
//for(unsigned i = 0; i < _len; ++i)
|
||||
//{
|
||||
//if(int(_ret[i])<0)
|
||||
//{
|
||||
//invalid = true;
|
||||
//break;
|
||||
//}
|
||||
//}
|
||||
//if(invalid)
|
||||
//{
|
||||
//cout<<"error in kvstore: "<<_id<<" "<<_ret<<endl;
|
||||
//cout<<"length: "<<_len<<" "<<_tmp<<" "<<_tmp[0]<<endl;
|
||||
//}
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
@ -1167,6 +1199,8 @@ KVstore::setEntityByID(TYPE_ENTITY_LITERAL_ID _id, string _entity)
|
|||
char* str = new char[len];
|
||||
memcpy(str, _entity.c_str(), len);
|
||||
|
||||
//cout<<"check 62: "<<this->getEntityByID(62)<<endl;
|
||||
|
||||
return this->addValueByKey(this->id2entity, _id, str, len);
|
||||
}
|
||||
|
||||
|
@ -1287,6 +1321,7 @@ KVstore::getPredicateByID(TYPE_PREDICATE_ID _id) const
|
|||
return "";
|
||||
}
|
||||
string _ret = string(_tmp, _len);
|
||||
delete[] _tmp;
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
@ -1422,6 +1457,21 @@ KVstore::getLiteralByID(TYPE_ENTITY_LITERAL_ID _id) const
|
|||
return "";
|
||||
}
|
||||
string _ret = string(_tmp, _len);
|
||||
delete[] _tmp;
|
||||
|
||||
//bool invalid = false;
|
||||
//for(unsigned i = 0; i < _len; ++i)
|
||||
//{
|
||||
//if(int(_ret[i])<0)
|
||||
//{
|
||||
//invalid = true;
|
||||
//break;
|
||||
//}
|
||||
//}
|
||||
//if(invalid)
|
||||
//{
|
||||
//cout<<"error in kvstore: "<<_id<<" "<<_ret<<endl;
|
||||
//}
|
||||
|
||||
return _ret;
|
||||
}
|
||||
|
@ -1596,11 +1646,11 @@ KVstore::getpreIDlistBysubID(TYPE_ENTITY_LITERAL_ID _subid, unsigned*& _preidlis
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1634,11 +1684,11 @@ KVstore::getobjIDlistBysubID(TYPE_ENTITY_LITERAL_ID _subid, unsigned*& _objidlis
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1684,11 +1734,11 @@ KVstore::getobjIDlistBysubIDpreID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_PREDICATE_
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1732,11 +1782,11 @@ KVstore::getpreIDobjIDlistBysubID(TYPE_ENTITY_LITERAL_ID _subid, unsigned*& _pre
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1872,11 +1922,11 @@ KVstore::getpreIDlistByobjID(TYPE_ENTITY_LITERAL_ID _objid, unsigned*& _preidlis
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1904,11 +1954,11 @@ KVstore::getsubIDlistByobjID(TYPE_ENTITY_LITERAL_ID _objid, unsigned*& _subidlis
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1948,11 +1998,11 @@ KVstore::getsubIDlistByobjIDpreID(TYPE_ENTITY_LITERAL_ID _objid, TYPE_PREDICATE_
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1989,11 +2039,11 @@ KVstore::getpreIDsubIDlistByobjID(TYPE_ENTITY_LITERAL_ID _objid, unsigned*& _pre
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2109,11 +2159,11 @@ KVstore::getsubIDlistBypreID(TYPE_PREDICATE_ID _preid, unsigned*& _subidlist, un
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2140,11 +2190,11 @@ KVstore::getobjIDlistBypreID(TYPE_PREDICATE_ID _preid, unsigned*& _objidlist, un
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2180,14 +2230,14 @@ KVstore::getsubIDobjIDlistBypreID(TYPE_PREDICATE_ID _preid, unsigned*& _subid_ob
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
#ifdef DEBUG_KVSTORE
|
||||
cout<<"this is a vlist"<<endl;
|
||||
#endif
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2254,11 +2304,11 @@ KVstore::getpreIDlistBysubIDobjID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_ENTITY_LIT
|
|||
|
||||
//if this is a long list, then we should remove itself after copying
|
||||
//otherwise, we should not free the list memory
|
||||
if(VList::listNeedDelete(_len))
|
||||
{
|
||||
//if(VList::listNeedDelete(_len))
|
||||
//{
|
||||
delete[] _tmp;
|
||||
//_tmp = NULL;
|
||||
}
|
||||
//}
|
||||
|
||||
if (_list_len == 0) {
|
||||
_preidlist = NULL;
|
||||
|
|
|
@ -20,8 +20,8 @@ SIHeap::SIHeap(unsigned _size)
|
|||
{
|
||||
this->length = 0;
|
||||
this->size = _size;
|
||||
//this->heap = (Node**)malloc(this->size * sizeof(Node*)); //not use 4 or 8
|
||||
this->heap = new SINode*[this->size];
|
||||
this->heap = (SINode**)malloc(this->size * sizeof(SINode*)); //not use 4 or 8
|
||||
//this->heap = new SINode*[this->size];
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
this->print("error in SIHeap: Allocation fail!");
|
||||
|
@ -69,6 +69,7 @@ SIHeap::insert(SINode* _np)
|
|||
{
|
||||
if (this->length == this->size) //when full, reallocate
|
||||
{
|
||||
cout<<"check: double the heap"<<endl;
|
||||
this->heap = (SINode**)realloc(this->heap, 2 * this->size * sizeof(SINode*));
|
||||
if (this->heap == NULL)
|
||||
{
|
||||
|
@ -173,7 +174,8 @@ SIHeap::modify(SINode* _np, bool _flag) //control direction
|
|||
|
||||
SIHeap::~SIHeap()
|
||||
{
|
||||
delete[] this->heap;
|
||||
//delete[] this->heap;
|
||||
free(this->heap);
|
||||
this->heap = NULL;
|
||||
this->length = this->size = 0;
|
||||
}
|
||||
|
|
|
@ -249,6 +249,7 @@ int initialize() {
|
|||
string format = "json";
|
||||
cout<<"HTTP: this is query"<<endl;
|
||||
string db_query=request->path_match[1];
|
||||
cout<<"check: "<<db_query<<endl;
|
||||
db_query = UrlDecode(db_query);
|
||||
cout<<"check: "<<db_query<<endl;
|
||||
string str = db_query;
|
||||
|
|
|
@ -63,6 +63,7 @@ in the sparql query can point to the same node in data graph)
|
|||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <new>
|
||||
|
||||
//NOTICE:below are libraries need to link
|
||||
#include <thread> //only for c++11 or greater versions
|
||||
|
|
|
@ -132,6 +132,8 @@ public class GstoreConnector {
|
|||
return false;
|
||||
}
|
||||
|
||||
//TODO: also use encode to support spaces?
|
||||
//Consider change format into ?name=DBname
|
||||
String cmd = "build/" + _db_name + "/" + _rdf_file_path;
|
||||
String msg = this.sendGet(cmd);
|
||||
|
||||
|
|
Loading…
Reference in New Issue