rename logtree to diskTreeComponent
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@591 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
2b82a62a34
commit
57c9afc8d8
16 changed files with 110 additions and 110 deletions
|
@ -23,18 +23,18 @@
|
|||
// LOGTREE implementation
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
const RegionAllocConf_t logtree::REGION_ALLOC_STATIC_INITIALIZER = { {0,0,-1}, 0, -1, -1, 1000 };
|
||||
const RegionAllocConf_t diskTreeComponent::REGION_ALLOC_STATIC_INITIALIZER = { {0,0,-1}, 0, -1, -1, 1000 };
|
||||
|
||||
#define LOGTREE_ROOT_PAGE SLOTTED_PAGE
|
||||
|
||||
//LSM_ROOT_PAGE
|
||||
|
||||
const int64_t logtree::DEPTH = 0; //in root this is the slot num where the DEPTH (of tree) is stored
|
||||
const int64_t logtree::COMPARATOR = 1; //in root this is the slot num where the COMPARATOR id is stored
|
||||
const int64_t logtree::FIRST_SLOT = 2; //this is the first unused slot in all index pages
|
||||
const size_t logtree::root_rec_size = sizeof(int64_t);
|
||||
const int64_t logtree::PREV_LEAF = 0; //pointer to prev leaf page
|
||||
const int64_t logtree::NEXT_LEAF = 1; //pointer to next leaf page
|
||||
const int64_t diskTreeComponent::DEPTH = 0; //in root this is the slot num where the DEPTH (of tree) is stored
|
||||
const int64_t diskTreeComponent::COMPARATOR = 1; //in root this is the slot num where the COMPARATOR id is stored
|
||||
const int64_t diskTreeComponent::FIRST_SLOT = 2; //this is the first unused slot in all index pages
|
||||
const size_t diskTreeComponent::root_rec_size = sizeof(int64_t);
|
||||
const int64_t diskTreeComponent::PREV_LEAF = 0; //pointer to prev leaf page
|
||||
const int64_t diskTreeComponent::NEXT_LEAF = 1; //pointer to next leaf page
|
||||
|
||||
// XXX hack, and cut and pasted from datapage.cpp.
|
||||
static lsn_t get_lsn(int xid) {
|
||||
|
@ -46,7 +46,7 @@ static lsn_t get_lsn(int xid) {
|
|||
}
|
||||
|
||||
|
||||
void logtree::init_stasis() {
|
||||
void diskTreeComponent::init_stasis() {
|
||||
|
||||
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_PFILE;
|
||||
|
||||
|
@ -58,9 +58,9 @@ void logtree::init_stasis() {
|
|||
|
||||
}
|
||||
|
||||
void logtree::deinit_stasis() { Tdeinit(); }
|
||||
void diskTreeComponent::deinit_stasis() { Tdeinit(); }
|
||||
|
||||
void logtree::free_region_rid(int xid, recordid tree,
|
||||
void diskTreeComponent::free_region_rid(int xid, recordid tree,
|
||||
logtree_page_deallocator_t dealloc, void *allocator_state)
|
||||
{
|
||||
// Tdealloc(xid,tree);
|
||||
|
@ -70,7 +70,7 @@ void logtree::free_region_rid(int xid, recordid tree,
|
|||
}
|
||||
|
||||
|
||||
void logtree::dealloc_region_rid(int xid, recordid rid)
|
||||
void diskTreeComponent::dealloc_region_rid(int xid, recordid rid)
|
||||
{
|
||||
RegionAllocConf_t a;
|
||||
Tread(xid,rid,&a);
|
||||
|
@ -83,12 +83,12 @@ void logtree::dealloc_region_rid(int xid, recordid rid)
|
|||
TregionDealloc(xid,pid);
|
||||
}
|
||||
a.regionList.slot = 0;
|
||||
// printf("Warning: leaking arraylist %lld in logtree\n", (long long)a.regionList.page);
|
||||
// printf("Warning: leaking arraylist %lld in diskTreeComponent\n", (long long)a.regionList.page);
|
||||
TarrayListDealloc(xid, a.regionList);
|
||||
}
|
||||
|
||||
|
||||
void logtree::force_region_rid(int xid, recordid rid)
|
||||
void diskTreeComponent::force_region_rid(int xid, recordid rid)
|
||||
{
|
||||
RegionAllocConf_t a;
|
||||
Tread(xid,rid,&a);
|
||||
|
@ -106,7 +106,7 @@ void logtree::force_region_rid(int xid, recordid rid)
|
|||
}
|
||||
|
||||
|
||||
pageid_t logtree::alloc_region(int xid, void *conf)
|
||||
pageid_t diskTreeComponent::alloc_region(int xid, void *conf)
|
||||
{
|
||||
RegionAllocConf_t* a = (RegionAllocConf_t*)conf;
|
||||
|
||||
|
@ -142,7 +142,7 @@ pageid_t logtree::alloc_region(int xid, void *conf)
|
|||
|
||||
}
|
||||
|
||||
pageid_t logtree::alloc_region_rid(int xid, void * ridp) {
|
||||
pageid_t diskTreeComponent::alloc_region_rid(int xid, void * ridp) {
|
||||
recordid rid = *(recordid*)ridp;
|
||||
RegionAllocConf_t conf;
|
||||
Tread(xid,rid,&conf);
|
||||
|
@ -154,7 +154,7 @@ pageid_t logtree::alloc_region_rid(int xid, void * ridp) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
pageid_t * logtree::list_region_rid(int xid, void *ridp, pageid_t * region_len, pageid_t * region_count) {
|
||||
pageid_t * diskTreeComponent::list_region_rid(int xid, void *ridp, pageid_t * region_len, pageid_t * region_count) {
|
||||
recordid header = *(recordid*)ridp;
|
||||
RegionAllocConf_t conf;
|
||||
Tread(xid,header,&conf);
|
||||
|
@ -171,7 +171,7 @@ pageid_t * logtree::list_region_rid(int xid, void *ridp, pageid_t * region_len,
|
|||
|
||||
|
||||
|
||||
recordid logtree::create(int xid)
|
||||
recordid diskTreeComponent::create(int xid)
|
||||
{
|
||||
|
||||
tree_state = Talloc(xid,sizeof(RegionAllocConf_t));
|
||||
|
@ -223,7 +223,7 @@ recordid logtree::create(int xid)
|
|||
* TODO: what happen if there is already such a record with a different size?
|
||||
* I guess this should never happen in rose, but what if?
|
||||
**/
|
||||
void logtree::writeRecord(int xid, Page *p, recordid &rid,
|
||||
void diskTreeComponent::writeRecord(int xid, Page *p, recordid &rid,
|
||||
const byte *data, size_t datalen)
|
||||
{
|
||||
byte *byte_arr = stasis_record_write_begin(xid, p, rid);
|
||||
|
@ -234,7 +234,7 @@ void logtree::writeRecord(int xid, Page *p, recordid &rid,
|
|||
}
|
||||
|
||||
|
||||
void logtree::writeNodeRecord(int xid, Page * p, recordid & rid,
|
||||
void diskTreeComponent::writeNodeRecord(int xid, Page * p, recordid & rid,
|
||||
const byte *key, size_t keylen, pageid_t ptr)
|
||||
{
|
||||
DEBUG("writenoderecord:\tp->id\t%lld\tkey:\t%s\tkeylen: %d\tval_page\t%lld\n",
|
||||
|
@ -246,7 +246,7 @@ void logtree::writeNodeRecord(int xid, Page * p, recordid & rid,
|
|||
stasis_page_lsn_write(xid, p, get_lsn(xid));
|
||||
}
|
||||
|
||||
void logtree::writeRecord(int xid, Page *p, slotid_t slot,
|
||||
void diskTreeComponent::writeRecord(int xid, Page *p, slotid_t slot,
|
||||
const byte *data, size_t datalen)
|
||||
{
|
||||
recordid rid;
|
||||
|
@ -260,13 +260,13 @@ void logtree::writeRecord(int xid, Page *p, slotid_t slot,
|
|||
|
||||
}
|
||||
|
||||
const byte* logtree::readRecord(int xid, Page * p, recordid &rid)
|
||||
const byte* diskTreeComponent::readRecord(int xid, Page * p, recordid &rid)
|
||||
{
|
||||
const byte *nr = stasis_record_read_begin(xid,p,rid); // XXX API violation?
|
||||
return nr;
|
||||
}
|
||||
|
||||
const byte* logtree::readRecord(int xid, Page * p, slotid_t slot, int64_t size)
|
||||
const byte* diskTreeComponent::readRecord(int xid, Page * p, slotid_t slot, int64_t size)
|
||||
{
|
||||
recordid rid;
|
||||
rid.page = p->id;
|
||||
|
@ -281,14 +281,14 @@ const byte* logtree::readRecord(int xid, Page * p, slotid_t slot, int64_t size)
|
|||
|
||||
}
|
||||
|
||||
int32_t logtree::readRecordLength(int xid, Page *p, slotid_t slot)
|
||||
int32_t diskTreeComponent::readRecordLength(int xid, Page *p, slotid_t slot)
|
||||
{
|
||||
recordid rec = {p->id, slot, 0};
|
||||
int32_t reclen = stasis_record_length_read(xid, p, rec);
|
||||
return reclen;
|
||||
}
|
||||
|
||||
void logtree::initializeNodePage(int xid, Page *p)
|
||||
void diskTreeComponent::initializeNodePage(int xid, Page *p)
|
||||
{
|
||||
stasis_page_slotted_initialize_page(p);
|
||||
recordid reserved1 = stasis_record_alloc_begin(xid, p, sizeof(indexnode_rec));
|
||||
|
@ -298,7 +298,7 @@ void logtree::initializeNodePage(int xid, Page *p)
|
|||
}
|
||||
|
||||
|
||||
recordid logtree::appendPage(int xid, recordid tree, pageid_t & rmLeafID,
|
||||
recordid diskTreeComponent::appendPage(int xid, recordid tree, pageid_t & rmLeafID,
|
||||
const byte *key, size_t keySize,
|
||||
lsm_page_allocator_t allocator, void *allocator_state,
|
||||
long val_page)
|
||||
|
@ -449,7 +449,7 @@ recordid logtree::appendPage(int xid, recordid tree, pageid_t & rmLeafID,
|
|||
|
||||
stasis_record_alloc_done(xid, lastLeaf, ret);
|
||||
|
||||
logtree::writeNodeRecord(xid, lastLeaf, ret, key, keySize, val_page);
|
||||
diskTreeComponent::writeNodeRecord(xid, lastLeaf, ret, key, keySize, val_page);
|
||||
|
||||
if(lastLeaf->id != p->id) {
|
||||
assert(rmLeafID != tree.page);
|
||||
|
@ -478,7 +478,7 @@ recordid logtree::appendPage(int xid, recordid tree, pageid_t & rmLeafID,
|
|||
|
||||
*/
|
||||
|
||||
recordid logtree::appendInternalNode(int xid, Page *p,
|
||||
recordid diskTreeComponent::appendInternalNode(int xid, Page *p,
|
||||
int64_t depth,
|
||||
const byte *key, size_t key_len,
|
||||
pageid_t val_page, pageid_t lastLeaf,
|
||||
|
@ -550,7 +550,7 @@ recordid logtree::appendInternalNode(int xid, Page *p,
|
|||
}
|
||||
}
|
||||
|
||||
recordid logtree::buildPathToLeaf(int xid, recordid root, Page *root_p,
|
||||
recordid diskTreeComponent::buildPathToLeaf(int xid, recordid root, Page *root_p,
|
||||
int64_t depth, const byte *key, size_t key_len,
|
||||
pageid_t val_page, pageid_t lastLeaf,
|
||||
logtree_page_allocator_t allocator,
|
||||
|
@ -633,7 +633,7 @@ recordid logtree::buildPathToLeaf(int xid, recordid root, Page *root_p,
|
|||
* Traverse from the root of the page to the right most leaf (the one
|
||||
* with the higest base key value).
|
||||
**/
|
||||
pageid_t logtree::findLastLeaf(int xid, Page *root, int64_t depth)
|
||||
pageid_t diskTreeComponent::findLastLeaf(int xid, Page *root, int64_t depth)
|
||||
{
|
||||
if(!depth)
|
||||
{
|
||||
|
@ -661,7 +661,7 @@ pageid_t logtree::findLastLeaf(int xid, Page *root, int64_t depth)
|
|||
* Traverse from the root of the tree to the left most (lowest valued
|
||||
* key) leaf.
|
||||
*/
|
||||
pageid_t logtree::findFirstLeaf(int xid, Page *root, int64_t depth)
|
||||
pageid_t diskTreeComponent::findFirstLeaf(int xid, Page *root, int64_t depth)
|
||||
{
|
||||
if(!depth) //if depth is 0, then returns the id of the page
|
||||
return root->id;
|
||||
|
@ -678,7 +678,7 @@ pageid_t logtree::findFirstLeaf(int xid, Page *root, int64_t depth)
|
|||
}
|
||||
|
||||
|
||||
pageid_t logtree::findPage(int xid, recordid tree, const byte *key, size_t keySize)
|
||||
pageid_t diskTreeComponent::findPage(int xid, recordid tree, const byte *key, size_t keySize)
|
||||
{
|
||||
Page *p = loadPage(xid, tree.page);
|
||||
readlock(p->rwlatch,0);
|
||||
|
@ -696,7 +696,7 @@ pageid_t logtree::findPage(int xid, recordid tree, const byte *key, size_t keySi
|
|||
|
||||
}
|
||||
|
||||
pageid_t logtree::lookupLeafPageFromRid(int xid, recordid rid)
|
||||
pageid_t diskTreeComponent::lookupLeafPageFromRid(int xid, recordid rid)
|
||||
{
|
||||
pageid_t pid = -1;
|
||||
if(rid.page != NULLRID.page || rid.slot != NULLRID.slot)
|
||||
|
@ -711,7 +711,7 @@ pageid_t logtree::lookupLeafPageFromRid(int xid, recordid rid)
|
|||
}
|
||||
|
||||
|
||||
recordid logtree::lookup(int xid,
|
||||
recordid diskTreeComponent::lookup(int xid,
|
||||
Page *node,
|
||||
int64_t depth,
|
||||
const byte *key, size_t keySize )
|
||||
|
@ -755,7 +755,7 @@ recordid logtree::lookup(int xid,
|
|||
}
|
||||
|
||||
|
||||
void logtree::print_tree(int xid)
|
||||
void diskTreeComponent::print_tree(int xid)
|
||||
{
|
||||
Page *p = loadPage(xid, root_rec.page);
|
||||
readlock(p->rwlatch,0);
|
||||
|
@ -771,7 +771,7 @@ void logtree::print_tree(int xid)
|
|||
|
||||
}
|
||||
|
||||
void logtree::print_tree(int xid, pageid_t pid, int64_t depth)
|
||||
void diskTreeComponent::print_tree(int xid, pageid_t pid, int64_t depth)
|
||||
{
|
||||
|
||||
Page *node = loadPage(xid, pid);
|
||||
|
@ -840,14 +840,14 @@ lladdIterator_t* logtreeIterator::open(int xid, recordid root)
|
|||
readlock(p->rwlatch,0);
|
||||
|
||||
//size_t keySize = getKeySize(xid,p);
|
||||
DEBUG("ROOT_REC_SIZE %d\n", logtree::root_rec_size);
|
||||
const byte * nr = logtree::readRecord(xid,p,
|
||||
logtree::DEPTH,
|
||||
logtree::root_rec_size);
|
||||
DEBUG("ROOT_REC_SIZE %d\n", diskTreeComponent::root_rec_size);
|
||||
const byte * nr = diskTreeComponent::readRecord(xid,p,
|
||||
diskTreeComponent::DEPTH,
|
||||
diskTreeComponent::root_rec_size);
|
||||
int64_t depth = *((int64_t*)nr);
|
||||
DEBUG("DEPTH = %lld\n", depth);
|
||||
|
||||
pageid_t leafid = logtree::findFirstLeaf(xid, p, depth);
|
||||
pageid_t leafid = diskTreeComponent::findFirstLeaf(xid, p, depth);
|
||||
if(leafid != root.page)
|
||||
{
|
||||
unlock(p->rwlatch);
|
||||
|
@ -885,12 +885,12 @@ lladdIterator_t* logtreeIterator::openAt(int xid, recordid root, const byte* key
|
|||
readlock(p->rwlatch,0);
|
||||
//size_t keySize = getKeySize(xid,p);
|
||||
//assert(keySize);
|
||||
const byte *nr = logtree::readRecord(xid,p,logtree::DEPTH, logtree::root_rec_size);
|
||||
//const byte *cmp_nr = logtree::readRecord(xid, p , logtree::COMPARATOR, logtree::root_rec_size);
|
||||
const byte *nr = diskTreeComponent::readRecord(xid,p,diskTreeComponent::DEPTH, diskTreeComponent::root_rec_size);
|
||||
//const byte *cmp_nr = diskTreeComponent::readRecord(xid, p , diskTreeComponent::COMPARATOR, diskTreeComponent::root_rec_size);
|
||||
|
||||
int64_t depth = *((int64_t*)nr);
|
||||
|
||||
recordid lsm_entry_rid = logtree::lookup(xid,p,depth,key,0);//keySize,comparators[cmp_nr->ptr]);
|
||||
recordid lsm_entry_rid = diskTreeComponent::lookup(xid,p,depth,key,0);//keySize,comparators[cmp_nr->ptr]);
|
||||
|
||||
if(lsm_entry_rid.page == NULLRID.page && lsm_entry_rid.slot == NULLRID.slot) {
|
||||
unlock(p->rwlatch);
|
||||
|
@ -934,8 +934,8 @@ int logtreeIterator::next(int xid, lladdIterator_t *it)
|
|||
if(impl->current.size == INVALID_SLOT)
|
||||
{
|
||||
|
||||
const indexnode_rec next_rec = *(const indexnode_rec*)logtree::readRecord(xid,impl->p,
|
||||
logtree::NEXT_LEAF,
|
||||
const indexnode_rec next_rec = *(const indexnode_rec*)diskTreeComponent::readRecord(xid,impl->p,
|
||||
diskTreeComponent::NEXT_LEAF,
|
||||
0);
|
||||
unlock(impl->p->rwlatch);
|
||||
releasePage(impl->p);
|
||||
|
@ -972,7 +972,7 @@ int logtreeIterator::next(int xid, lladdIterator_t *it)
|
|||
free(impl->t);
|
||||
|
||||
impl->t = (indexnode_rec*)malloc(impl->current.size);
|
||||
memcpy(impl->t, logtree::readRecord(xid,impl->p,impl->current), impl->current.size);
|
||||
memcpy(impl->t, diskTreeComponent::readRecord(xid,impl->p,impl->current), impl->current.size);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ typedef pageid_t(*logtree_page_allocator_t)(int, void *);
|
|||
typedef void(*logtree_page_deallocator_t)(int, void *);
|
||||
|
||||
|
||||
class logtree{
|
||||
class diskTreeComponent{
|
||||
public:
|
||||
logtree(int xid): region_alloc(new DataPage<datatuple>::RegionAllocator(xid, 10000)) {create(xid);} // XXX shouldn't hardcode region size.
|
||||
diskTreeComponent(int xid): region_alloc(new DataPage<datatuple>::RegionAllocator(xid, 10000)) {create(xid);} // XXX shouldn't hardcode region size.
|
||||
private:
|
||||
recordid create(int xid);
|
||||
public:
|
||||
|
|
|
@ -71,7 +71,7 @@ private:
|
|||
private:
|
||||
recordid tree_; //root of the tree
|
||||
|
||||
lladdIterator_t * lsmIterator_; //logtree iterator
|
||||
lladdIterator_t * lsmIterator_; //diskTreeComponent iterator
|
||||
|
||||
pageid_t curr_pageid; //current page id
|
||||
DataPage<TUPLE> *curr_page; //current page
|
||||
|
|
|
@ -531,13 +531,13 @@ void * thread_work_fn( void * args)
|
|||
recordid tree_c1_region_header = item->data->ltable->get_tree_c1()->get_tree_state();
|
||||
recordid tree_c2_region_header = item->data->ltable->get_tree_c2()->get_tree_state();
|
||||
|
||||
pageid_t * tree_c1_regions = logtree::list_region_rid(xid, &tree_c1_region_header, &tree_c1_region_length, &tree_c1_region_count);
|
||||
pageid_t * tree_c1_regions = diskTreeComponent::list_region_rid(xid, &tree_c1_region_header, &tree_c1_region_length, &tree_c1_region_count);
|
||||
pageid_t * tree_c1_mergeable_regions = NULL;
|
||||
if(item->data->ltable->get_tree_c1_mergeable()) {
|
||||
recordid tree_c1_mergeable_region_header = item->data->ltable->get_tree_c1_mergeable()->get_tree_state();
|
||||
tree_c1_mergeable_regions = logtree::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
|
||||
tree_c1_mergeable_regions = diskTreeComponent::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
|
||||
}
|
||||
pageid_t * tree_c2_regions = logtree::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
|
||||
pageid_t * tree_c2_regions = diskTreeComponent::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
|
||||
unlock(item->data->ltable->getMergeData()->header_lock);
|
||||
|
||||
Tcommit(xid);
|
||||
|
|
12
logstore.cpp
12
logstore.cpp
|
@ -90,11 +90,11 @@ recordid logtable::allocTable(int xid)
|
|||
|
||||
//create the big tree
|
||||
tbl_header.c2_dp_state = Talloc(xid, DataPage<datatuple>::RegionAllocator::header_size);
|
||||
tree_c2 = new logtree(xid);
|
||||
tree_c2 = new diskTreeComponent(xid);
|
||||
|
||||
//create the small tree
|
||||
tbl_header.c1_dp_state = Talloc(xid, DataPage<datatuple>::RegionAllocator::header_size);
|
||||
tree_c1 = new logtree(xid);
|
||||
tree_c1 = new diskTreeComponent(xid);
|
||||
|
||||
tbl_header.c2_root = tree_c2->get_root_rec();
|
||||
tbl_header.c2_dp_state = tree_c2->get_alloc()->header_rid();
|
||||
|
@ -471,7 +471,7 @@ void logtable::insertTuple(datatuple *tuple)
|
|||
}
|
||||
|
||||
|
||||
DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, logtree *ltree)
|
||||
DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, diskTreeComponent *ltree)
|
||||
{
|
||||
//create a new data page -- either the last region is full, or the last data page doesn't want our tuple. (or both)
|
||||
|
||||
|
@ -494,9 +494,9 @@ DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, logtree *l
|
|||
|
||||
|
||||
RegionAllocConf_t alloc_conf;
|
||||
//insert the record key and id of the first page of the datapage to the logtree
|
||||
//insert the record key and id of the first page of the datapage to the diskTreeComponent
|
||||
Tread(xid,ltree->get_tree_state(), &alloc_conf);
|
||||
logtree::appendPage(xid, ltree->get_root_rec(), ltree->lastLeaf,
|
||||
diskTreeComponent::appendPage(xid, ltree->get_root_rec(), ltree->lastLeaf,
|
||||
tuple->key(),
|
||||
tuple->keylen(),
|
||||
ltree->alloc_region,
|
||||
|
@ -510,7 +510,7 @@ DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, logtree *l
|
|||
return dp;
|
||||
}
|
||||
|
||||
datatuple * logtable::findTuple(int xid, datatuple::key_t key, size_t keySize, logtree *ltree)
|
||||
datatuple * logtable::findTuple(int xid, datatuple::key_t key, size_t keySize, diskTreeComponent *ltree)
|
||||
{
|
||||
datatuple * tup=0;
|
||||
|
||||
|
|
22
logstore.h
22
logstore.h
|
@ -65,19 +65,19 @@ public:
|
|||
|
||||
static void tearDownTree(rbtree_ptr_t t);
|
||||
|
||||
DataPage<datatuple>* insertTuple(int xid, datatuple *tuple,logtree *ltree);
|
||||
DataPage<datatuple>* insertTuple(int xid, datatuple *tuple,diskTreeComponent *ltree);
|
||||
|
||||
datatuple * findTuple(int xid, const datatuple::key_t key, size_t keySize, logtree *ltree);
|
||||
datatuple * findTuple(int xid, const datatuple::key_t key, size_t keySize, diskTreeComponent *ltree);
|
||||
|
||||
inline recordid & get_table_rec(){return table_rec;} // TODO This is called by merger.cpp for no good reason. (remove the calls)
|
||||
|
||||
inline logtree * get_tree_c2(){return tree_c2;}
|
||||
inline logtree * get_tree_c1(){return tree_c1;}
|
||||
inline logtree * get_tree_c1_mergeable(){return tree_c1_mergeable;}
|
||||
inline diskTreeComponent * get_tree_c2(){return tree_c2;}
|
||||
inline diskTreeComponent * get_tree_c1(){return tree_c1;}
|
||||
inline diskTreeComponent * get_tree_c1_mergeable(){return tree_c1_mergeable;}
|
||||
|
||||
inline void set_tree_c1(logtree *t){tree_c1=t;}
|
||||
inline void set_tree_c1_mergeable(logtree *t){tree_c1_mergeable=t;}
|
||||
inline void set_tree_c2(logtree *t){tree_c2=t;}
|
||||
inline void set_tree_c1(diskTreeComponent *t){tree_c1=t;}
|
||||
inline void set_tree_c1_mergeable(diskTreeComponent *t){tree_c1_mergeable=t;}
|
||||
inline void set_tree_c2(diskTreeComponent *t){tree_c2=t;}
|
||||
|
||||
inline rbtree_ptr_t get_tree_c0(){return tree_c0;}
|
||||
inline rbtree_ptr_t get_tree_c0_mergeable(){return tree_c0_mergeable;}
|
||||
|
@ -119,9 +119,9 @@ private:
|
|||
recordid table_rec;
|
||||
struct table_header tbl_header;
|
||||
|
||||
logtree *tree_c2; //big tree
|
||||
logtree *tree_c1; //small tree
|
||||
logtree *tree_c1_mergeable; //small tree: ready to be merged with c2
|
||||
diskTreeComponent *tree_c2; //big tree
|
||||
diskTreeComponent *tree_c1; //small tree
|
||||
diskTreeComponent *tree_c1_mergeable; //small tree: ready to be merged with c2
|
||||
rbtree_ptr_t tree_c0; // in-mem red black tree
|
||||
rbtree_ptr_t tree_c0_mergeable; // in-mem red black tree: ready to be merged with c1.
|
||||
|
||||
|
|
24
merger.cpp
24
merger.cpp
|
@ -7,7 +7,7 @@
|
|||
inline DataPage<datatuple>*
|
||||
insertTuple(int xid, DataPage<datatuple> *dp, datatuple *t,
|
||||
logtable *ltable,
|
||||
logtree * ltree,
|
||||
diskTreeComponent * ltree,
|
||||
int64_t &dpages, int64_t &npages);
|
||||
|
||||
int merge_scheduler::addlogtable(logtable *ltable)
|
||||
|
@ -139,7 +139,7 @@ void merge_scheduler::startlogtable(int index, int64_t MAX_C0_SIZE)
|
|||
|
||||
ltable->max_c0_size = MAX_C0_SIZE;
|
||||
|
||||
logtree ** block1_scratch = new logtree*;
|
||||
diskTreeComponent ** block1_scratch = new diskTreeComponent*;
|
||||
*block1_scratch=0;
|
||||
|
||||
DEBUG("Tree C1 is %lld\n", (long long)ltable->get_tree_c1()->get_root_rec().page);
|
||||
|
@ -267,7 +267,7 @@ void* memMergeThread(void*arg)
|
|||
|
||||
|
||||
//create a new tree
|
||||
logtree * c1_prime = new logtree(xid); // XXX should not hardcode region size)
|
||||
diskTreeComponent * c1_prime = new diskTreeComponent(xid); // XXX should not hardcode region size)
|
||||
|
||||
//pthread_mutex_unlock(a->block_ready_mut);
|
||||
unlock(ltable->mergedata->header_lock);
|
||||
|
@ -284,12 +284,12 @@ void* memMergeThread(void*arg)
|
|||
// 5: force c1'
|
||||
|
||||
//force write the new region to disk
|
||||
logtree::force_region_rid(xid, c1_prime->get_tree_state());
|
||||
diskTreeComponent::force_region_rid(xid, c1_prime->get_tree_state());
|
||||
//force write the new datapages
|
||||
c1_prime->get_alloc()->force_regions(xid);
|
||||
|
||||
// 6: delete c1 and c0_mergeable
|
||||
logtree::dealloc_region_rid(xid, ltable->get_tree_c1()->get_tree_state());
|
||||
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c1()->get_tree_state());
|
||||
ltable->get_tree_c1()->get_alloc()->dealloc_regions(xid);
|
||||
|
||||
logtable::tearDownTree(ltable->get_tree_c0_mergeable());
|
||||
|
@ -314,7 +314,7 @@ void* memMergeThread(void*arg)
|
|||
// 7: c1' is too big
|
||||
|
||||
// 8: c1 = new empty.
|
||||
ltable->set_tree_c1(new logtree(xid));
|
||||
ltable->set_tree_c1(new diskTreeComponent(xid));
|
||||
|
||||
printf("mmt:\tsignaling C2 for merge\n");
|
||||
printf("mmt:\tnew_c1_size %.2f\tMAX_C0_SIZE %lld\ta->max_size %lld\t targetr %.2f \n", new_c1_size,
|
||||
|
@ -415,7 +415,7 @@ void *diskMergeThread(void*arg)
|
|||
|
||||
//create a new tree
|
||||
//TODO: maybe you want larger regions for the second tree?
|
||||
logtree * c2_prime = new logtree(xid);
|
||||
diskTreeComponent * c2_prime = new diskTreeComponent(xid);
|
||||
|
||||
unlock(ltable->mergedata->header_lock);
|
||||
|
||||
|
@ -430,15 +430,15 @@ void *diskMergeThread(void*arg)
|
|||
delete itrB;
|
||||
|
||||
//force write the new region to disk
|
||||
logtree::force_region_rid(xid, c2_prime->get_tree_state());
|
||||
diskTreeComponent::force_region_rid(xid, c2_prime->get_tree_state());
|
||||
c2_prime->get_alloc()->force_regions(xid);
|
||||
|
||||
logtree::dealloc_region_rid(xid, ltable->get_tree_c1_mergeable()->get_tree_state());
|
||||
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c1_mergeable()->get_tree_state());
|
||||
ltable->get_tree_c1_mergeable()->get_alloc()->dealloc_regions(xid);
|
||||
delete ltable->get_tree_c1_mergeable();
|
||||
ltable->set_tree_c1_mergeable(0);
|
||||
|
||||
logtree::dealloc_region_rid(xid, ltable->get_tree_c2()->get_tree_state());
|
||||
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c2()->get_tree_state());
|
||||
ltable->get_tree_c2()->get_alloc()->dealloc_regions(xid);
|
||||
delete ltable->get_tree_c2();
|
||||
|
||||
|
@ -473,7 +473,7 @@ int64_t merge_iterators(int xid,
|
|||
ITA *itrA, //iterator on c1 or c2
|
||||
ITB *itrB, //iterator on c0 or c1, respectively
|
||||
logtable *ltable,
|
||||
logtree *scratch_tree,
|
||||
diskTreeComponent *scratch_tree,
|
||||
int64_t &npages,
|
||||
bool dropDeletes // should be true iff this is biggest component
|
||||
)
|
||||
|
@ -550,7 +550,7 @@ int64_t merge_iterators(int xid,
|
|||
inline DataPage<datatuple>*
|
||||
insertTuple(int xid, DataPage<datatuple> *dp, datatuple *t,
|
||||
logtable *ltable,
|
||||
logtree * ltree,
|
||||
diskTreeComponent * ltree,
|
||||
int64_t &dpages, int64_t &npages)
|
||||
{
|
||||
if(dp==0)
|
||||
|
|
2
merger.h
2
merger.h
|
@ -78,7 +78,7 @@ int64_t merge_iterators(int xid,
|
|||
ITA *itrA,
|
||||
ITB *itrB,
|
||||
logtable *ltable,
|
||||
logtree *scratch_tree,
|
||||
diskTreeComponent *scratch_tree,
|
||||
int64_t &npages,
|
||||
bool dropDeletes);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void terminate (int param)
|
|||
|
||||
printf("Deinitializing stasis...\n");
|
||||
fflush(stdout);
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void initialize_server()
|
|||
//signal handling
|
||||
void (*prev_fn)(int);
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
prev_fn = signal (SIGINT,terminate);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
int xid = Tbegin();
|
||||
|
||||
|
@ -53,7 +53,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
recordid alloc_state = Talloc(xid,sizeof(RegionAllocConf_t));
|
||||
|
||||
Tset(xid,alloc_state, &logtree::REGION_ALLOC_STATIC_INITIALIZER);
|
||||
Tset(xid,alloc_state, &diskTreeComponent::REGION_ALLOC_STATIC_INITIALIZER);
|
||||
|
||||
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES);
|
||||
|
||||
|
@ -118,7 +118,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
Tcommit(xid);
|
||||
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ int main(int argc, char **argv)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
int xid = Tbegin();
|
||||
|
||||
|
@ -28,7 +28,7 @@ int main(int argc, char **argv)
|
|||
logtreeIterator::close(xid, it);
|
||||
Tcommit(xid);
|
||||
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
int xid = Tbegin();
|
||||
|
||||
|
@ -41,7 +41,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
Tcommit(xid);
|
||||
|
||||
xid = Tbegin();
|
||||
logtree *ltable_c1 = ltable.get_tree_c1();
|
||||
diskTreeComponent *ltable_c1 = ltable.get_tree_c1();
|
||||
|
||||
recordid tree_root = ltable_c1->get_root_rec();
|
||||
|
||||
|
@ -151,7 +151,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
printf("Random Reads completed.\n");
|
||||
Tcommit(xid);
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
}
|
||||
|
||||
/** @test
|
||||
|
|
|
@ -32,7 +32,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
int xid = Tbegin();
|
||||
|
||||
|
@ -43,7 +43,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
Tcommit(xid);
|
||||
|
||||
xid = Tbegin();
|
||||
logtree *lt = ltable.get_tree_c1();
|
||||
diskTreeComponent *lt = ltable.get_tree_c1();
|
||||
|
||||
recordid tree = lt->get_root_rec();
|
||||
|
||||
|
@ -73,7 +73,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
currkey[keylen-1]='\0';
|
||||
|
||||
//printf("\n#########\ni=%d\nkey:\t%s\nkeylen:%d\n",i,((char*)currkey),keylen);
|
||||
long pagenum = logtree::findPage(xid, tree, currkey, keylen);
|
||||
long pagenum = diskTreeComponent::findPage(xid, tree, currkey, keylen);
|
||||
//printf("pagenum:%d\n", pagenum);
|
||||
assert(pagenum == -1 || pagenum == oldpagenum || oldpagenum == -1);
|
||||
//printf("TlsmAppendPage %d\n",i);
|
||||
|
@ -82,7 +82,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
RegionAllocConf_t alloc_conf;
|
||||
Tread(xid,rid,&alloc_conf);
|
||||
|
||||
logtree::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
|
||||
diskTreeComponent::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
|
||||
|
||||
//DEBUG("{%lld <- alloc region extend}\n", conf.regionList.page);
|
||||
// XXX get rid of Tset by storing next page in memory, and losing it
|
||||
|
@ -90,7 +90,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
Tset(xid,rid,&alloc_conf);
|
||||
|
||||
|
||||
pagenum = logtree::findPage(xid, tree, currkey,keylen);
|
||||
pagenum = diskTreeComponent::findPage(xid, tree, currkey,keylen);
|
||||
oldpagenum = pagenum;
|
||||
//printf("pagenum:%d\n", pagenum);
|
||||
assert(pagenum == i + OFFSET);
|
||||
|
@ -118,7 +118,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
currkey[keylen-1]='\0';
|
||||
|
||||
//printf("\n#########\ni=%d\nkey:\t%s\nkeylen:%d\n",i,((char*)currkey),keylen);
|
||||
long pagenum = logtree::findPage(xid, tree, currkey, keylen);
|
||||
long pagenum = diskTreeComponent::findPage(xid, tree, currkey, keylen);
|
||||
//printf("pagenum:%d\n", pagenum);
|
||||
assert(pagenum == i + OFFSET);
|
||||
free(currkey);
|
||||
|
@ -150,7 +150,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
|
|||
logtreeIterator::close(xid, it);
|
||||
|
||||
Tcommit(xid);
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,7 +177,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
|
|||
Tcommit(xid);
|
||||
|
||||
xid = Tbegin();
|
||||
logtree *lt = ltable.get_tree_c1();
|
||||
diskTreeComponent *lt = ltable.get_tree_c1();
|
||||
|
||||
recordid tree = lt->get_root_rec();
|
||||
|
||||
|
@ -190,7 +190,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
|
|||
//currkey[]='\0';
|
||||
|
||||
printf("\n#########\ni=%d\nkey:\t%d\nkeylen:%d\n",i,*((int32_t*)currkey),keylen);
|
||||
pageid_t pagenum = logtree::findPage(xid, tree, currkey, keylen);
|
||||
pageid_t pagenum = diskTreeComponent::findPage(xid, tree, currkey, keylen);
|
||||
printf("pagenum:%lld\n", (long long)pagenum);
|
||||
assert(pagenum == -1 || pagenum == oldpagenum || oldpagenum == -1);
|
||||
printf("TlsmAppendPage %d\n",i);
|
||||
|
@ -199,7 +199,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
|
|||
RegionAllocConf_t alloc_conf;
|
||||
Tread(xid,rid,&alloc_conf);
|
||||
|
||||
logtree::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
|
||||
diskTreeComponent::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
|
||||
|
||||
//DEBUG("{%lld <- alloc region extend}\n", conf.regionList.page);
|
||||
// XXX get rid of Tset by storing next page in memory, and losing it
|
||||
|
@ -207,7 +207,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
|
|||
Tset(xid,rid,&alloc_conf);
|
||||
|
||||
|
||||
pagenum = logtree::findPage(xid, tree, currkey,keylen);
|
||||
pagenum = diskTreeComponent::findPage(xid, tree, currkey,keylen);
|
||||
oldpagenum = pagenum;
|
||||
printf("pagenum:%lld\n", (long long)pagenum);
|
||||
assert(pagenum == i + OFFSET);
|
||||
|
@ -229,7 +229,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
|
|||
memcpy(currkey, (byte*)(&i), keylen);
|
||||
|
||||
printf("\n#########\ni=%d\nkey:\t%d\nkeylen:%d\n",i,*((int32_t*)currkey),keylen);
|
||||
pageid_t pagenum = logtree::findPage(xid, tree, currkey, keylen);
|
||||
pageid_t pagenum = diskTreeComponent::findPage(xid, tree, currkey, keylen);
|
||||
printf("pagenum:%lld\n", (long long) pagenum);
|
||||
assert(pagenum == i + OFFSET);
|
||||
free(currkey);
|
||||
|
|
|
@ -24,7 +24,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
unlink("storefile.txt");
|
||||
unlink("logfile.txt");
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
//data generation
|
||||
std::vector<std::string> * data_arr = new std::vector<std::string>;
|
||||
|
@ -152,7 +152,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
|
||||
Tcommit(xid);
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
//data generation
|
||||
// std::vector<std::string> * data_arr = new std::vector<std::string>;
|
||||
|
@ -102,7 +102,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
//Tcommit(xid);
|
||||
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
sync();
|
||||
|
||||
logtree::init_stasis();
|
||||
diskTreeComponent::init_stasis();
|
||||
|
||||
double delete_freq = .05;
|
||||
double update_freq = .15;
|
||||
|
@ -256,7 +256,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
|
|||
|
||||
|
||||
Tcommit(xid);
|
||||
logtree::deinit_stasis();
|
||||
diskTreeComponent::deinit_stasis();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue