Commit 6ac39437 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Start making structs for the children. Addresses #126.

git-svn-id: file:///svn/tokudb@957 c7de825b-a66e-492c-adef-691d508d4ae1
parent eeb476bd
...@@ -25,6 +25,22 @@ enum { BUFFER_HEADER_SIZE = (4 // height// ...@@ -25,6 +25,22 @@ enum { BUFFER_HEADER_SIZE = (4 // height//
+ 4 // n_children + 4 // n_children
+ TREE_FANOUT * 8 // children + TREE_FANOUT * 8 // children
) }; ) };
struct brtnode_nonleaf_pivotinfo {
struct kv_pair *pivotkey; /* For DUPSORT keys, the keys are whole key-value pairs.
* 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] ...
*/
unsigned char pivotflags;
};
struct brtnode_nonleaf_childinfo {
u_int32_t subtree_fingerprint;
DISKOFF diskoff;
HASHTABLE htable;
unsigned int n_bytes_in_hashtable; /* How many bytes are in each hashtable (including overheads for the disk-representation) */
unsigned int n_cursors;
};
typedef struct brtnode *BRTNODE; typedef struct brtnode *BRTNODE;
/* Internal nodes. */ /* Internal nodes. */
struct brtnode { struct brtnode {
...@@ -44,19 +60,26 @@ struct brtnode { ...@@ -44,19 +60,26 @@ struct brtnode {
struct nonleaf { struct nonleaf {
// Don't actually store the subree fingerprint in the in-memory data structure. // Don't actually store the subree fingerprint in the in-memory data structure.
int n_children; /* if n_children==TREE_FANOUT+1 then the tree needs to be rebalanced. */ int n_children; /* if n_children==TREE_FANOUT+1 then the tree needs to be rebalanced. */
unsigned int totalchildkeylens;
unsigned int n_bytes_in_hashtables;
//#define CHSTRUCT
#ifdef CHSTRUCT
struct brtnode_nonleaf_pivotinfo pivots[TREE_FANOUT]; /* One extra one so we can grow. */
struct brtnode_nonleaf_childinfo children[TREE_FANOUT+1]; /* One extra so we can grow */
#else
u_int32_t child_subtree_fingerprints[TREE_FANOUT+1]; u_int32_t child_subtree_fingerprints[TREE_FANOUT+1];
struct kv_pair *childkeys[TREE_FANOUT]; /* Pivot keys. Child 0's keys are <= childkeys[0]. Child 1's keys are <= childkeys[1]. struct kv_pair *childkeys[TREE_FANOUT]; /* Pivot keys. Child 0's keys are <= childkeys[0]. Child 1's keys are <= childkeys[1].
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 int totalchildkeylens;
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];
unsigned int n_bytes_in_hashtable[TREE_FANOUT+1]; /* how many bytes are in each hashtable (including overheads) */ unsigned int n_bytes_in_hashtable[TREE_FANOUT+1]; /* how many bytes are in each hashtable (including overheads) */
unsigned int n_bytes_in_hashtables;
unsigned int n_cursors[TREE_FANOUT+1]; unsigned int n_cursors[TREE_FANOUT+1];
#endif
} n; } n;
struct leaf { struct leaf {
PMA buffer; PMA buffer;
......
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