diskTreeComponent -> diskTreeComponent::internalNodes

git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@680 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
sears 2010-03-09 19:47:12 +00:00
parent 1f2f4c745b
commit 01c65d7a3c
16 changed files with 239 additions and 236 deletions

View file

@ -23,16 +23,16 @@
// LOGTREE implementation
/////////////////////////////////////////////////////////////////
const RegionAllocConf_t diskTreeComponent::REGION_ALLOC_STATIC_INITIALIZER = { {0,0,-1}, 0, -1, -1, 1000 };
const RegionAllocConf_t diskTreeComponent::internalNodes::REGION_ALLOC_STATIC_INITIALIZER = { {0,0,-1}, 0, -1, -1, 1000 };
//LSM_ROOT_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
const int64_t diskTreeComponent::internalNodes::DEPTH = 0; //in root this is the slot num where the DEPTH (of tree) is stored
const int64_t diskTreeComponent::internalNodes::COMPARATOR = 1; //in root this is the slot num where the COMPARATOR id is stored
const int64_t diskTreeComponent::internalNodes::FIRST_SLOT = 2; //this is the first unused slot in all index pages
const size_t diskTreeComponent::internalNodes::root_rec_size = sizeof(int64_t);
const int64_t diskTreeComponent::internalNodes::PREV_LEAF = 0; //pointer to prev leaf page
const int64_t diskTreeComponent::internalNodes::NEXT_LEAF = 1; //pointer to next leaf page
// XXX hack, and cut and pasted from datapage.cpp.
static lsn_t get_lsn(int xid) {
@ -45,7 +45,7 @@ static lsn_t get_lsn(int xid) {
// TODO move init_stasis to a more appropriate module
void diskTreeComponent::init_stasis() {
void diskTreeComponent::internalNodes::init_stasis() {
bufferManagerFileHandleType = BUFFER_MANAGER_FILE_HANDLE_PFILE;
@ -57,16 +57,16 @@ void diskTreeComponent::init_stasis() {
}
void diskTreeComponent::deinit_stasis() { Tdeinit(); }
void diskTreeComponent::internalNodes::deinit_stasis() { Tdeinit(); }
void diskTreeComponent::free_region_rid(int xid, recordid tree,
void diskTreeComponent::internalNodes::free_region_rid(int xid, recordid tree,
diskTreeComponent_page_deallocator_t dealloc, void *allocator_state) {
dealloc(xid,allocator_state);
// XXX fishy shouldn't caller do this?
Tdealloc(xid, *(recordid*)allocator_state);
}
void diskTreeComponent::dealloc_region_rid(int xid, recordid rid) {
void diskTreeComponent::internalNodes::dealloc_region_rid(int xid, recordid rid) {
RegionAllocConf_t a;
Tread(xid,rid,&a);
DEBUG("{%lld <- dealloc region arraylist}\n", a.regionList.page);
@ -82,7 +82,7 @@ void diskTreeComponent::dealloc_region_rid(int xid, recordid rid) {
}
void diskTreeComponent::force_region_rid(int xid, recordid rid) {
void diskTreeComponent::internalNodes::force_region_rid(int xid, recordid rid) {
RegionAllocConf_t a;
Tread(xid,rid,&a);
@ -100,7 +100,7 @@ void diskTreeComponent::force_region_rid(int xid, recordid rid) {
}
}
pageid_t diskTreeComponent::alloc_region(int xid, void *conf) {
pageid_t diskTreeComponent::internalNodes::alloc_region(int xid, void *conf) {
RegionAllocConf_t* a = (RegionAllocConf_t*)conf;
if(a->nextPage == a->endOfRegion) {
@ -133,7 +133,7 @@ pageid_t diskTreeComponent::alloc_region(int xid, void *conf) {
return ret;
}
pageid_t diskTreeComponent::alloc_region_rid(int xid, void * ridp) {
pageid_t diskTreeComponent::internalNodes::alloc_region_rid(int xid, void * ridp) {
recordid rid = *(recordid*)ridp;
RegionAllocConf_t conf;
Tread(xid,rid,&conf);
@ -144,7 +144,7 @@ pageid_t diskTreeComponent::alloc_region_rid(int xid, void * ridp) {
return ret;
}
pageid_t * diskTreeComponent::list_region_rid(int xid, void *ridp, pageid_t * region_len, pageid_t * region_count) {
pageid_t * diskTreeComponent::internalNodes::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);
@ -159,7 +159,7 @@ pageid_t * diskTreeComponent::list_region_rid(int xid, void *ridp, pageid_t * re
return ret;
}
recordid diskTreeComponent::create(int xid) {
recordid diskTreeComponent::internalNodes::create(int xid) {
tree_state = Talloc(xid,sizeof(RegionAllocConf_t));
@ -206,7 +206,7 @@ recordid diskTreeComponent::create(int xid) {
return ret;
}
void diskTreeComponent::writeNodeRecord(int xid, Page * p, recordid & rid,
void diskTreeComponent::internalNodes::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",
p->id, datatuple::key_to_str(key).c_str(), keylen, ptr);
@ -217,7 +217,7 @@ void diskTreeComponent::writeNodeRecord(int xid, Page * p, recordid & rid,
stasis_page_lsn_write(xid, p, get_lsn(xid));
}
void diskTreeComponent::initializeNodePage(int xid, Page *p) {
void diskTreeComponent::internalNodes::initializeNodePage(int xid, Page *p) {
stasis_page_slotted_initialize_page(p);
recordid reserved1 = stasis_record_alloc_begin(xid, p, sizeof(indexnode_rec));
stasis_record_alloc_done(xid, p, reserved1);
@ -226,7 +226,7 @@ void diskTreeComponent::initializeNodePage(int xid, Page *p) {
}
recordid diskTreeComponent::appendPage(int xid, recordid tree, pageid_t & rmLeafID,
recordid diskTreeComponent::internalNodes::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) {
@ -367,7 +367,7 @@ recordid diskTreeComponent::appendPage(int xid, recordid tree, pageid_t & rmLeaf
stasis_record_alloc_done(xid, lastLeaf, ret);
diskTreeComponent::writeNodeRecord(xid, lastLeaf, ret, key, keySize, val_page);
writeNodeRecord(xid, lastLeaf, ret, key, keySize, val_page);
if(lastLeaf->id != p->id) {
assert(rmLeafID != tree.page);
@ -398,7 +398,7 @@ recordid diskTreeComponent::appendPage(int xid, recordid tree, pageid_t & rmLeaf
*/
recordid diskTreeComponent::appendInternalNode(int xid, Page *p,
recordid diskTreeComponent::internalNodes::appendInternalNode(int xid, Page *p,
int64_t depth,
const byte *key, size_t key_len,
pageid_t val_page, pageid_t lastLeaf,
@ -463,7 +463,7 @@ recordid diskTreeComponent::appendInternalNode(int xid, Page *p,
return ret;
}
recordid diskTreeComponent::buildPathToLeaf(int xid, recordid root, Page *root_p,
recordid diskTreeComponent::internalNodes::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,
diskTreeComponent_page_allocator_t allocator,
@ -544,7 +544,7 @@ recordid diskTreeComponent::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 diskTreeComponent::findLastLeaf(int xid, Page *root, int64_t depth) {
pageid_t diskTreeComponent::internalNodes::findLastLeaf(int xid, Page *root, int64_t depth) {
if(!depth) {
DEBUG("Found last leaf = %lld\n", root->id);
return root->id;
@ -568,7 +568,7 @@ pageid_t diskTreeComponent::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 diskTreeComponent::findFirstLeaf(int xid, Page *root, int64_t depth) {
pageid_t diskTreeComponent::internalNodes::findFirstLeaf(int xid, Page *root, int64_t depth) {
if(!depth) { //if depth is 0, then returns the id of the page
return root->id;
@ -586,7 +586,7 @@ pageid_t diskTreeComponent::findFirstLeaf(int xid, Page *root, int64_t depth) {
}
pageid_t diskTreeComponent::findPage(int xid, recordid tree, const byte *key, size_t keySize) {
pageid_t diskTreeComponent::internalNodes::findPage(int xid, recordid tree, const byte *key, size_t keySize) {
Page *p = loadPage(xid, tree.page);
readlock(p->rwlatch,0);
@ -605,7 +605,7 @@ pageid_t diskTreeComponent::findPage(int xid, recordid tree, const byte *key, si
}
pageid_t diskTreeComponent::lookupLeafPageFromRid(int xid, recordid rid) {
pageid_t diskTreeComponent::internalNodes::lookupLeafPageFromRid(int xid, recordid rid) {
pageid_t pid = -1;
if(rid.page != NULLRID.page || rid.slot != NULLRID.slot) {
@ -620,7 +620,7 @@ pageid_t diskTreeComponent::lookupLeafPageFromRid(int xid, recordid rid) {
return pid;
}
recordid diskTreeComponent::lookup(int xid,
recordid diskTreeComponent::internalNodes::lookup(int xid,
Page *node,
int64_t depth,
const byte *key, size_t keySize ) {
@ -672,7 +672,7 @@ recordid diskTreeComponent::lookup(int xid,
}
}
void diskTreeComponent::print_tree(int xid) {
void diskTreeComponent::internalNodes::print_tree(int xid) {
Page *p = loadPage(xid, root_rec.page);
readlock(p->rwlatch,0);
recordid depth_rid = {p->id, DEPTH, 0};
@ -688,7 +688,7 @@ void diskTreeComponent::print_tree(int xid) {
}
void diskTreeComponent::print_tree(int xid, pageid_t pid, int64_t depth) {
void diskTreeComponent::internalNodes::print_tree(int xid, pageid_t pid, int64_t depth) {
Page *node = loadPage(xid, pid);
readlock(node->rwlatch,0);
@ -748,20 +748,20 @@ void diskTreeComponent::print_tree(int xid, pageid_t pid, int64_t depth) {
//diskTreeComponentIterator implementation
/////////////////////////////////////////////////
diskTreeComponent::iterator::iterator(int xid, recordid root) {
diskTreeComponent::internalNodes::iterator::iterator(int xid, recordid root) {
if(root.page == 0 && root.slot == 0 && root.size == -1) abort();
p = loadPage(xid,root.page);
readlock(p->rwlatch,0);
DEBUG("ROOT_REC_SIZE %d\n", diskTreeComponent::root_rec_size);
recordid rid = {p->id, diskTreeComponent::DEPTH, diskTreeComponent::root_rec_size};
DEBUG("ROOT_REC_SIZE %d\n", diskTreeComponent::internalNodes::root_rec_size);
recordid rid = {p->id, diskTreeComponent::internalNodes::DEPTH, diskTreeComponent::internalNodes::root_rec_size};
const indexnode_rec* nr = (const indexnode_rec*)stasis_record_read_begin(xid,p, rid);
int64_t depth = nr->ptr;
DEBUG("DEPTH = %lld\n", depth);
stasis_record_read_done(xid,p,rid,(const byte*)nr);
pageid_t leafid = diskTreeComponent::findFirstLeaf(xid, p, depth);
pageid_t leafid = diskTreeComponent::internalNodes::findFirstLeaf(xid, p, depth);
if(leafid != root.page) {
unlock(p->rwlatch);
@ -776,7 +776,7 @@ diskTreeComponent::iterator::iterator(int xid, recordid root) {
{
// Position just before the first slot.
// The first call to next() will increment us to the first slot, or return NULL.
recordid rid = { p->id, diskTreeComponent::FIRST_SLOT-1, 0};
recordid rid = { p->id, diskTreeComponent::internalNodes::FIRST_SLOT-1, 0};
current = rid;
}
@ -787,18 +787,18 @@ diskTreeComponent::iterator::iterator(int xid, recordid root) {
justOnePage = (depth == 0);
}
diskTreeComponent::iterator::iterator(int xid, recordid root, const byte* key, len_t keylen) {
diskTreeComponent::internalNodes::iterator::iterator(int xid, recordid root, const byte* key, len_t keylen) {
if(root.page == NULLRID.page && root.slot == NULLRID.slot) abort();
p = loadPage(xid,root.page);
readlock(p->rwlatch,0);
recordid rid = {p->id, diskTreeComponent::DEPTH, diskTreeComponent::root_rec_size};
recordid rid = {p->id, diskTreeComponent::internalNodes::DEPTH, diskTreeComponent::internalNodes::root_rec_size};
const indexnode_rec *nr = (const indexnode_rec*)stasis_record_read_begin(xid,p,rid);
int64_t depth = nr->ptr;
stasis_record_read_done(xid,p,rid,(const byte*)nr);
recordid lsm_entry_rid = diskTreeComponent::lookup(xid,p,depth,key,keylen);
recordid lsm_entry_rid = diskTreeComponent::internalNodes::lookup(xid,p,depth,key,keylen);
if(lsm_entry_rid.page == NULLRID.page && lsm_entry_rid.slot == NULLRID.slot) {
unlock(p->rwlatch);
@ -833,7 +833,7 @@ diskTreeComponent::iterator::iterator(int xid, recordid root, const byte* key, l
/**
* move to the next page
**/
int diskTreeComponent::iterator::next()
int diskTreeComponent::internalNodes::iterator::next()
{
if(done) return 0;
@ -841,7 +841,7 @@ int diskTreeComponent::iterator::next()
if(current.size == INVALID_SLOT) {
recordid next_leaf_rid = {p->id, diskTreeComponent::NEXT_LEAF,0};
recordid next_leaf_rid = {p->id, diskTreeComponent::internalNodes::NEXT_LEAF,0};
const indexnode_rec *nr = (const indexnode_rec*)stasis_record_read_begin(xid_, p, next_leaf_rid);
pageid_t next_rec = nr->ptr;
stasis_record_read_done(xid_,p,next_leaf_rid,(const byte*)nr);
@ -881,7 +881,7 @@ int diskTreeComponent::iterator::next()
}
}
void diskTreeComponent::iterator::close() {
void diskTreeComponent::internalNodes::iterator::close() {
if(p) {
unlock(p->rwlatch);

View file

@ -39,23 +39,25 @@ struct indexnode_rec {
typedef pageid_t(*diskTreeComponent_page_allocator_t)(int, void *);
typedef void(*diskTreeComponent_page_deallocator_t)(int, void *);
class diskTreeComponent{
class diskTreeComponent {
public:
diskTreeComponent(int xid): region_alloc(new DataPage<datatuple>::RegionAllocator(xid, 10000)) {create(xid);} // XXX shouldn't hardcode region size.
diskTreeComponent(int xid, recordid root, recordid state, recordid dp_state)
class internalNodes{
public:
internalNodes(int xid): region_alloc(new DataPage<datatuple>::RegionAllocator(xid, 10000)) {create(xid);} // XXX shouldn't hardcode region size.
internalNodes(int xid, recordid root, recordid state, recordid dp_state)
: tree_state(state),
root_rec(root),
region_alloc(new DataPage<datatuple>::RegionAllocator(xid, dp_state)) { lastLeaf = -1; }
private:
private:
recordid create(int xid);
public:
public:
void print_tree(int xid);
static void init_stasis();
static void deinit_stasis();
private:
private:
static pageid_t alloc_region(int xid, void *conf);
public:
public:
static pageid_t alloc_region_rid(int xid, void * ridp);
static void force_region_rid(int xid, recordid rid);
static pageid_t*list_region_rid(int xid, void * ridp,
@ -114,7 +116,7 @@ public:
recordid &get_tree_state(){return tree_state;}
recordid &get_root_rec(){return root_rec;}
public:
public:
const static RegionAllocConf_t REGION_ALLOC_STATIC_INITIALIZER;
const static int64_t DEPTH;
@ -125,7 +127,7 @@ public:
const static int64_t NEXT_LEAF;
pageid_t lastLeaf;
private:
private:
void print_tree(int xid, pageid_t pid, int64_t depth);
@ -134,7 +136,7 @@ private:
DataPage<datatuple>::RegionAllocator* region_alloc;
public:
public:
class iterator {
public:
iterator(int xid, recordid root);
@ -165,5 +167,6 @@ public:
int justOnePage;
};
};
};
#endif /* DISKTREECOMPONENT_H_ */

View file

@ -12,9 +12,9 @@ void diskTreeIterator<TUPLE>::init_iterators(TUPLE * key1, TUPLE * key2) {
lsmIterator_ = NULL;
} else {
if(key1) {
lsmIterator_ = new diskTreeComponent::iterator(-1, tree_, key1->key(), key1->keylen());
lsmIterator_ = new diskTreeComponent::internalNodes::iterator(-1, tree_, key1->key(), key1->keylen());
} else {
lsmIterator_ = new diskTreeComponent::iterator(-1, tree_);
lsmIterator_ = new diskTreeComponent::internalNodes::iterator(-1, tree_);
}
}
}
@ -37,7 +37,7 @@ diskTreeIterator<TUPLE>::diskTreeIterator(recordid tree, TUPLE& key) :
}
template <class TUPLE>
diskTreeIterator<TUPLE>::diskTreeIterator(diskTreeComponent *tree) :
diskTreeIterator<TUPLE>::diskTreeIterator(diskTreeComponent::internalNodes *tree) :
tree_(tree ? tree->get_root_rec() : NULLRID)
{
init_iterators(NULL, NULL);
@ -45,7 +45,7 @@ diskTreeIterator<TUPLE>::diskTreeIterator(diskTreeComponent *tree) :
}
template <class TUPLE>
diskTreeIterator<TUPLE>::diskTreeIterator(diskTreeComponent *tree, TUPLE& key) :
diskTreeIterator<TUPLE>::diskTreeIterator(diskTreeComponent::internalNodes *tree, TUPLE& key) :
tree_(tree ? tree->get_root_rec() : NULLRID)
{
init_iterators(&key,NULL);

View file

@ -15,9 +15,9 @@ public:
explicit diskTreeIterator(recordid tree,TUPLE &key);
explicit diskTreeIterator(diskTreeComponent *tree);
explicit diskTreeIterator(diskTreeComponent::internalNodes *tree);
explicit diskTreeIterator(diskTreeComponent *tree,TUPLE &key);
explicit diskTreeIterator(diskTreeComponent::internalNodes *tree,TUPLE &key);
~diskTreeIterator();
@ -34,7 +34,7 @@ private:
private:
recordid tree_; //root of the tree
diskTreeComponent::iterator* lsmIterator_;
diskTreeComponent::internalNodes::iterator* lsmIterator_;
pageid_t curr_pageid; //current page id
DataPage<TUPLE> *curr_page; //current page

View file

@ -527,16 +527,16 @@ int op_stat_space_usage(pthread_data* data) {
pageid_t * datapage_c2_regions = data->ltable->get_tree_c2()->get_alloc()->list_regions(xid, &datapage_c2_region_length, &datapage_c2_region_count);
recordid tree_c1_region_header = data->ltable->get_tree_c1()->get_tree_state();
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_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c1_region_header, &tree_c1_region_length, &tree_c1_region_count);
pageid_t * tree_c1_mergeable_regions = NULL;
if(data->ltable->get_tree_c1_mergeable()) {
recordid tree_c1_mergeable_region_header = data->ltable->get_tree_c1_mergeable()->get_tree_state();
tree_c1_mergeable_regions = diskTreeComponent::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
tree_c1_mergeable_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
}
recordid tree_c2_region_header = data->ltable->get_tree_c2()->get_tree_state();
pageid_t * tree_c2_regions = diskTreeComponent::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
pageid_t * tree_c2_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
free(datapage_c1_regions);
free(datapage_c1_mergeable_regions);
@ -595,7 +595,7 @@ int op_stat_histogram(pthread_data* data, size_t limit) {
}
int xid = Tbegin();
diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid, data->ltable->get_tree_c2()->get_root_rec());
diskTreeComponent::internalNodes::iterator * it = new diskTreeComponent::internalNodes::iterator(xid, data->ltable->get_tree_c2()->get_root_rec());
size_t count = 0;
int err = 0;
@ -621,7 +621,7 @@ int op_stat_histogram(pthread_data* data, size_t limit) {
size_t cur_stride = 0;
size_t i = 0;
it = new diskTreeComponent::iterator(xid, data->ltable->get_tree_c2()->get_root_rec());
it = new diskTreeComponent::internalNodes::iterator(xid, data->ltable->get_tree_c2()->get_root_rec());
while(it->next()) {
i++;
if(i == count || !cur_stride) { // do we want to send this key? (this matches the first, last and interior keys)
@ -665,13 +665,13 @@ int op_dbg_blockmap(pthread_data* data) {
recordid tree_c1_region_header = data->ltable->get_tree_c1()->get_tree_state();
recordid tree_c2_region_header = data->ltable->get_tree_c2()->get_tree_state();
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_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c1_region_header, &tree_c1_region_length, &tree_c1_region_count);
pageid_t * tree_c1_mergeable_regions = NULL;
if(data->ltable->get_tree_c1_mergeable()) {
recordid tree_c1_mergeable_region_header = data->ltable->get_tree_c1_mergeable()->get_tree_state();
tree_c1_mergeable_regions = diskTreeComponent::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
tree_c1_mergeable_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c1_mergeable_region_header, &tree_c1_mergeable_region_length, &tree_c1_mergeable_region_count);
}
pageid_t * tree_c2_regions = diskTreeComponent::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
pageid_t * tree_c2_regions = diskTreeComponent::internalNodes::list_region_rid(xid, &tree_c2_region_header, &tree_c2_region_length, &tree_c2_region_count);
unlock(data->ltable->header_lock);
Tcommit(xid);

View file

@ -71,10 +71,10 @@ recordid logtable::allocTable(int xid)
table_rec = Talloc(xid, sizeof(tbl_header));
//create the big tree
tree_c2 = new diskTreeComponent(xid);
tree_c2 = new diskTreeComponent::internalNodes(xid);
//create the small tree
tree_c1 = new diskTreeComponent(xid);
tree_c1 = new diskTreeComponent::internalNodes(xid);
update_persistent_header(xid);
@ -83,8 +83,8 @@ recordid logtable::allocTable(int xid)
void logtable::openTable(int xid, recordid rid) {
table_rec = rid;
Tread(xid, table_rec, &tbl_header);
tree_c2 = new diskTreeComponent(xid, tbl_header.c2_root, tbl_header.c2_state, tbl_header.c2_dp_state);
tree_c1 = new diskTreeComponent(xid, tbl_header.c1_root, tbl_header.c1_state, tbl_header.c1_dp_state);
tree_c2 = new diskTreeComponent::internalNodes(xid, tbl_header.c2_root, tbl_header.c2_state, tbl_header.c2_dp_state);
tree_c1 = new diskTreeComponent::internalNodes(xid, tbl_header.c1_root, tbl_header.c1_state, tbl_header.c1_dp_state);
}
void logtable::update_persistent_header(int xid) {
@ -445,7 +445,7 @@ void logtable::insertTuple(datatuple *tuple)
}
DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, diskTreeComponent *ltree)
DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, diskTreeComponent::internalNodes *ltree)
{
//create a new data page -- either the last region is full, or the last data page doesn't want our tuple. (or both)
@ -470,7 +470,7 @@ DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, diskTreeCo
RegionAllocConf_t alloc_conf;
//insert the record key and id of the first page of the datapage to the diskTreeComponent
Tread(xid,ltree->get_tree_state(), &alloc_conf);
diskTreeComponent::appendPage(xid, ltree->get_root_rec(), ltree->lastLeaf,
diskTreeComponent::internalNodes::appendPage(xid, ltree->get_root_rec(), ltree->lastLeaf,
tuple->key(),
tuple->keylen(),
ltree->alloc_region,
@ -484,7 +484,7 @@ DataPage<datatuple>* logtable::insertTuple(int xid, datatuple *tuple, diskTreeCo
return dp;
}
datatuple * logtable::findTuple(int xid, datatuple::key_t key, size_t keySize, diskTreeComponent *ltree)
datatuple * logtable::findTuple(int xid, datatuple::key_t key, size_t keySize, diskTreeComponent::internalNodes *ltree)
{
datatuple * tup=0;

View file

@ -61,9 +61,9 @@ public:
void openTable(int xid, recordid rid);
void flushTable();
DataPage<datatuple>* insertTuple(int xid, datatuple *tuple,diskTreeComponent *ltree);
DataPage<datatuple>* insertTuple(int xid, datatuple *tuple,diskTreeComponent::internalNodes *ltree);
datatuple * findTuple(int xid, const datatuple::key_t key, size_t keySize, diskTreeComponent *ltree);
datatuple * findTuple(int xid, const datatuple::key_t key, size_t keySize, diskTreeComponent::internalNodes *ltree);
inline recordid & get_table_rec(){return table_rec;} // TODO This is called by merger.cpp for no good reason. (remove the calls)
@ -73,13 +73,13 @@ public:
void forgetIterator(logtableIterator<datatuple> * it);
void bump_epoch() ;
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 diskTreeComponent::internalNodes * get_tree_c2(){return tree_c2;}
inline diskTreeComponent::internalNodes * get_tree_c1(){return tree_c1;}
inline diskTreeComponent::internalNodes * get_tree_c1_mergeable(){return tree_c1_mergeable;}
inline void set_tree_c1(diskTreeComponent *t){tree_c1=t; bump_epoch(); }
inline void set_tree_c1_mergeable(diskTreeComponent *t){tree_c1_mergeable=t; bump_epoch(); }
inline void set_tree_c2(diskTreeComponent *t){tree_c2=t; bump_epoch(); }
inline void set_tree_c1(diskTreeComponent::internalNodes *t){tree_c1=t; bump_epoch(); }
inline void set_tree_c1_mergeable(diskTreeComponent::internalNodes *t){tree_c1_mergeable=t; bump_epoch(); }
inline void set_tree_c2(diskTreeComponent::internalNodes *t){tree_c2=t; bump_epoch(); }
inline memTreeComponent<datatuple>::rbtree_ptr_t get_tree_c0(){return tree_c0;}
inline memTreeComponent<datatuple>::rbtree_ptr_t get_tree_c0_mergeable(){return tree_c0_mergeable;}
@ -124,9 +124,9 @@ private:
recordid table_rec;
struct table_header tbl_header;
uint64_t epoch;
diskTreeComponent *tree_c2; //big tree
diskTreeComponent *tree_c1; //small tree
diskTreeComponent *tree_c1_mergeable; //small tree: ready to be merged with c2
diskTreeComponent::internalNodes *tree_c2; //big tree
diskTreeComponent::internalNodes *tree_c1; //small tree
diskTreeComponent::internalNodes *tree_c1_mergeable; //small tree: ready to be merged with c2
memTreeComponent<datatuple>::rbtree_ptr_t tree_c0; // in-mem red black tree
memTreeComponent<datatuple>::rbtree_ptr_t tree_c0_mergeable; // in-mem red black tree: ready to be merged with c1.

View file

@ -64,7 +64,7 @@ double merge_stats_nsec_to_merge_in_bytes(merge_stats_t); // how many nsec did w
inline DataPage<datatuple>*
insertTuple(int xid, DataPage<datatuple> *dp, datatuple *t,
logtable *ltable,
diskTreeComponent * ltree, merge_stats_t*);
diskTreeComponent::internalNodes * ltree, merge_stats_t*);
int merge_scheduler::addlogtable(logtable *ltable)
{
@ -245,7 +245,7 @@ void merge_iterators(int xid,
ITA *itrA,
ITB *itrB,
logtable *ltable,
diskTreeComponent *scratch_tree,
diskTreeComponent::internalNodes *scratch_tree,
merge_stats_t *stats,
bool dropDeletes);
@ -340,7 +340,7 @@ void* memMergeThread(void*arg)
//create a new tree
diskTreeComponent * c1_prime = new diskTreeComponent(xid); // XXX should not hardcode region size)
diskTreeComponent::internalNodes * c1_prime = new diskTreeComponent::internalNodes(xid); // XXX should not hardcode region size)
//pthread_mutex_unlock(a->block_ready_mut);
unlock(ltable->header_lock);
@ -356,7 +356,7 @@ void* memMergeThread(void*arg)
// 5: force c1'
//force write the new region to disk
diskTreeComponent::force_region_rid(xid, c1_prime->get_tree_state());
diskTreeComponent::internalNodes::force_region_rid(xid, c1_prime->get_tree_state());
//force write the new datapages
c1_prime->get_alloc()->force_regions(xid);
@ -391,7 +391,7 @@ void* memMergeThread(void*arg)
}
// 12: delete old c1
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c1()->get_tree_state());
diskTreeComponent::internalNodes::dealloc_region_rid(xid, ltable->get_tree_c1()->get_tree_state());
ltable->get_tree_c1()->get_alloc()->dealloc_regions(xid);
delete ltable->get_tree_c1();
@ -406,7 +406,7 @@ void* memMergeThread(void*arg)
ltable->set_tree_c1_mergeable(c1_prime);
// 8: c1 = new empty.
ltable->set_tree_c1(new diskTreeComponent(xid));
ltable->set_tree_c1(new diskTreeComponent::internalNodes(xid));
pthread_cond_signal(a->out_block_ready_cond);
@ -497,7 +497,7 @@ void *diskMergeThread(void*arg)
//create a new tree
//TODO: maybe you want larger regions for the second tree?
diskTreeComponent * c2_prime = new diskTreeComponent(xid);
diskTreeComponent::internalNodes * c2_prime = new diskTreeComponent::internalNodes(xid);
unlock(ltable->header_lock);
@ -510,18 +510,18 @@ void *diskMergeThread(void*arg)
delete itrB;
//5: force write the new region to disk
diskTreeComponent::force_region_rid(xid, c2_prime->get_tree_state());
diskTreeComponent::internalNodes::force_region_rid(xid, c2_prime->get_tree_state());
c2_prime->get_alloc()->force_regions(xid);
// (skip 6, 7, 8, 8.5, 9))
writelock(ltable->header_lock,0);
//12
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c2()->get_tree_state());
diskTreeComponent::internalNodes::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();
//11.5
diskTreeComponent::dealloc_region_rid(xid, ltable->get_tree_c1_mergeable()->get_tree_state());
diskTreeComponent::internalNodes::dealloc_region_rid(xid, ltable->get_tree_c1_mergeable()->get_tree_state());
ltable->get_tree_c1_mergeable()->get_alloc()->dealloc_regions(xid);
//11
delete ltable->get_tree_c1_mergeable();
@ -560,7 +560,7 @@ void merge_iterators(int xid,
ITA *itrA, //iterator on c1 or c2
ITB *itrB, //iterator on c0 or c1, respectively
logtable *ltable,
diskTreeComponent *scratch_tree, merge_stats_t *stats,
diskTreeComponent::internalNodes *scratch_tree, merge_stats_t *stats,
bool dropDeletes // should be true iff this is biggest component
)
{
@ -654,7 +654,7 @@ void merge_iterators(int xid,
inline DataPage<datatuple>*
insertTuple(int xid, DataPage<datatuple> *dp, datatuple *t,
logtable *ltable,
diskTreeComponent * ltree, merge_stats_t * stats)
diskTreeComponent::internalNodes * ltree, merge_stats_t * stats)
{
if(dp==0)
{

View file

@ -37,7 +37,7 @@ void terminate (int param)
printf("Deinitializing stasis...\n");
fflush(stdout);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
exit(0);
}
@ -50,7 +50,7 @@ void initialize_server()
prev_fn = signal (SIGINT,terminate);
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
int xid = Tbegin();

View file

@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::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, &diskTreeComponent::REGION_ALLOC_STATIC_INITIALIZER);
Tset(xid,alloc_state, &diskTreeComponent::internalNodes::REGION_ALLOC_STATIC_INITIALIZER);
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES);
@ -119,7 +119,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}

View file

@ -9,7 +9,7 @@ int main(int argc, char **argv)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
int xid = Tbegin();
@ -24,12 +24,12 @@ int main(int argc, char **argv)
// lsmTableHandle<PAGELAYOUT>* h = TlsmTableStart<PAGELAYOUT>(lsmTable, INVALID_COL);
xid = Tbegin();
diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid,ltable.get_tree_c2()->get_root_rec() );
diskTreeComponent::internalNodes::iterator * it = new diskTreeComponent::internalNodes::iterator(xid,ltable.get_tree_c2()->get_root_rec() );
it->close();
delete it;
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();

View file

@ -28,7 +28,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
int xid = Tbegin();
@ -41,7 +41,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
Tcommit(xid);
xid = Tbegin();
diskTreeComponent *ltable_c1 = ltable.get_tree_c1();
diskTreeComponent::internalNodes *ltable_c1 = ltable.get_tree_c1();
recordid tree_root = ltable_c1->get_root_rec();
@ -153,7 +153,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
printf("Random Reads completed.\n");
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}
/** @test

View file

@ -32,7 +32,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
int xid = Tbegin();
@ -43,7 +43,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
Tcommit(xid);
xid = Tbegin();
diskTreeComponent *lt = ltable.get_tree_c1();
diskTreeComponent::internalNodes *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 = diskTreeComponent::findPage(xid, tree, currkey, keylen);
long pagenum = diskTreeComponent::internalNodes::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);
diskTreeComponent::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
diskTreeComponent::internalNodes::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 = diskTreeComponent::findPage(xid, tree, currkey,keylen);
pagenum = diskTreeComponent::internalNodes::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 = diskTreeComponent::findPage(xid, tree, currkey, keylen);
long pagenum = diskTreeComponent::internalNodes::findPage(xid, tree, currkey, keylen);
//printf("pagenum:%d\n", pagenum);
assert(pagenum == i + OFFSET);
free(currkey);
@ -129,7 +129,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
int64_t count = 0;
diskTreeComponent::iterator * it = new diskTreeComponent::iterator(xid, tree);
diskTreeComponent::internalNodes::iterator * it = new diskTreeComponent::internalNodes::iterator(xid, tree);
while(it->next()) {
byte * key;
@ -150,7 +150,7 @@ void insertProbeIter_str(int NUM_ENTRIES)
delete it;
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}
@ -177,7 +177,7 @@ void insertProbeIter_int(int NUM_ENTRIES)
Tcommit(xid);
xid = Tbegin();
diskTreeComponent *lt = ltable.get_tree_c1();
diskTreeComponent::internalNodes *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 = diskTreeComponent::findPage(xid, tree, currkey, keylen);
pageid_t pagenum = diskTreeComponent::internalNodes::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);
diskTreeComponent::appendPage(xid, tree, lt->lastLeaf, currkey, keylen, lt->alloc_region, &alloc_conf, i + OFFSET);
diskTreeComponent::internalNodes::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 = diskTreeComponent::findPage(xid, tree, currkey,keylen);
pagenum = diskTreeComponent::internalNodes::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 = diskTreeComponent::findPage(xid, tree, currkey, keylen);
pageid_t pagenum = diskTreeComponent::internalNodes::findPage(xid, tree, currkey, keylen);
printf("pagenum:%lld\n", (long long) pagenum);
assert(pagenum == i + OFFSET);
free(currkey);

View file

@ -24,7 +24,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
unlink("storefile.txt");
unlink("logfile.txt");
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
//data generation
std::vector<std::string> * data_arr = new std::vector<std::string>;
@ -150,7 +150,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}

View file

@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::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);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}

View file

@ -26,7 +26,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
sync();
diskTreeComponent::init_stasis();
diskTreeComponent::internalNodes::init_stasis();
double delete_freq = .05;
double update_freq = .15;
@ -254,7 +254,7 @@ void insertProbeIter(size_t NUM_ENTRIES)
Tcommit(xid);
diskTreeComponent::deinit_stasis();
diskTreeComponent::internalNodes::deinit_stasis();
}