@ -370,7 +370,7 @@ class MemTableConstructor: public Constructor {
: Constructor ( cmp ) ,
: Constructor ( cmp ) ,
internal_comparator_ ( cmp ) ,
internal_comparator_ ( cmp ) ,
table_factory_ ( new SkipListFactory ) {
table_factory_ ( new SkipListFactory ) {
memtable_ = new MemTable ( internal_comparator_ , table_factory_ ) ;
memtable_ = new MemTable ( internal_comparator_ , table_factory_ . get ( ) ) ;
memtable_ - > Ref ( ) ;
memtable_ - > Ref ( ) ;
}
}
~ MemTableConstructor ( ) {
~ MemTableConstructor ( ) {
@ -378,7 +378,7 @@ class MemTableConstructor: public Constructor {
}
}
virtual Status FinishImpl ( const Options & options , const KVMap & data ) {
virtual Status FinishImpl ( const Options & options , const KVMap & data ) {
delete memtable_ - > Unref ( ) ;
delete memtable_ - > Unref ( ) ;
memtable_ = new MemTable ( internal_comparator_ , table_factory_ ) ;
memtable_ = new MemTable ( internal_comparator_ , table_factory_ . get ( ) ) ;
memtable_ - > Ref ( ) ;
memtable_ - > Ref ( ) ;
int seq = 1 ;
int seq = 1 ;
for ( KVMap : : const_iterator it = data . begin ( ) ;
for ( KVMap : : const_iterator it = data . begin ( ) ;
@ -930,19 +930,19 @@ TEST(TableTest, NumBlockStat) {
class BlockCacheProperties {
class BlockCacheProperties {
public :
public :
explicit BlockCacheProperties ( std : : shared_ptr < Statistics > statistics ) {
explicit BlockCacheProperties ( Statistics * statistics ) {
block_cache_miss =
block_cache_miss =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_MISS ) ;
statistics - > getTickerCount ( BLOCK_CACHE_MISS ) ;
block_cache_hit =
block_cache_hit =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_HIT ) ;
statistics - > getTickerCount ( BLOCK_CACHE_HIT ) ;
index_block_cache_miss =
index_block_cache_miss =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_INDEX_MISS ) ;
statistics - > getTickerCount ( BLOCK_CACHE_INDEX_MISS ) ;
index_block_cache_hit =
index_block_cache_hit =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_INDEX_HIT ) ;
statistics - > getTickerCount ( BLOCK_CACHE_INDEX_HIT ) ;
data_block_cache_miss =
data_block_cache_miss =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_DATA_MISS ) ;
statistics - > getTickerCount ( BLOCK_CACHE_DATA_MISS ) ;
data_block_cache_hit =
data_block_cache_hit =
statistics . get ( ) - > getTickerCount ( BLOCK_CACHE_DATA_HIT ) ;
statistics - > getTickerCount ( BLOCK_CACHE_DATA_HIT ) ;
}
}
// Check if the fetched props matches the expected ones.
// Check if the fetched props matches the expected ones.
@ -993,7 +993,7 @@ TEST(TableTest, BlockCacheTest) {
// At first, no block will be accessed.
// At first, no block will be accessed.
{
{
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
// index will be added to block cache.
// index will be added to block cache.
props . AssertEqual (
props . AssertEqual (
1 , // index block miss
1 , // index block miss
@ -1006,7 +1006,7 @@ TEST(TableTest, BlockCacheTest) {
// Only index block will be accessed
// Only index block will be accessed
{
{
iter . reset ( c . NewIterator ( ) ) ;
iter . reset ( c . NewIterator ( ) ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
// NOTE: to help better highlight the "detla" of each ticker, I use
// NOTE: to help better highlight the "detla" of each ticker, I use
// <last_value> + <added_value> to indicate the increment of changed
// <last_value> + <added_value> to indicate the increment of changed
// value; other numbers remain the same.
// value; other numbers remain the same.
@ -1021,7 +1021,7 @@ TEST(TableTest, BlockCacheTest) {
// Only data block will be accessed
// Only data block will be accessed
{
{
iter - > SeekToFirst ( ) ;
iter - > SeekToFirst ( ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
props . AssertEqual (
props . AssertEqual (
1 ,
1 ,
1 ,
1 ,
@ -1034,7 +1034,7 @@ TEST(TableTest, BlockCacheTest) {
{
{
iter . reset ( c . NewIterator ( ) ) ;
iter . reset ( c . NewIterator ( ) ) ;
iter - > SeekToFirst ( ) ;
iter - > SeekToFirst ( ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
props . AssertEqual (
props . AssertEqual (
1 ,
1 ,
1 + 1 , // index block hit
1 + 1 , // index block hit
@ -1054,7 +1054,7 @@ TEST(TableTest, BlockCacheTest) {
iter . reset ( c . NewIterator ( ) ) ;
iter . reset ( c . NewIterator ( ) ) ;
iter - > SeekToFirst ( ) ;
iter - > SeekToFirst ( ) ;
ASSERT_EQ ( " key " , iter - > key ( ) . ToString ( ) ) ;
ASSERT_EQ ( " key " , iter - > key ( ) . ToString ( ) ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
// Nothing is affected at all
// Nothing is affected at all
props . AssertEqual ( 0 , 0 , 0 , 0 ) ;
props . AssertEqual ( 0 , 0 , 0 , 0 ) ;
}
}
@ -1065,7 +1065,7 @@ TEST(TableTest, BlockCacheTest) {
options . block_cache = NewLRUCache ( 1 ) ;
options . block_cache = NewLRUCache ( 1 ) ;
c . Reopen ( options ) ;
c . Reopen ( options ) ;
{
{
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
props . AssertEqual (
props . AssertEqual (
1 , // index block miss
1 , // index block miss
0 ,
0 ,
@ -1080,7 +1080,7 @@ TEST(TableTest, BlockCacheTest) {
// It first cache index block then data block. But since the cache size
// It first cache index block then data block. But since the cache size
// is only 1, index block will be purged after data block is inserted.
// is only 1, index block will be purged after data block is inserted.
iter . reset ( c . NewIterator ( ) ) ;
iter . reset ( c . NewIterator ( ) ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
props . AssertEqual (
props . AssertEqual (
1 + 1 , // index block miss
1 + 1 , // index block miss
0 ,
0 ,
@ -1093,7 +1093,7 @@ TEST(TableTest, BlockCacheTest) {
// SeekToFirst() accesses data block. With similar reason, we expect data
// SeekToFirst() accesses data block. With similar reason, we expect data
// block's cache miss.
// block's cache miss.
iter - > SeekToFirst ( ) ;
iter - > SeekToFirst ( ) ;
BlockCacheProperties props ( options . statistics ) ;
BlockCacheProperties props ( options . statistics . get ( ) ) ;
props . AssertEqual (
props . AssertEqual (
2 ,
2 ,
0 ,
0 ,
@ -1268,7 +1268,7 @@ class MemTableTest { };
TEST ( MemTableTest , Simple ) {
TEST ( MemTableTest , Simple ) {
InternalKeyComparator cmp ( BytewiseComparator ( ) ) ;
InternalKeyComparator cmp ( BytewiseComparator ( ) ) ;
auto table_factory = std : : make_shared < SkipListFactory > ( ) ;
auto table_factory = std : : make_shared < SkipListFactory > ( ) ;
MemTable * memtable = new MemTable ( cmp , table_factory ) ;
MemTable * memtable = new MemTable ( cmp , table_factory . get ( ) ) ;
memtable - > Ref ( ) ;
memtable - > Ref ( ) ;
WriteBatch batch ;
WriteBatch batch ;
Options options ;
Options options ;