Commit 2ba9c065 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

[t:3218] Try to write a big-block test. Refs #3218.

git-svn-id: file:///svn/toku/tokudb@28258 c7de825b-a66e-492c-adef-691d508d4ae1
parent ed80f210
...@@ -74,8 +74,8 @@ destroy_block_allocator (BLOCK_ALLOCATOR *bap) { ...@@ -74,8 +74,8 @@ destroy_block_allocator (BLOCK_ALLOCATOR *bap) {
static void static void
grow_blocks_array_by (BLOCK_ALLOCATOR ba, u_int64_t n_to_add) { grow_blocks_array_by (BLOCK_ALLOCATOR ba, u_int64_t n_to_add) {
if (ba->n_blocks + n_to_add > ba->blocks_array_size) { if (ba->n_blocks + n_to_add > ba->blocks_array_size) {
u_int64_t new_size = ba->n_blocks + n_to_add; int new_size = ba->n_blocks + n_to_add;
u_int64_t at_least = ba->blocks_array_size * 2; int at_least = ba->blocks_array_size * 2;
if (at_least > new_size) { if (at_least > new_size) {
new_size = at_least; new_size = at_least;
} }
......
...@@ -100,6 +100,21 @@ test_merge_n_m (u_int64_t n, u_int64_t m, int mode) ...@@ -100,6 +100,21 @@ test_merge_n_m (u_int64_t n, u_int64_t m, int mode)
toku_free(ma); toku_free(ma);
} }
static void
test_big_merge (void) {
u_int64_t twoG = 1024LL * 1024LL * 1024LL * 2;
u_int64_t an = twoG;
u_int64_t bn = 1;
struct block_allocator_blockpair *MALLOC_N(an+bn, a);
struct block_allocator_blockpair *MALLOC_N(bn, b);
for (u_int64_t i=0; i<an; i++) a[i].offset=i+1;
b[0].offset = 0;
block_allocator_merge_blockpairs_into(an, a, bn, b);
for (u_int64_t i=0; i<an+bn; i++) assert(a[i].offset=i);
toku_free(a);
toku_free(b);
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
test_merge_n_m(4, 4, 0); test_merge_n_m(4, 4, 0);
test_merge_n_m(16, 16, 0); test_merge_n_m(16, 16, 0);
...@@ -112,5 +127,6 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un ...@@ -112,5 +127,6 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
test_merge_n_m(too_big, too_big); test_merge_n_m(too_big, too_big);
test_merge_n_m(1, too_big, 0); test_merge_n_m(1, too_big, 0);
#endif #endif
test_big_merge();
return 0; return 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