diff --git a/newbrt/brt.c b/newbrt/brt.c index b6bd86a42750a66c4f2e8d7bc8bdbdc5ce3a862c..a6fb977cb27608e8ccb301168e97016c4aa48fa8 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -5428,33 +5428,7 @@ toku_brt_keyrange (BRT brt, DBT *key, u_int64_t *less_p, u_int64_t *equal_p, u_i int toku_brt_stat64 (BRT brt, TOKUTXN UU(txn), struct brtstat64_s *s) { assert(brt->h); - - { - int64_t file_size; - int fd = toku_cachefile_get_and_pin_fd(brt->h->cf); - int r = toku_os_get_file_size(fd, &file_size); - toku_cachefile_unpin_fd(brt->h->cf); - assert_zero(r); - s->fsize = file_size + toku_cachefile_size_in_memory(brt->h->cf); - } - // just use the in memory stats from the header - // prevent appearance of negative numbers for numrows, numbytes - int64_t n = brt->h->in_memory_stats.numrows; - if (n < 0) { - n = 0; - } - s->nkeys = s->ndata = n; - n = brt->h->in_memory_stats.numbytes; - if (n < 0) { - n = 0; - } - s->dsize = n; - - // 4018 - s->create_time_sec = brt->h->time_of_creation; - s->modify_time_sec = brt->h->time_of_last_modification; - s->verify_time_sec = brt->h->time_of_last_verification; - + toku_brtheader_stat64(brt->h, s); return 0; } diff --git a/newbrt/brt_header.c b/newbrt/brt_header.c index 0fdcfead2379d0d5a6a2d2d613c0f21d64b401ae..328c3bcd76bf5c79f1c6f9692e653b700b4ecc1f 100644 --- a/newbrt/brt_header.c +++ b/newbrt/brt_header.c @@ -906,4 +906,25 @@ int toku_brtheader_set_panic(struct brt_header *h, int panic, char *panic_string return 0; } +void +toku_brtheader_stat64 (struct brt_header* h, struct brtstat64_s *s) { + s->fsize = toku_cachefile_size(h->cf); + // just use the in memory stats from the header + // prevent appearance of negative numbers for numrows, numbytes + int64_t n = h->in_memory_stats.numrows; + if (n < 0) { + n = 0; + } + s->nkeys = s->ndata = n; + n = h->in_memory_stats.numbytes; + if (n < 0) { + n = 0; + } + s->dsize = n; + + // 4018 + s->create_time_sec = h->time_of_creation; + s->modify_time_sec = h->time_of_last_modification; + s->verify_time_sec = h->time_of_last_verification; +} diff --git a/newbrt/brt_header.h b/newbrt/brt_header.h index 01086c852712b37aba3159d652474c038f2499c2..2897bf3b623fb542b221ee318b748578602f525d 100644 --- a/newbrt/brt_header.h +++ b/newbrt/brt_header.h @@ -62,6 +62,6 @@ void toku_calculate_root_offset_pointer ( struct brt_header* h, CACHEKEY* root_k void toku_brtheader_set_new_root_blocknum(struct brt_header* h, CACHEKEY new_root_key); LSN toku_brt_checkpoint_lsn(struct brt_header* h) __attribute__ ((warn_unused_result)); int toku_brtheader_set_panic(struct brt_header *h, int panic, char *panic_string) __attribute__ ((warn_unused_result)); - +void toku_brtheader_stat64 (struct brt_header* h, struct brtstat64_s *s); #endif diff --git a/newbrt/cachetable.c b/newbrt/cachetable.c index 141fdd8f16d77d5c875d8d94c6daac20a1f3b25e..52f5ca8366754d86edb5445ed1cb5659fabdb4f8 100644 --- a/newbrt/cachetable.c +++ b/newbrt/cachetable.c @@ -3975,23 +3975,16 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) { return 0; } -u_int64_t -toku_cachefile_size_in_memory(CACHEFILE cf) -{ - u_int64_t result=0; - CACHETABLE ct=cf->cachetable; - unsigned long i; - for (i=0; i<ct->table_size; i++) { - PAIR p; - for (p=ct->table[i]; p; p=p->hash_chain) { - if (p->cachefile==cf) { - result += p->attr.size; - } - } - } - return result; +u_int64_t toku_cachefile_size(CACHEFILE cf) { + int64_t file_size; + int fd = toku_cachefile_get_and_pin_fd(cf); + int r = toku_os_get_file_size(fd, &file_size); + toku_cachefile_unpin_fd(cf); + assert_zero(r); + return file_size; } + char * toku_construct_full_name(int count, ...) { va_list ap; diff --git a/newbrt/cachetable.h b/newbrt/cachetable.h index f10209089aea632891961146ab954115cf9c6b62..bf9a829c53fcd5378088dfd6d5fbb5be6af6353d 100644 --- a/newbrt/cachetable.h +++ b/newbrt/cachetable.h @@ -479,7 +479,8 @@ void toku_cachetable_print_hash_histogram (void) __attribute__((__visibility__(" void toku_cachetable_maybe_flush_some(CACHETABLE ct); -u_int64_t toku_cachefile_size_in_memory(CACHEFILE cf); +// for stat64 +u_int64_t toku_cachefile_size(CACHEFILE cf); typedef enum { CT_MISS = 0,