fix: bugs with ISTree and KVstore;
virtual functions not matched in ISTree; unsigned type matching error in KVstore; both fixed, by zengli
This commit is contained in:
parent
f3202ada40
commit
405bb21a9a
|
@ -82,6 +82,7 @@ ISLeafNode::getValue(int _index) const
|
||||||
int num = this->getNum();
|
int num = this->getNum();
|
||||||
if (_index < 0 || _index >= num)
|
if (_index < 0 || _index >= num)
|
||||||
{
|
{
|
||||||
|
//cout<<"null in getValue: "<<_index<<endl;
|
||||||
//print(string("error in getValue: Invalid index ") + Util::int2string(_index));
|
//print(string("error in getValue: Invalid index ") + Util::int2string(_index));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ ISLeafNode::setValue(char* _str, unsigned _len, int _index, bool ifcopy)
|
||||||
int num = this->getNum();
|
int num = this->getNum();
|
||||||
if (_index < 0 || _index >= num)
|
if (_index < 0 || _index >= num)
|
||||||
{
|
{
|
||||||
print(string("error in setValue: Invalid index ") + Util::int2string(_index));
|
//print(string("error in setValue: Invalid index ") + Util::int2string(_index));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->values[_index].release(); //NOTICE: only used in modify
|
this->values[_index].release(); //NOTICE: only used in modify
|
||||||
|
@ -146,9 +147,12 @@ bool
|
||||||
ISLeafNode::addValue(char* _str, unsigned _len, int _index, bool ifcopy)
|
ISLeafNode::addValue(char* _str, unsigned _len, int _index, bool ifcopy)
|
||||||
{
|
{
|
||||||
int num = this->getNum();
|
int num = this->getNum();
|
||||||
|
//cout<<"addValue: "<<num<<" "<<_index<<endl;
|
||||||
|
|
||||||
if (_index < 0 || _index > num)
|
if (_index < 0 || _index > num)
|
||||||
{
|
{
|
||||||
print(string("error in addValue: Invalid index ") + Util::int2string(_index));
|
//print(string("error in addValue: Invalid index ") + Util::int2string(_index));
|
||||||
|
//cout<<"error in addValue: "<<_index<<" "<<num<<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
|
@ -157,6 +161,7 @@ ISLeafNode::addValue(char* _str, unsigned _len, int _index, bool ifcopy)
|
||||||
|
|
||||||
this->values[_index].setStr(_str);
|
this->values[_index].setStr(_str);
|
||||||
this->values[_index].setLen(_len);
|
this->values[_index].setLen(_len);
|
||||||
|
//cout<<"show: "<<this->values[_index].getLen()<<" "<<this->values[_index].getStr()[0]<<endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +172,7 @@ ISLeafNode::subValue(int _index, bool ifdel)
|
||||||
int num = this->getNum();
|
int num = this->getNum();
|
||||||
if (_index < 0 || _index >= num)
|
if (_index < 0 || _index >= num)
|
||||||
{
|
{
|
||||||
print(string("error in subValue: Invalid index ") + Util::int2string(_index));
|
//print(string("error in subValue: Invalid index ") + Util::int2string(_index));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
|
@ -319,8 +324,8 @@ ISLeafNode::coalesce(ISNode* _father, int _index)
|
||||||
p->subNum();
|
p->subNum();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print("error in coalesce: Invalid case!");
|
//print("error in coalesce: Invalid case!");
|
||||||
//printf("error in coalesce: Invalid case!");
|
cout<<"error in coalesce: Invalid case!"<<endl;
|
||||||
}
|
}
|
||||||
_father->setDirty();
|
_father->setDirty();
|
||||||
p->setDirty();
|
p->setDirty();
|
||||||
|
|
|
@ -88,8 +88,8 @@ public:
|
||||||
virtual void setPrev(ISNode* _prev) {};
|
virtual void setPrev(ISNode* _prev) {};
|
||||||
virtual void setNext(ISNode* _next) {};
|
virtual void setNext(ISNode* _next) {};
|
||||||
|
|
||||||
virtual bool setValue(const char* _str, unsigned _len, int _index, bool ifcopy = false) { return true; };
|
virtual bool setValue(char* _str, unsigned _len, int _index, bool ifcopy = false) { return true; };
|
||||||
virtual bool addValue(const char* _str, unsigned _len, int _index, bool ifcopy = false) { return true; };
|
virtual bool addValue(char* _str, unsigned _len, int _index, bool ifcopy = false) { return true; };
|
||||||
|
|
||||||
//pure virtual function
|
//pure virtual function
|
||||||
virtual void Virtual() = 0;
|
virtual void Virtual() = 0;
|
||||||
|
|
|
@ -401,10 +401,10 @@ ISStorage::writeNode(ISNode* _np)
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
{
|
{
|
||||||
this->writeBstr(_np->getValue(i), &blocknum, SpecialBlock);
|
this->writeBstr(_np->getValue(i), &blocknum, SpecialBlock);
|
||||||
if(_np->getKey(0) == 0)
|
//if(_np->getKey(0) == 0)
|
||||||
{
|
//{
|
||||||
cout<<"the 0th value: "<<_np->getValue(i)->getStr()[0]<<endl;
|
//cout<<"the 0th value: "<<_np->getValue(i)->getStr()[0]<<endl;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fseek(treefp, Address(blocknum), SEEK_SET);
|
fseek(treefp, Address(blocknum), SEEK_SET);
|
||||||
|
|
|
@ -218,8 +218,9 @@ KVstore::getSubjectPredicateDegree(TYPE_ENTITY_LITERAL_ID _subid, TYPE_PREDICATE
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if(_get)
|
if(_get)
|
||||||
{
|
{
|
||||||
int _result = KVstore::binarySearch(_preid, _tmp + 3, _tmp[1], 2);
|
unsigned _result = KVstore::binarySearch(_preid, _tmp + 3, _tmp[1], 2);
|
||||||
if (_result != -1)
|
//if (_result != -1)
|
||||||
|
if (_result != INVALID)
|
||||||
{
|
{
|
||||||
int _offset = _tmp[4 + 2 * _result];
|
int _offset = _tmp[4 + 2 * _result];
|
||||||
int _offset_next;
|
int _offset_next;
|
||||||
|
@ -257,8 +258,9 @@ KVstore::getObjectPredicateDegree(TYPE_ENTITY_LITERAL_ID _objid, TYPE_PREDICATE_
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (_get)
|
if (_get)
|
||||||
{
|
{
|
||||||
int _result = KVstore::binarySearch(_preid, _tmp + 2, _tmp[1], 2);
|
unsigned _result = KVstore::binarySearch(_preid, _tmp + 2, _tmp[1], 2);
|
||||||
if (_result != -1)
|
//if (_result != -1)
|
||||||
|
if (_result != INVALID)
|
||||||
{
|
{
|
||||||
int _offset = _tmp[3 + 2 * _result];
|
int _offset = _tmp[3 + 2 * _result];
|
||||||
int _offset_next;
|
int _offset_next;
|
||||||
|
@ -709,7 +711,8 @@ KVstore::updateInsert_o2values(TYPE_ENTITY_LITERAL_ID _sub_id, TYPE_PREDICATE_ID
|
||||||
unsigned _position = KVstore::binarySearch(_pre_id, _tmp + 2, _tmp[1], 2);
|
unsigned _position = KVstore::binarySearch(_pre_id, _tmp + 2, _tmp[1], 2);
|
||||||
|
|
||||||
//preID doesn't exist
|
//preID doesn't exist
|
||||||
if (_position == -1) {
|
if (_position == INVALID)
|
||||||
|
{
|
||||||
_values_len = _len / sizeof(unsigned) + 3;
|
_values_len = _len / sizeof(unsigned) + 3;
|
||||||
_values = new unsigned[_values_len];
|
_values = new unsigned[_values_len];
|
||||||
_values[0] = _tmp[0] + 1;
|
_values[0] = _tmp[0] + 1;
|
||||||
|
@ -1632,6 +1635,7 @@ KVstore::getobjIDlistBysubIDpreID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_PREDICATE_
|
||||||
_list_len = 0;
|
_list_len = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//cout<<"check "<<_subid<<" "<<_preid<<endl;
|
||||||
unsigned _result = KVstore::binarySearch(_preid, _tmp + 3, _tmp[1], 2);
|
unsigned _result = KVstore::binarySearch(_preid, _tmp + 3, _tmp[1], 2);
|
||||||
//if (_result == -1)
|
//if (_result == -1)
|
||||||
if (_result == INVALID)
|
if (_result == INVALID)
|
||||||
|
@ -2202,7 +2206,8 @@ KVstore::getpreIDlistBysubIDobjID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_ENTITY_LIT
|
||||||
}
|
}
|
||||||
if (_result == _tmp[1]) {
|
if (_result == _tmp[1]) {
|
||||||
for (unsigned j = i; j < len; j++) {
|
for (unsigned j = i; j < len; j++) {
|
||||||
list[j] = -1;
|
//list[j] = -1;
|
||||||
|
list[j] = INVALID;
|
||||||
_list_len--;
|
_list_len--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2215,8 +2220,8 @@ KVstore::getpreIDlistBysubIDobjID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_ENTITY_LIT
|
||||||
else {
|
else {
|
||||||
_offset_next = _tmp[6 + 2 * _result];
|
_offset_next = _tmp[6 + 2 * _result];
|
||||||
}
|
}
|
||||||
if (KVstore::binarySearch(_objid, _tmp + _offset, _offset_next - _offset) == -1) {
|
if (KVstore::binarySearch(_objid, _tmp + _offset, _offset_next - _offset) == INVALID) {
|
||||||
list[i] = -1;
|
list[i] = INVALID;
|
||||||
_list_len--;
|
_list_len--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2236,7 +2241,8 @@ KVstore::getpreIDlistBysubIDobjID(TYPE_ENTITY_LITERAL_ID _subid, TYPE_ENTITY_LIT
|
||||||
_preidlist = new unsigned[_list_len];
|
_preidlist = new unsigned[_list_len];
|
||||||
unsigned i = 0, j = 0;
|
unsigned i = 0, j = 0;
|
||||||
while (i < len) {
|
while (i < len) {
|
||||||
if (list[i] != -1) {
|
if (list[i] != INVALID)
|
||||||
|
{
|
||||||
_preidlist[j] = list[i];
|
_preidlist[j] = list[i];
|
||||||
i++;
|
i++;
|
||||||
j++;
|
j++;
|
||||||
|
@ -2451,11 +2457,12 @@ KVstore::intersect(const unsigned* _list1, const unsigned* _list2, unsigned _len
|
||||||
unsigned
|
unsigned
|
||||||
KVstore::binarySearch(unsigned _key, const unsigned* _list, unsigned _list_len, int _step)
|
KVstore::binarySearch(unsigned _key, const unsigned* _list, unsigned _list_len, int _step)
|
||||||
{
|
{
|
||||||
unsigned _left = 0;
|
long long _left = 0;
|
||||||
unsigned _right = _list_len - 1;
|
long long _right = _list_len - 1;
|
||||||
unsigned _mid;
|
long long _mid;
|
||||||
while (_left <= _right) {
|
while (_left <= _right) {
|
||||||
_mid = (_right - _left) / 2 + _left;
|
_mid = (_right - _left) / 2 + _left;
|
||||||
|
cout<<"check "<<_step<<" "<<_mid<<" "<<_step*_mid<<" "<<_list_len<<endl;
|
||||||
if (_key == _list[_step * _mid]) {
|
if (_key == _list[_step * _mid]) {
|
||||||
return _mid;
|
return _mid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ in the sparql query can point to the same node in data graph)
|
||||||
//#define DEBUG_JOIN
|
//#define DEBUG_JOIN
|
||||||
//#define DEBUG_STREAM
|
//#define DEBUG_STREAM
|
||||||
//#define DEBUG_PRECISE 1 all information
|
//#define DEBUG_PRECISE 1 all information
|
||||||
#define DEBUG_KVSTORE 1 //in KVstore
|
//#define DEBUG_KVSTORE 1 //in KVstore
|
||||||
//#define DEBUG_VSTREE 1 //in Database
|
//#define DEBUG_VSTREE 1 //in Database
|
||||||
//#define DEBUG_LRUCACHE 1
|
//#define DEBUG_LRUCACHE 1
|
||||||
//#define DEBUG_DATABASE 1 //in Database
|
//#define DEBUG_DATABASE 1 //in Database
|
||||||
|
|
|
@ -36,7 +36,7 @@ class VList
|
||||||
public:
|
public:
|
||||||
//NOTICE:the border is 10^6, but the block is larger, 1M
|
//NOTICE:the border is 10^6, but the block is larger, 1M
|
||||||
static const unsigned LENGTH_BORDER = 1000000;
|
static const unsigned LENGTH_BORDER = 1000000;
|
||||||
//static const unsigned LENGTH_BORDER = 1000;
|
//static const unsigned LENGTH_BORDER = 100;
|
||||||
static const unsigned BLOCK_SIZE = 1 << 20; //fixed size of disk-block
|
static const unsigned BLOCK_SIZE = 1 << 20; //fixed size of disk-block
|
||||||
static const unsigned MAX_BLOCK_NUM = 1 << 23; //max block-num
|
static const unsigned MAX_BLOCK_NUM = 1 << 23; //max block-num
|
||||||
//below two constants: must can be exactly divided by 8
|
//below two constants: must can be exactly divided by 8
|
||||||
|
|
|
@ -934,7 +934,7 @@ VSTree::split(VNode* _p_node_being_split, const SigEntry& _insert_entry, VNode*
|
||||||
bool is_leaf = oldNodePtr->isLeaf();
|
bool is_leaf = oldNodePtr->isLeaf();
|
||||||
// then create a new node to act as BEntryIndex's father.
|
// then create a new node to act as BEntryIndex's father.
|
||||||
VNode* newNodePtr = this->createNode(is_leaf);
|
VNode* newNodePtr = this->createNode(is_leaf);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_VSTREE
|
||||||
cout<<"new node file line: "<<newNodePtr->getFileLine()<<endl;
|
cout<<"new node file line: "<<newNodePtr->getFileLine()<<endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue