Merge branch 'qinzongyue' into bookug

deal with errors in build
This commit is contained in:
bookug 2017-07-15 17:42:49 +08:00
commit 26b619a80e
4 changed files with 18 additions and 26 deletions

View File

@ -188,7 +188,6 @@ IVTree::insert(unsigned _key, char* _str, unsigned _len)
this->TSM->updateHeap(ret, ret->getRank(), false); this->TSM->updateHeap(ret, ret->getRank(), false);
this->root = father; this->root = father;
} }
IVNode* p = this->root; IVNode* p = this->root;
IVNode* q; IVNode* q;
int i; int i;
@ -255,7 +254,6 @@ IVTree::insert(unsigned _key, char* _str, unsigned _len)
//_key->clear(); //_key->clear();
//_value->clear(); //_value->clear();
} }
this->TSM->request(request); this->TSM->request(request);
return !ifexist; //QUERY(which case:return false) return !ifexist; //QUERY(which case:return false)
} }

View File

@ -1834,12 +1834,13 @@ KVstore::build_objID2values(ID_TUPLE* _p_id_tuples, TYPE_TRIPLE_NUM _triples_num
for (k = 0; k < _sidlist_o.size(); j++, k++) { for (k = 0; k < _sidlist_o.size(); j++, k++) {
_entrylist_o[j] = _sidlist_o[k]; _entrylist_o[j] = _sidlist_o[k];
} }
this->addValueByKey(this->objID2values, _obj_id, (char*)_entrylist_o, sizeof(unsigned) * j); this->addValueByKey(this->objID2values, _obj_id, (char*)_entrylist_o, sizeof(unsigned) * j);
//delete[] _entrylist_o; //delete[] _entrylist_o;
} }
} }
} }
this->close_objID2values(); this->close_objID2values();
cout << "Finished building objID2values" << endl; cout << "Finished building objID2values" << endl;
return true; return true;

View File

@ -33,8 +33,6 @@ VList::VList()
freelist = NULL; freelist = NULL;
max_buffer_size = Util::MAX_BUFFER_SIZE; max_buffer_size = Util::MAX_BUFFER_SIZE;
freemem = max_buffer_size; freemem = max_buffer_size;
if (longlist != NULL) delete [] longlist;
longlist = new Longlist_inMem [2000];
} }
VList::VList(string& _filepath, string& _mode, unsigned long long _buffer_size) VList::VList(string& _filepath, string& _mode, unsigned long long _buffer_size)
@ -42,10 +40,6 @@ VList::VList(string& _filepath, string& _mode, unsigned long long _buffer_size)
vlist_cache_left = CACHE_CAPACITY; vlist_cache_left = CACHE_CAPACITY;
cur_block_num = SET_BLOCK_NUM; //initialize cur_block_num = SET_BLOCK_NUM; //initialize
this->filepath = _filepath; this->filepath = _filepath;
if (longlist != NULL) delete [] longlist;
longlist = new Longlist_inMem [2000];
if (_mode == string("build")) if (_mode == string("build"))
valfp = fopen(_filepath.c_str(), "w+b"); valfp = fopen(_filepath.c_str(), "w+b");
else if (_mode == string("open")) else if (_mode == string("open"))
@ -207,19 +201,19 @@ VList::readValue(unsigned _block_num, char*& _str, unsigned& _len, unsigned _key
_len = strlen(_str); _len = strlen(_str);
return true; return true;
}*/ }*/
unsigned node = _key % 2000, i; unsigned node = _key % 2000, i;
for(i = node; longlist[i].key % 2000 <= node; ++i) for(i = node; longlist[i].key % 2000 <= node; ++i)
if (longlist[i].key == (int)_key || longlist[i].key == -1) break; if (longlist[i].key == (int)_key || longlist[i].key == -1) break;
if (longlist[i].key == (int)_key) // value is in cache if (longlist[i].key == (int)_key) // value is in cache
{ {
// cout << "access in cache" << endl; // cout << "access in cache" << endl;
// accessOfCache++; // accessOfCache++;
_len = longlist[i]._len; _len = longlist[i]._len;
_str = new char[_len]; _str = new char[_len];
memcpy(_str, longlist[i]._str, _len); memcpy(_str, longlist[i]._str, _len);
// cout << _len << endl; // cout << _len << endl;
return true; return true;
} }
//if not in cache, read from disk(add a random seek time), the pointer should be clear in upper layer //if not in cache, read from disk(add a random seek time), the pointer should be clear in upper layer
fseek(valfp, Address(_block_num), SEEK_SET); fseek(valfp, Address(_block_num), SEEK_SET);
@ -376,8 +370,6 @@ VList::writeBstr(const char* _str, unsigned _len, unsigned* _curnum)
void void
VList::AddIntoCache(unsigned _key, char*& _str, unsigned _len) VList::AddIntoCache(unsigned _key, char*& _str, unsigned _len)
{ {
// cout << "vlist::addintocache" << endl;
// cout << _len << endl;
unsigned node = _key % 2000; unsigned node = _key % 2000;
while (longlist[node].key != -1) while (longlist[node].key != -1)
node++; node++;
@ -396,7 +388,8 @@ VList::~VList()
delete[] it->second; delete[] it->second;
} }
this->vlist_cache.clear(); this->vlist_cache.clear();
if (longlist != NULL) delete [] longlist; for(int i = 0; i < 2000; i++)
delete [] longlist[i]._str;
//write the info back //write the info back
fseek(this->valfp, 0, SEEK_SET); fseek(this->valfp, 0, SEEK_SET);
fwrite(&cur_block_num, sizeof(unsigned), 1, valfp);//write current blocks num fwrite(&cur_block_num, sizeof(unsigned), 1, valfp);//write current blocks num

View File

@ -76,7 +76,7 @@ private:
//<10%: 5000000~100M bytes //<10%: 5000000~100M bytes
FILE* valfp; FILE* valfp;
// cache for vlist. // cache for vlist.
Longlist_inMem* longlist; Longlist_inMem longlist[2000];
//NOTICE: freemem's type is long long here, due to large memory in server. //NOTICE: freemem's type is long long here, due to large memory in server.
//However, needmem in handler() and request() is ok to be int/unsigned. //However, needmem in handler() and request() is ok to be int/unsigned.
//Because the bstr' size is controlled, so is the node. //Because the bstr' size is controlled, so is the node.