Commit 2fa610a8 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #523

Uses range iterator (of range trees) to simplify code in lock tree.

This allowed us to deleting 'emergency' version of a function that was not well tested.

git-svn-id: file:///svn/tokudb@2825 c7de825b-a66e-492c-adef-691d508d4ae1
parent f333dea4
...@@ -695,34 +695,11 @@ static inline void toku__lt_init_full_query(toku_lock_tree* tree, toku_range* qu ...@@ -695,34 +695,11 @@ static inline void toku__lt_init_full_query(toku_lock_tree* tree, toku_range* qu
toku__init_query(query, left, right); toku__init_query(query, left, right);
} }
static inline int toku__lt_free_contents_slow(toku_lock_tree* tree, /*
toku_range_tree* rt, TODO: Refactor.
toku_range_tree* rtdel) { toku__lt_free_points should be replaced (or supplanted) with a
int r; toku__lt_free_point (singular)
toku_range query; */
toku_point left;
toku_point right;
u_int32_t numfound;
toku__lt_init_full_query(tree, &query, &left, &right);
/*
To free space the fast way, we need to allocate more space.
Since we can't, we free the slow way.
We do not optimize this, we take one entry at a time,
delete it from the tree, and then free the memory.
*/
do {
r = toku_rt_find(rt, &query, 1, &tree->buf, &tree->buflen, &numfound);
if (r!=0) break;
if (!numfound) break;
assert(numfound == 1);
r = toku_rt_delete(rt, &tree->buf[0]);
if (r!=0) break;
r = toku__lt_free_points(tree, &query, numfound, rtdel);
} while (TRUE);
return r;
}
static inline int toku__lt_free_contents(toku_lock_tree* tree, toku_range_tree* rt, static inline int toku__lt_free_contents(toku_lock_tree* tree, toku_range_tree* rt,
toku_range_tree *rtdel) { toku_range_tree *rtdel) {
assert(tree); assert(tree);
...@@ -730,17 +707,17 @@ static inline int toku__lt_free_contents(toku_lock_tree* tree, toku_range_tree* ...@@ -730,17 +707,17 @@ static inline int toku__lt_free_contents(toku_lock_tree* tree, toku_range_tree*
int r; int r;
int r2; int r2;
BOOL found = FALSE;
toku_rt_start_scan(rt);
toku_range query; toku_range query;
toku_point left; toku_point left;
toku_point right; toku_point right;
toku__lt_init_full_query(tree, &query, &left, &right); toku__lt_init_full_query(tree, &query, &left, &right);
while ((r = toku_rt_next(rt, &tree->buf[0], &found)) == 0 && found) {
u_int32_t numfound; r = toku__lt_free_points(tree, &query, 1, rtdel);
r = toku_rt_find(rt, &query, 0, &tree->buf, &tree->buflen, &numfound); if (r!=0) return toku__lt_panic(tree, r);
if (r==0) r = toku__lt_free_points(tree, &query, numfound, }
rtdel);
else if (r==ENOMEM) r = toku__lt_free_contents_slow(tree, rt, rtdel);
r2 = toku_rt_close(rt); r2 = toku_rt_close(rt);
assert(r2 == 0); assert(r2 == 0);
return r; return r;
......
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