Commit f4ec8661 authored by Rich Prohaska's avatar Rich Prohaska

merge some seq insert code to main. addresses #896

git-svn-id: file:///svn/tokudb@4626 c7de825b-a66e-492c-adef-691d508d4ae1
parent 9c6dd317
...@@ -95,6 +95,7 @@ struct brtnode { ...@@ -95,6 +95,7 @@ struct brtnode {
struct leaf { struct leaf {
OMT buffer; OMT buffer;
unsigned int n_bytes_in_buffer; /* How many bytes to represent the OMT (including the per-key overheads, but not including the overheads for the node. */ unsigned int n_bytes_in_buffer; /* How many bytes to represent the OMT (including the per-key overheads, but not including the overheads for the node. */
unsigned int seqinsert; /* number of sequential inserts to this leaf */
struct mempool buffer_mempool; struct mempool buffer_mempool;
} l; } l;
} u; } u;
......
...@@ -386,6 +386,7 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, u_int32_t fullhash, BRTN ...@@ -386,6 +386,7 @@ int toku_deserialize_brtnode_from (int fd, DISKOFF off, u_int32_t fullhash, BRTN
} else { } else {
int n_in_buf = rbuf_int(&rc); int n_in_buf = rbuf_int(&rc);
result->u.l.n_bytes_in_buffer = 0; result->u.l.n_bytes_in_buffer = 0;
result->u.l.seqinsert = 0;
//printf("%s:%d r PMA= %p\n", __FILE__, __LINE__, result->u.l.buffer); //printf("%s:%d r PMA= %p\n", __FILE__, __LINE__, result->u.l.buffer);
toku_mempool_init(&result->u.l.buffer_mempool, rc.buf, datasize); toku_mempool_init(&result->u.l.buffer_mempool, rc.buf, datasize);
......
...@@ -356,6 +356,7 @@ static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height) ...@@ -356,6 +356,7 @@ static void initialize_brtnode (BRT t, BRTNODE n, DISKOFF nodename, int height)
//printf("%s:%d n PMA= %p (rcount=%d)\n", __FILE__, __LINE__, n->u.l.buffer, rcount); //printf("%s:%d n PMA= %p (rcount=%d)\n", __FILE__, __LINE__, n->u.l.buffer, rcount);
rcount++; rcount++;
n->u.l.n_bytes_in_buffer = 0; n->u.l.n_bytes_in_buffer = 0;
n->u.l.seqinsert = 0;
} }
} }
...@@ -1515,9 +1516,19 @@ static int brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, ...@@ -1515,9 +1516,19 @@ static int brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd,
switch (cmd->type) { switch (cmd->type) {
case BRT_INSERT: case BRT_INSERT:
if (node->u.l.seqinsert) {
r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_bessel, &be, idx = toku_omt_size(node->u.l.buffer);
&storeddatav, &idx, NULL); r = toku_omt_fetch(node->u.l.buffer, idx-1, &storeddatav, NULL);
if (r != 0) goto fz;
storeddata = storeddatav;
int cmp = toku_cmd_leafval_bessel(storeddata, &be);
if (cmp >= 0) goto fz;
r = DB_NOTFOUND;
} else {
fz:
r = toku_omt_find_zero(node->u.l.buffer, toku_cmd_leafval_bessel, &be,
&storeddatav, &idx, NULL);
}
if (r==DB_NOTFOUND) { if (r==DB_NOTFOUND) {
storeddata = 0; storeddata = 0;
} else if (r!=0) { } else if (r!=0) {
...@@ -1528,6 +1539,10 @@ static int brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd, ...@@ -1528,6 +1539,10 @@ static int brt_leaf_put_cmd (BRT t, BRTNODE node, BRT_CMD cmd,
r = brt_leaf_apply_cmd_once(t, node, cmd, logger, idx, storeddata); r = brt_leaf_apply_cmd_once(t, node, cmd, logger, idx, storeddata);
if (r!=0) return r; if (r!=0) return r;
if (idx == toku_omt_size(node->u.l.buffer)-1)
node->u.l.seqinsert += 1;
else
node->u.l.seqinsert = 0;
break; break;
case BRT_DELETE_BOTH: case BRT_DELETE_BOTH:
case BRT_ABORT_BOTH: case BRT_ABORT_BOTH:
......
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