Commit d1569489 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Get rid of childkeylens. Addresses #126.

git-svn-id: file:///svn/tokudb@964 c7de825b-a66e-492c-adef-691d508d4ae1
parent 814b68e8
...@@ -73,7 +73,7 @@ struct brtnode { ...@@ -73,7 +73,7 @@ struct brtnode {
Note: It is possible that Child 1's keys are == to child 0's key's, so it is Note: It is possible that Child 1's keys are == to child 0's key's, so it is
not necessarily true that child 1's keys are > childkeys[0]. not necessarily true that child 1's keys are > childkeys[0].
However, in the absense of duplicate keys, child 1's keys *are* > childkeys[0]. */ However, in the absense of duplicate keys, child 1's keys *are* > childkeys[0]. */
unsigned int childkeylens[TREE_FANOUT]; // unsigned int childkeylens[TREE_FANOUT];
unsigned char pivotflags[TREE_FANOUT]; unsigned char pivotflags[TREE_FANOUT];
DISKOFF children[TREE_FANOUT+1]; /* unused if height==0 */ /* Note: The last element of these arrays is used only temporarily while splitting a node. */ DISKOFF children[TREE_FANOUT+1]; /* unused if height==0 */ /* Note: The last element of these arrays is used only temporarily while splitting a node. */
HASHTABLE htables[TREE_FANOUT+1]; HASHTABLE htables[TREE_FANOUT+1];
......
...@@ -33,7 +33,6 @@ static void test_serialize(void) { ...@@ -33,7 +33,6 @@ static void test_serialize(void) {
sn.u.n.n_children = 2; sn.u.n.n_children = 2;
hello_string = toku_strdup("hello"); hello_string = toku_strdup("hello");
sn.u.n.childkeys[0] = kv_pair_malloc(hello_string, 6, 0, 0); sn.u.n.childkeys[0] = kv_pair_malloc(hello_string, 6, 0, 0);
sn.u.n.childkeylens[0] = 6;
sn.u.n.totalchildkeylens = 6; sn.u.n.totalchildkeylens = 6;
sn.u.n.pivotflags[0] = 42; sn.u.n.pivotflags[0] = 42;
sn.u.n.children[0] = sn.nodesize*30; sn.u.n.children[0] = sn.nodesize*30;
......
...@@ -281,7 +281,6 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl ...@@ -281,7 +281,6 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
for (i=0; i<TREE_FANOUT; i++) { for (i=0; i<TREE_FANOUT; i++) {
result->u.n.child_subtree_fingerprints[i]=0; result->u.n.child_subtree_fingerprints[i]=0;
result->u.n.childkeys[i]=0; result->u.n.childkeys[i]=0;
result->u.n.childkeylens[i]=0;
} }
for (i=0; i<TREE_FANOUT+1; i++) { for (i=0; i<TREE_FANOUT+1; i++) {
result->u.n.children[i]=0; result->u.n.children[i]=0;
...@@ -307,12 +306,12 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl ...@@ -307,12 +306,12 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
unsigned int keylen, datalen; unsigned int keylen, datalen;
rbuf_bytes(&rc, &keyptr, &keylen); rbuf_bytes(&rc, &keyptr, &keylen);
rbuf_bytes(&rc, &dataptr, &datalen); rbuf_bytes(&rc, &dataptr, &datalen);
result->u.n.childkeylens[i] = keylen + datalen;
result->u.n.childkeys[i] = kv_pair_malloc(keyptr, keylen, dataptr, datalen); result->u.n.childkeys[i] = kv_pair_malloc(keyptr, keylen, dataptr, datalen);
} else { } else {
bytevec childkeyptr; bytevec childkeyptr;
rbuf_bytes(&rc, &childkeyptr, &result->u.n.childkeylens[i]); /* Returns a pointer into the rbuf. */ unsigned int cklen;
result->u.n.childkeys[i] = kv_pair_malloc((void*)childkeyptr, result->u.n.childkeylens[i], 0, 0); rbuf_bytes(&rc, &childkeyptr, &cklen); /* Returns a pointer into the rbuf. */
result->u.n.childkeys[i] = kv_pair_malloc((void*)childkeyptr, cklen, 0, 0);
} }
//printf(" key %d length=%d data=%s\n", i, result->childkeylens[i], result->childkeys[i]); //printf(" key %d length=%d data=%s\n", i, result->childkeylens[i], result->childkeys[i]);
result->u.n.totalchildkeylens+=toku_brtnode_pivot_key_len(result, result->u.n.childkeys[i]); result->u.n.totalchildkeylens+=toku_brtnode_pivot_key_len(result, result->u.n.childkeys[i]);
......
...@@ -478,27 +478,22 @@ static void brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nod ...@@ -478,27 +478,22 @@ static void brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nod
} }
for (i=0; i<n_children_in_a-1; i++) { for (i=0; i<n_children_in_a-1; i++) {
A->u.n.childkeys[i] = node->u.n.childkeys[i]; A->u.n.childkeys[i] = node->u.n.childkeys[i];
A->u.n.childkeylens[i] = node->u.n.childkeylens[i];
A->u.n.pivotflags[i] = node->u.n.pivotflags[i]; A->u.n.pivotflags[i] = node->u.n.pivotflags[i];
A->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[i]); A->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[i]);
node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[i]); node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[i]);
node->u.n.childkeys[i] = 0; node->u.n.childkeys[i] = 0;
node->u.n.childkeylens[i] = 0;
} }
splitk->data = (void*)(node->u.n.childkeys[n_children_in_a-1]); splitk->data = (void*)(node->u.n.childkeys[n_children_in_a-1]);
splitk->size = toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]); splitk->size = toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]);
splitk->flags = node->u.n.pivotflags[n_children_in_a-1]; splitk->flags = node->u.n.pivotflags[n_children_in_a-1];
node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]); node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[n_children_in_a-1]);
node->u.n.childkeys[n_children_in_a-1]=0; node->u.n.childkeys[n_children_in_a-1]=0;
node->u.n.childkeylens[n_children_in_a-1]=0;
for (i=n_children_in_a; i<node->u.n.n_children-1; i++) { for (i=n_children_in_a; i<node->u.n.n_children-1; i++) {
B->u.n.childkeys[i-n_children_in_a] = node->u.n.childkeys[i]; B->u.n.childkeys[i-n_children_in_a] = node->u.n.childkeys[i];
B->u.n.childkeylens[i-n_children_in_a] = node->u.n.childkeylens[i];
B->u.n.pivotflags[i-n_children_in_a] = node->u.n.pivotflags[i]; B->u.n.pivotflags[i-n_children_in_a] = node->u.n.pivotflags[i];
B->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[i]); B->u.n.totalchildkeylens += toku_brt_pivot_key_len(t, node->u.n.childkeys[i]);
node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[i]); node->u.n.totalchildkeylens -= toku_brt_pivot_key_len(t, node->u.n.childkeys[i]);
node->u.n.childkeys[i] = 0; node->u.n.childkeys[i] = 0;
node->u.n.childkeylens[i] = 0;
} }
assert(node->u.n.totalchildkeylens==0); assert(node->u.n.totalchildkeylens==0);
...@@ -695,11 +690,9 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum, ...@@ -695,11 +690,9 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum,
// Slide the keys over // Slide the keys over
for (cnum=node->u.n.n_children-1; cnum>childnum; cnum--) { for (cnum=node->u.n.n_children-1; cnum>childnum; cnum--) {
node->u.n.childkeys[cnum] = node->u.n.childkeys[cnum-1]; node->u.n.childkeys[cnum] = node->u.n.childkeys[cnum-1];
node->u.n.childkeylens[cnum] = node->u.n.childkeylens[cnum-1];
node->u.n.pivotflags[cnum] = node->u.n.pivotflags[cnum-1]; node->u.n.pivotflags[cnum] = node->u.n.pivotflags[cnum-1];
} }
node->u.n.childkeys[childnum]= (void*)childsplitk->data; node->u.n.childkeys[childnum]= (void*)childsplitk->data;
node->u.n.childkeylens[childnum]= childsplitk->size;
node->u.n.pivotflags[childnum] = childsplitk->flags; node->u.n.pivotflags[childnum] = childsplitk->flags;
node->u.n.totalchildkeylens += childsplitk->size; node->u.n.totalchildkeylens += childsplitk->size;
node->u.n.n_children++; node->u.n.n_children++;
...@@ -1768,7 +1761,6 @@ static int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, ...@@ -1768,7 +1761,6 @@ static int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk,
newroot->u.n.n_children=2; newroot->u.n.n_children=2;
//printf("%s:%d Splitkey=%p %s\n", __FILE__, __LINE__, splitkey, splitkey); //printf("%s:%d Splitkey=%p %s\n", __FILE__, __LINE__, splitkey, splitkey);
newroot->u.n.childkeys[0] = splitk.data; newroot->u.n.childkeys[0] = splitk.data;
newroot->u.n.childkeylens[0] = splitk.size;
newroot->u.n.pivotflags[0] = splitk.flags; newroot->u.n.pivotflags[0] = splitk.flags;
newroot->u.n.totalchildkeylens=splitk.size; newroot->u.n.totalchildkeylens=splitk.size;
newroot->u.n.children[0]=nodea->thisnodename; newroot->u.n.children[0]=nodea->thisnodename;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment