Commit 13e5e562 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4875], move brt_stat64 work to brt_header.c

git-svn-id: file:///svn/toku/tokudb@43499 c7de825b-a66e-492c-adef-691d508d4ae1
parent adbd5ee0
...@@ -5428,33 +5428,7 @@ toku_brt_keyrange (BRT brt, DBT *key, u_int64_t *less_p, u_int64_t *equal_p, u_i ...@@ -5428,33 +5428,7 @@ toku_brt_keyrange (BRT brt, DBT *key, u_int64_t *less_p, u_int64_t *equal_p, u_i
int int
toku_brt_stat64 (BRT brt, TOKUTXN UU(txn), struct brtstat64_s *s) { toku_brt_stat64 (BRT brt, TOKUTXN UU(txn), struct brtstat64_s *s) {
assert(brt->h); assert(brt->h);
toku_brtheader_stat64(brt->h, s);
{
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;
return 0; return 0;
} }
......
...@@ -906,4 +906,25 @@ int toku_brtheader_set_panic(struct brt_header *h, int panic, char *panic_string ...@@ -906,4 +906,25 @@ int toku_brtheader_set_panic(struct brt_header *h, int panic, char *panic_string
return 0; 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;
}
...@@ -62,6 +62,6 @@ void toku_calculate_root_offset_pointer ( struct brt_header* h, CACHEKEY* root_k ...@@ -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); 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)); 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)); 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 #endif
...@@ -3975,23 +3975,16 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) { ...@@ -3975,23 +3975,16 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) {
return 0; return 0;
} }
u_int64_t u_int64_t toku_cachefile_size(CACHEFILE cf) {
toku_cachefile_size_in_memory(CACHEFILE cf) int64_t file_size;
{ int fd = toku_cachefile_get_and_pin_fd(cf);
u_int64_t result=0; int r = toku_os_get_file_size(fd, &file_size);
CACHETABLE ct=cf->cachetable; toku_cachefile_unpin_fd(cf);
unsigned long i; assert_zero(r);
for (i=0; i<ct->table_size; i++) { return file_size;
PAIR p;
for (p=ct->table[i]; p; p=p->hash_chain) {
if (p->cachefile==cf) {
result += p->attr.size;
}
}
}
return result;
} }
char * char *
toku_construct_full_name(int count, ...) { toku_construct_full_name(int count, ...) {
va_list ap; va_list ap;
......
...@@ -479,7 +479,8 @@ void toku_cachetable_print_hash_histogram (void) __attribute__((__visibility__(" ...@@ -479,7 +479,8 @@ void toku_cachetable_print_hash_histogram (void) __attribute__((__visibility__("
void toku_cachetable_maybe_flush_some(CACHETABLE ct); 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 { typedef enum {
CT_MISS = 0, CT_MISS = 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