Commit 7ff640e0 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

closes #5757 merge information_schema.tokudb_fractal_tree_info and...

closes #5757 merge information_schema.tokudb_fractal_tree_info and information_schema.tokudb_fractal_tree_block_map to main

git-svn-id: file:///svn/toku/tokudb@50863 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0ecaed87
......@@ -443,6 +443,8 @@ static void print_db_struct (void) {
"int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)",
"int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, uint32_t flags)",
"int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, uint32_t flags)",
"int (*get_fractal_tree_info64)(DB*,uint64_t*,uint64_t*,uint64_t*,uint64_t*)",
"int (*iterate_fractal_tree_block_map)(DB*,int(*)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*),void*)",
NULL};
sort_and_dump_fields("db", true, extra);
}
......
......@@ -1070,3 +1070,56 @@ toku_block_table_get_fragmentation_unlocked(BLOCK_TABLE bt, TOKU_DB_FRAGMENTATIO
block_allocator_get_unused_statistics(bt->block_allocator, report);
}
void
toku_blocktable_get_info64(BLOCK_TABLE bt, struct ftinfo64 *s) {
lock_for_blocktable(bt);
struct translation *current = &bt->current;
s->num_blocks_allocated = current->length_of_array;
s->num_blocks_in_use = 0;
s->size_allocated = 0;
s->size_in_use = 0;
for (int64_t i = 0; i < current->length_of_array; ++i) {
struct block_translation_pair *block = &current->block_translation[i];
if (block->size != size_is_free) {
++s->num_blocks_in_use;
s->size_in_use += block->size;
if (block->u.diskoff != diskoff_unused) {
uint64_t limit = block->u.diskoff + block->size;
if (limit > s->size_allocated) {
s->size_allocated = limit;
}
}
}
}
unlock_for_blocktable(bt);
}
int
toku_blocktable_iterate_translation_tables(BLOCK_TABLE bt, uint64_t checkpoint_count,
int (*iter)(uint64_t checkpoint_count,
int64_t total_num_rows,
int64_t blocknum,
int64_t diskoff,
int64_t size,
void *extra),
void *iter_extra) {
int error = 0;
lock_for_blocktable(bt);
int64_t total_num_rows = bt->current.length_of_array + bt->checkpointed.length_of_array;
for (int64_t i = 0; error == 0 && i < bt->current.length_of_array; ++i) {
struct block_translation_pair *block = &bt->current.block_translation[i];
error = iter(checkpoint_count, total_num_rows, i, block->u.diskoff, block->size, iter_extra);
}
for (int64_t i = 0; error == 0 && i < bt->checkpointed.length_of_array; ++i) {
struct block_translation_pair *block = &bt->checkpointed.block_translation[i];
error = iter(checkpoint_count - 1, total_num_rows, i, block->u.diskoff, block->size, iter_extra);
}
unlock_for_blocktable(bt);
return error;
}
......@@ -75,6 +75,10 @@ void toku_block_table_get_fragmentation_unlocked(BLOCK_TABLE bt, TOKU_DB_FRAGMEN
int64_t toku_block_get_blocks_in_use_unlocked(BLOCK_TABLE bt);
void toku_blocktable_get_info64(BLOCK_TABLE, struct ftinfo64 *);
int toku_blocktable_iterate_translation_tables(BLOCK_TABLE, uint64_t, int (*)(uint64_t, int64_t, int64_t, int64_t, int64_t, void *), void *);
//Unmovable reserved first, then reallocable.
// We reserve one blocknum for the translation table itself.
enum {RESERVED_BLOCKNUM_NULL =0,
......
......@@ -5748,6 +5748,14 @@ void toku_ft_handle_stat64 (FT_HANDLE brt, TOKUTXN UU(txn), struct ftstat64_s *s
toku_ft_stat64(brt->ft, s);
}
void toku_ft_handle_get_fractal_tree_info64(FT_HANDLE ft_h, struct ftinfo64 *s) {
toku_ft_get_fractal_tree_info64(ft_h->ft, s);
}
int toku_ft_handle_iterate_fractal_tree_block_map(FT_HANDLE ft_h, int (*iter)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*), void *iter_extra) {
return toku_ft_iterate_fractal_tree_block_map(ft_h->ft, iter, iter_extra);
}
/* ********************* debugging dump ************************ */
static int
toku_dump_ftnode (FILE *file, FT_HANDLE brt, BLOCKNUM blocknum, int depth, const DBT *lorange, const DBT *hirange) {
......
......@@ -219,6 +219,17 @@ struct ftstat64_s {
void toku_ft_handle_stat64 (FT_HANDLE, TOKUTXN, struct ftstat64_s *stat);
struct ftinfo64 {
uint64_t num_blocks_allocated; // number of blocks in the blocktable
uint64_t num_blocks_in_use; // number of blocks in use by most recent checkpoint
uint64_t size_allocated; // sum of sizes of blocks in blocktable
uint64_t size_in_use; // sum of sizes of blocks in use by most recent checkpoint
};
void toku_ft_handle_get_fractal_tree_info64(FT_HANDLE, struct ftinfo64 *);
int toku_ft_handle_iterate_fractal_tree_block_map(FT_HANDLE, int (*)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*), void *);
int toku_ft_layer_init(void) __attribute__ ((warn_unused_result));
void toku_ft_open_close_lock(void);
void toku_ft_open_close_unlock(void);
......
......@@ -770,6 +770,16 @@ toku_ft_stat64 (FT ft, struct ftstat64_s *s) {
s->verify_time_sec = ft->h->time_of_last_verification;
}
void
toku_ft_get_fractal_tree_info64(FT ft, struct ftinfo64 *s) {
toku_blocktable_get_info64(ft->blocktable, s);
}
int toku_ft_iterate_fractal_tree_block_map(FT ft, int (*iter)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*), void *iter_extra) {
uint64_t this_checkpoint_count = ft->h->checkpoint_count;
return toku_blocktable_iterate_translation_tables(ft->blocktable, this_checkpoint_count, iter, iter_extra);
}
void
toku_ft_update_descriptor(FT ft, DESCRIPTOR d)
// Effect: Changes the descriptor in a tree (log the change, make sure it makes it to disk eventually).
......
......@@ -67,6 +67,8 @@ void toku_calculate_root_offset_pointer ( FT h, CACHEKEY* root_key, uint32_t *ro
void toku_ft_set_new_root_blocknum(FT h, CACHEKEY new_root_key);
LSN toku_ft_checkpoint_lsn(FT h) __attribute__ ((warn_unused_result));
void toku_ft_stat64 (FT h, struct ftstat64_s *s);
void toku_ft_get_fractal_tree_info64 (FT h, struct ftinfo64 *s);
int toku_ft_iterate_fractal_tree_block_map(FT ft, int (*iter)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*), void *iter_extra);
// unconditionally set the descriptor for an open FT. can't do this when
// any operation has already occurred on the ft.
......
......@@ -605,6 +605,24 @@ toku_db_get_compression_method(DB *db, enum toku_compression_method *compression
return 0;
}
static int
toku_db_get_fractal_tree_info64(DB *db, uint64_t *num_blocks_allocated, uint64_t *num_blocks_in_use, uint64_t *size_allocated, uint64_t *size_in_use) {
HANDLE_PANICKED_DB(db);
struct ftinfo64 ftinfo;
toku_ft_handle_get_fractal_tree_info64(db->i->ft_handle, &ftinfo);
*num_blocks_allocated = ftinfo.num_blocks_allocated;
*num_blocks_in_use = ftinfo.num_blocks_in_use;
*size_allocated = ftinfo.size_allocated;
*size_in_use = ftinfo.size_in_use;
return 0;
}
static int
toku_db_iterate_fractal_tree_block_map(DB *db, int (*iter)(uint64_t,int64_t,int64_t,int64_t,int64_t,void*), void *iter_extra) {
HANDLE_PANICKED_DB(db);
return toku_ft_handle_iterate_fractal_tree_block_map(db->i->ft_handle, iter, iter_extra);
}
static int
toku_db_stat64(DB * db, DB_TXN *txn, DB_BTREE_STAT64 *s) {
HANDLE_PANICKED_DB(db);
......@@ -913,6 +931,8 @@ toku_db_create(DB ** db, DB_ENV * env, uint32_t flags) {
USDB(key_range64);
USDB(hot_optimize);
USDB(stat64);
USDB(get_fractal_tree_info64);
USDB(iterate_fractal_tree_block_map);
USDB(verify_with_progress);
USDB(cursor);
USDB(dbt_pos_infty);
......
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