Commit 3a29cece authored by Rich Prohaska's avatar Rich Prohaska

remove pivot flags. addresses #250

git-svn-id: file:///svn/tokudb@1560 c7de825b-a66e-492c-adef-691d508d4ae1
parent 62da09d7
...@@ -31,7 +31,6 @@ struct brtnode_nonleaf_pivotinfo { ...@@ -31,7 +31,6 @@ struct brtnode_nonleaf_pivotinfo {
* For nonduplicate and DUPSORT keys we have * For nonduplicate and DUPSORT keys we have
* Child 0's keys <= pivotkey[0] < Child 1's keys <= pivotkey[1] < ... pivotkey[N-1] < child N's keys <= pivotkey[N] ... * Child 0's keys <= pivotkey[0] < Child 1's keys <= pivotkey[1] < ... pivotkey[N-1] < child N's keys <= pivotkey[N] ...
*/ */
unsigned char pivotflags;
}; };
struct brtnode_nonleaf_childinfo { struct brtnode_nonleaf_childinfo {
u_int32_t subtree_fingerprint; u_int32_t subtree_fingerprint;
...@@ -81,7 +80,6 @@ struct brtnode { ...@@ -81,7 +80,6 @@ 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 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. */
#define BRTNODE_CHILD_DISKOFF(node,i) ((node)->u.n.children[i]) #define BRTNODE_CHILD_DISKOFF(node,i) ((node)->u.n.children[i])
HASHTABLE htables[TREE_FANOUT+1]; HASHTABLE htables[TREE_FANOUT+1];
...@@ -98,8 +96,6 @@ struct brtnode { ...@@ -98,8 +96,6 @@ struct brtnode {
/* pivot flags (must fit in 8 bits) */ /* pivot flags (must fit in 8 bits) */
enum { enum {
BRT_PIVOT_PRESENT_L = 1,
BRT_PIVOT_PRESENT_R = 2,
BRT_PIVOT_TRUNC = 4, BRT_PIVOT_TRUNC = 4,
BRT_PIVOT_FRONT_COMPRESS = 8, BRT_PIVOT_FRONT_COMPRESS = 8,
}; };
......
...@@ -34,7 +34,6 @@ static void test_serialize(void) { ...@@ -34,7 +34,6 @@ static void test_serialize(void) {
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.totalchildkeylens = 6; sn.u.n.totalchildkeylens = 6;
sn.u.n.pivotflags[0] = 42;
sn.u.n.children[0] = sn.nodesize*30; sn.u.n.children[0] = sn.nodesize*30;
sn.u.n.children[1] = sn.nodesize*35; sn.u.n.children[1] = sn.nodesize*35;
BRTNODE_CHILD_SUBTREE_FINGERPRINTS(&sn, 0) = random(); BRTNODE_CHILD_SUBTREE_FINGERPRINTS(&sn, 0) = random();
...@@ -67,7 +66,6 @@ static void test_serialize(void) { ...@@ -67,7 +66,6 @@ static void test_serialize(void) {
assert(strcmp(kv_pair_key(dn->u.n.childkeys[0]), "hello")==0); assert(strcmp(kv_pair_key(dn->u.n.childkeys[0]), "hello")==0);
assert(toku_brtnode_pivot_key_len(dn, dn->u.n.childkeys[0])==6); assert(toku_brtnode_pivot_key_len(dn, dn->u.n.childkeys[0])==6);
assert(dn->u.n.totalchildkeylens==6); assert(dn->u.n.totalchildkeylens==6);
assert(dn->u.n.pivotflags[0]==42);
assert(dn->u.n.children[0]==nodesize*30); assert(dn->u.n.children[0]==nodesize*30);
assert(dn->u.n.children[1]==nodesize*35); assert(dn->u.n.children[1]==nodesize*35);
{ {
......
...@@ -36,7 +36,6 @@ static unsigned int toku_serialize_brtnode_size_slow(BRTNODE node) { ...@@ -36,7 +36,6 @@ static unsigned int toku_serialize_brtnode_size_slow(BRTNODE node) {
for (i=0; i<node->u.n.n_children-1; i++) { for (i=0; i<node->u.n.n_children-1; i++) {
size+=4; size+=4;
if (node->flags & TOKU_DB_DUPSORT) size += 4; if (node->flags & TOKU_DB_DUPSORT) size += 4;
size+=1; /* pivotflags */
csize+=toku_brtnode_pivot_key_len(node, node->u.n.childkeys[i]); csize+=toku_brtnode_pivot_key_len(node, node->u.n.childkeys[i]);
} }
for (i=0; i<node->u.n.n_children; i++) { for (i=0; i<node->u.n.n_children; i++) {
...@@ -75,7 +74,7 @@ unsigned int toku_serialize_brtnode_size (BRTNODE node) { ...@@ -75,7 +74,7 @@ unsigned int toku_serialize_brtnode_size (BRTNODE node) {
if (node->height>0) { if (node->height>0) {
result+=4; /* n_children */ result+=4; /* n_children */
result+=4; /* subtree fingerpirnt */ result+=4; /* subtree fingerpirnt */
result+=(4+1)*(node->u.n.n_children-1); /* key lengths + pivotflags*/ result+=4*(node->u.n.n_children-1); /* key lengths*/
if (node->flags & TOKU_DB_DUPSORT) result += 4*(node->u.n.n_children-1); /* data lengths */ if (node->flags & TOKU_DB_DUPSORT) result += 4*(node->u.n.n_children-1); /* data lengths */
result+=node->u.n.totalchildkeylens; /* the lengths of the pivot keys, without their key lengths. */ result+=node->u.n.totalchildkeylens; /* the lengths of the pivot keys, without their key lengths. */
result+=(8+4+4)*(node->u.n.n_children); /* For each child, a child offset, a count for the number of hash table entries, and the subtree fingerprint. */ result+=(8+4+4)*(node->u.n.n_children); /* For each child, a child offset, a count for the number of hash table entries, and the subtree fingerprint. */
...@@ -133,8 +132,6 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node) ...@@ -133,8 +132,6 @@ void toku_serialize_brtnode_to(int fd, DISKOFF off, DISKOFF size, BRTNODE node)
wbuf_int(&w, BRTNODE_CHILD_SUBTREE_FINGERPRINTS(node, i)); wbuf_int(&w, BRTNODE_CHILD_SUBTREE_FINGERPRINTS(node, i));
} }
//printf("%s:%d w.ndone=%d\n", __FILE__, __LINE__, w.ndone); //printf("%s:%d w.ndone=%d\n", __FILE__, __LINE__, w.ndone);
for (i=0; i<node->u.n.n_children-1; i++)
wbuf_char(&w, node->u.n.pivotflags[i]);
for (i=0; i<node->u.n.n_children-1; i++) { for (i=0; i<node->u.n.n_children-1; i++) {
if (node->flags & TOKU_DB_DUPSORT) { if (node->flags & TOKU_DB_DUPSORT) {
wbuf_bytes(&w, kv_pair_key(node->u.n.childkeys[i]), kv_pair_keylen(node->u.n.childkeys[i])); wbuf_bytes(&w, kv_pair_key(node->u.n.childkeys[i]), kv_pair_keylen(node->u.n.childkeys[i]));
...@@ -298,8 +295,6 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl ...@@ -298,8 +295,6 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, BRTNODE *brtnode, int fl
BRTNODE_CHILD_SUBTREE_FINGERPRINTS(result, i)= childfp; BRTNODE_CHILD_SUBTREE_FINGERPRINTS(result, i)= childfp;
check_subtree_fingerprint += childfp; check_subtree_fingerprint += childfp;
} }
for (i=0; i<result->u.n.n_children-1; i++)
result->u.n.pivotflags[i] = rbuf_char(&rc);
for (i=0; i<result->u.n.n_children-1; i++) { for (i=0; i<result->u.n.n_children-1; i++) {
if (result->flags & TOKU_DB_DUPSORT) { if (result->flags & TOKU_DB_DUPSORT) {
bytevec keyptr, dataptr; bytevec keyptr, dataptr;
......
...@@ -442,19 +442,16 @@ static void brt_nonleaf_split (BRT t, BRTNODE node, BRTNODE *nodea, BRTNODE *nod ...@@ -442,19 +442,16 @@ 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.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;
} }
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];
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;
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.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;
...@@ -654,10 +651,8 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum, ...@@ -654,10 +651,8 @@ 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.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.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++;
...@@ -1599,7 +1594,6 @@ static int brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, ...@@ -1599,7 +1594,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.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;
newroot->u.n.children[1]=nodeb->thisnodename; newroot->u.n.children[1]=nodeb->thisnodename;
......
...@@ -972,13 +972,11 @@ static void test_pma_dup_split_n(int n, int dup_mode) { ...@@ -972,13 +972,11 @@ static void test_pma_dup_split_n(int n, int dup_mode) {
if (0) { printf("c:"); toku_print_pma(pmac); } if (0) { printf("c:"); toku_print_pma(pmac); }
nc = toku_pma_n_entries(pmac); nc = toku_pma_n_entries(pmac);
if (na > 0) { if (n > 0) {
int kk; int kk;
assert(splitk.size == sizeof kk); assert(splitk.size == sizeof kk);
memcpy(&kk, splitk.data, splitk.size); memcpy(&kk, splitk.data, splitk.size);
assert(kk == dupkey); assert(kk == dupkey);
if (nb > 0) assert(splitk.flags & BRT_PIVOT_PRESENT_L);
if (nc > 0) assert(splitk.flags & BRT_PIVOT_PRESENT_R);
} }
if (splitk.data) toku_free(splitk.data); if (splitk.data) toku_free(splitk.data);
......
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