Commit 421b29ed authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#2717 refs[t:2717] fix the brtloader subtree estimates

git-svn-id: file:///svn/toku/tokudb@21040 c7de825b-a66e-492c-adef-691d508d4ae1
parent 536973c4
...@@ -52,12 +52,10 @@ struct subtree_estimates { ...@@ -52,12 +52,10 @@ struct subtree_estimates {
static struct subtree_estimates const zero_estimates __attribute__((__unused__)) = {0,0,0,TRUE}; static struct subtree_estimates const zero_estimates __attribute__((__unused__)) = {0,0,0,TRUE};
#if 0
static inline struct subtree_estimates __attribute__((__unused__)) static inline struct subtree_estimates __attribute__((__unused__))
make_subtree_estimates (u_int64_t nkeys, u_int64_t ndata, u_int64_t dsize, BOOL exact) { make_subtree_estimates (u_int64_t nkeys, u_int64_t ndata, u_int64_t dsize, BOOL exact) {
return (struct subtree_estimates){.nkeys=nkeys, .ndata=ndata, .dsize=dsize, .exact=exact}; return (struct subtree_estimates){nkeys, ndata, dsize, exact};
} }
#endif
static inline void __attribute__((__unused__)) static inline void __attribute__((__unused__))
subtract_estimates (struct subtree_estimates *a, struct subtree_estimates *b) { subtract_estimates (struct subtree_estimates *a, struct subtree_estimates *b) {
......
...@@ -2169,8 +2169,6 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl, ...@@ -2169,8 +2169,6 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
result = allocate_block(&out, &lblock); result = allocate_block(&out, &lblock);
lazy_assert(result == 0); // can not fail since translations reserved above lazy_assert(result == 0); // can not fail since translations reserved above
struct leaf_buf *lbuf = start_leaf(&out, descriptor, lblock); struct leaf_buf *lbuf = start_leaf(&out, descriptor, lblock);
struct subtree_estimates est = zero_estimates;
est.exact = TRUE;
u_int64_t n_rows_remaining = bl->n_rows; u_int64_t n_rows_remaining = bl->n_rows;
u_int64_t old_n_rows_remaining = bl->n_rows; u_int64_t old_n_rows_remaining = bl->n_rows;
...@@ -2215,6 +2213,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl, ...@@ -2215,6 +2213,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
progress_allocation -= progress_this_node; progress_allocation -= progress_this_node;
old_n_rows_remaining = n_rows_remaining; old_n_rows_remaining = n_rows_remaining;
struct subtree_estimates est = make_subtree_estimates(lbuf->nkeys, lbuf->ndata, lbuf->dsize, TRUE);
allocate_node(&sts, lblock, est, lbuf->local_fingerprint); allocate_node(&sts, lblock, est, lbuf->local_fingerprint);
n_pivots++; n_pivots++;
...@@ -2238,9 +2237,6 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl, ...@@ -2238,9 +2237,6 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
} }
add_pair_to_leafnode(lbuf, (unsigned char *) key.data, key.size, (unsigned char *) val.data, val.size); add_pair_to_leafnode(lbuf, (unsigned char *) key.data, key.size, (unsigned char *) val.data, val.size);
est.nkeys++;
est.ndata++;
est.dsize+=key.size + val.size;
n_rows_remaining--; n_rows_remaining--;
} }
...@@ -2249,6 +2245,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl, ...@@ -2249,6 +2245,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
} }
if (lbuf) { if (lbuf) {
struct subtree_estimates est = make_subtree_estimates(lbuf->nkeys, lbuf->ndata, lbuf->dsize, TRUE);
allocate_node(&sts, lblock, est, lbuf->local_fingerprint); allocate_node(&sts, lblock, est, lbuf->local_fingerprint);
{ {
int p = progress_allocation/2; int p = progress_allocation/2;
...@@ -2856,9 +2853,7 @@ static int setup_nonleaf_block (int n_children, ...@@ -2856,9 +2853,7 @@ static int setup_nonleaf_block (int n_children,
toku_free(pivots[n_children-1].data); toku_free(pivots[n_children-1].data);
pivots[n_children-1] = zero_dbt; pivots[n_children-1] = zero_dbt;
struct subtree_estimates new_subtree_estimates; struct subtree_estimates new_subtree_estimates = zero_estimates;
memset(&new_subtree_estimates, 0, sizeof new_subtree_estimates);
new_subtree_estimates.exact = TRUE;
struct subtree_info *XMALLOC_N(n_children, subtrees_array); struct subtree_info *XMALLOC_N(n_children, subtrees_array);
int32_t fingerprint = 0; int32_t fingerprint = 0;
......
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