@ -126,6 +126,15 @@ DBPropertyType GetPropertyType(const Slice& property) {
bool InternalStats : : GetProperty ( DBPropertyType property_type ,
bool InternalStats : : GetProperty ( DBPropertyType property_type ,
const Slice & property , std : : string * value ) {
const Slice & property , std : : string * value ) {
if ( property_type > kStartIntTypes ) {
uint64_t int_value ;
bool ret_value = GetIntProperty ( property_type , property , & int_value ) ;
if ( ret_value ) {
* value = std : : to_string ( int_value ) ;
}
return ret_value ;
}
Version * current = cfd_ - > current ( ) ;
Version * current = cfd_ - > current ( ) ;
Slice in = property ;
Slice in = property ;
@ -179,40 +188,51 @@ bool InternalStats::GetProperty(DBPropertyType property_type,
case kSsTables :
case kSsTables :
* value = current - > DebugString ( ) ;
* value = current - > DebugString ( ) ;
return true ;
return true ;
default :
return false ;
}
}
bool InternalStats : : GetIntProperty ( DBPropertyType property_type ,
const Slice & property ,
uint64_t * value ) const {
Version * current = cfd_ - > current ( ) ;
switch ( property_type ) {
case kNumImmutableMemTable :
case kNumImmutableMemTable :
* value = std : : to_string ( cfd_ - > imm ( ) - > size ( ) ) ;
* value = cfd_ - > imm ( ) - > size ( ) ;
return true ;
return true ;
case kMemtableFlushPending :
case kMemtableFlushPending :
// Return number of mem tables that are ready to flush (made immutable)
// Return number of mem tables that are ready to flush (made immutable)
* value = std : : to_string ( cfd_ - > imm ( ) - > IsFlushPending ( ) ? 1 : 0 ) ;
* value = ( cfd_ - > imm ( ) - > IsFlushPending ( ) ? 1 : 0 ) ;
return true ;
return true ;
case kCompactionPending :
case kCompactionPending :
// 1 if the system already determines at least one compacdtion is needed.
// 1 if the system already determines at least one compacdtion is needed.
// 0 otherwise,
// 0 otherwise,
* value = std : : to_string ( current - > NeedsCompaction ( ) ? 1 : 0 ) ;
* value = ( current - > NeedsCompaction ( ) ? 1 : 0 ) ;
return true ;
return true ;
case kBackgroundErrors :
case kBackgroundErrors :
// Accumulated number of errors in background flushes or compactions.
// Accumulated number of errors in background flushes or compactions.
* value = std : : to_string ( GetBackgroundErrorCount ( ) ) ;
* value = GetBackgroundErrorCount ( ) ;
return true ;
return true ;
case kCurSizeActiveMemTable :
case kCurSizeActiveMemTable :
// Current size of the active memtable
// Current size of the active memtable
* value = std : : to_string ( cfd_ - > mem ( ) - > ApproximateMemoryUsage ( ) ) ;
* value = cfd_ - > mem ( ) - > ApproximateMemoryUsage ( ) ;
return true ;
return true ;
case kNumEntriesInMutableMemtable :
case kNumEntriesInMutableMemtable :
// Current size of the active memtable
// Current size of the active memtable
* value = std : : to_string ( cfd_ - > mem ( ) - > GetNumEntries ( ) ) ;
* value = cfd_ - > mem ( ) - > GetNumEntries ( ) ;
return true ;
return true ;
case kNumEntriesInImmutableMemtable :
case kNumEntriesInImmutableMemtable :
// Current size of the active memtable
// Current size of the active memtable
* value = std : : to_string ( cfd_ - > imm ( ) - > current ( ) - > GetTotalNumEntries ( ) ) ;
* value = cfd_ - > imm ( ) - > current ( ) - > GetTotalNumEntries ( ) ;
return true ;
return true ;
case kEstimatedNumKeys :
case kEstimatedNumKeys :
// Estimate number of entries in the column family:
// Estimate number of entries in the column family:
// Use estimated entries in tables + total entries in memtables.
// Use estimated entries in tables + total entries in memtables.
* value = std : : to_string ( cfd_ - > mem ( ) - > GetNumEntries ( ) +
* value = cfd_ - > mem ( ) - > GetNumEntries ( ) +
cfd_ - > imm ( ) - > current ( ) - > GetTotalNumEntries ( ) +
cfd_ - > imm ( ) - > current ( ) - > GetTotalNumEntries ( ) +
current - > GetEstimatedActiveKeys ( ) ) ;
current - > GetEstimatedActiveKeys ( ) ;
return true ;
return true ;
default :
default :
return false ;
return false ;