diff options
author | Leif Walsh <leif@tokutek.com> | 2012-12-07 00:01:22 +0000 |
---|---|---|
committer | Yoni Fogel <yoni@tokutek.com> | 2013-04-17 00:01:21 -0400 |
commit | 7ff640e046154a432ab549cad3412bfe895b928f (patch) | |
tree | 7e6597a4e1f8b450c69c31b67e1c9ab896ce697c /ft | |
parent | 0ecaed8724f2a5f107f61e526c61f432f0df8933 (diff) | |
download | mariadb-git-7ff640e046154a432ab549cad3412bfe895b928f.tar.gz |
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
Diffstat (limited to 'ft')
-rw-r--r-- | ft/block_table.cc | 53 | ||||
-rw-r--r-- | ft/block_table.h | 4 | ||||
-rw-r--r-- | ft/ft-ops.cc | 8 | ||||
-rw-r--r-- | ft/ft-ops.h | 11 | ||||
-rw-r--r-- | ft/ft.cc | 10 | ||||
-rw-r--r-- | ft/ft.h | 2 |
6 files changed, 88 insertions, 0 deletions
diff --git a/ft/block_table.cc b/ft/block_table.cc index 0bf40470e41..68980741ef6 100644 --- a/ft/block_table.cc +++ b/ft/block_table.cc @@ -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 = ¤t->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; +} diff --git a/ft/block_table.h b/ft/block_table.h index ad4df746b8e..909b0a81a98 100644 --- a/ft/block_table.h +++ b/ft/block_table.h @@ -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, diff --git a/ft/ft-ops.cc b/ft/ft-ops.cc index 6164b9094fd..47ada85ea97 100644 --- a/ft/ft-ops.cc +++ b/ft/ft-ops.cc @@ -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) { diff --git a/ft/ft-ops.h b/ft/ft-ops.h index 6d03de7e899..9e5b2b0e220 100644 --- a/ft/ft-ops.h +++ b/ft/ft-ops.h @@ -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. |