Commit d7b8320f authored by Rich Prohaska's avatar Rich Prohaska

#87 add callback to allow loader memory size to be a session variable

parent 7c455cbf
......@@ -459,7 +459,7 @@ static void print_db_env_struct (void) {
"void (*change_fsync_log_period) (DB_ENV*, uint32_t)",
"int (*iterate_live_transactions) (DB_ENV *env, iterate_transactions_callback callback, void *extra)",
"int (*iterate_pending_lock_requests) (DB_ENV *env, iterate_requests_callback callback, void *extra)",
"void (*set_loader_memory_size)(DB_ENV *env, uint64_t loader_memory_size)",
"void (*set_loader_memory_size)(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void))",
"uint64_t (*get_loader_memory_size)(DB_ENV *env)",
NULL};
......
......@@ -319,8 +319,8 @@ toku_loader_create_loader(DB_ENV *env,
}
TOKUTXN ttxn = txn ? db_txn_struct_i(txn)->tokutxn : NULL;
rval = toku_ft_loader_open(&loader->i->ft_loader,
loader->i->env->i->cachetable,
loader->i->env->i->generate_row_for_put,
env->i->cachetable,
env->i->generate_row_for_put,
src_db,
N,
brts, dbs,
......@@ -330,7 +330,7 @@ toku_loader_create_loader(DB_ENV *env,
load_lsn,
ttxn,
puts_allowed,
loader->i->env->i->loader_memory_size,
env->get_loader_memory_size(env),
compress_intermediates);
if ( rval!=0 ) {
toku_free(new_inames_in_env);
......
......@@ -91,14 +91,21 @@ PATENT RIGHTS GRANT:
#include "test.h"
#include <db.h>
static uint64_t my_loader_memory_size;
static uint64_t get_loader_memory_size(void) {
return my_loader_memory_size;
}
int test_main (int argc, char * const argv[]) {
parse_args(argc, argv);
int r;
DB_ENV *env;
r = db_env_create(&env, 0);
assert_zero(r);
env->set_loader_memory_size(env, get_loader_memory_size);
for (uint64_t n = 0 ; n < 10000000000; n += 1000000000) {
env->set_loader_memory_size(env, n);
my_loader_memory_size = n;
assert(env->get_loader_memory_size(env) == n);
}
r = env->close(env, 0);
......
......@@ -182,7 +182,7 @@ struct __toku_db_env_internal {
int datadir_lockfd;
int logdir_lockfd;
int tmpdir_lockfd;
uint64_t loader_memory_size;
uint64_t (*get_loader_memory_size_callback)(void);
};
// test-only environment function for running lock escalation
......
......@@ -2416,12 +2416,15 @@ env_iterate_live_transactions(DB_ENV *env,
return toku_txn_manager_iter_over_live_root_txns(txn_manager, iter_txns_callback, &e);
}
static void env_set_loader_memory_size(DB_ENV *env, uint64_t loader_memory_size) {
env->i->loader_memory_size = loader_memory_size;
static void env_set_loader_memory_size(DB_ENV *env, uint64_t (*get_loader_memory_size_callback)(void)) {
env->i->get_loader_memory_size_callback = get_loader_memory_size_callback;
}
static uint64_t env_get_loader_memory_size(DB_ENV *env) {
return env->i->loader_memory_size;
uint64_t memory_size = 0;
if (env->i->get_loader_memory_size_callback)
memory_size = env->i->get_loader_memory_size_callback();
return memory_size;
}
static int
......
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