@ -20,7 +20,8 @@ namespace {
class HashSkipListRep : public MemTableRep {
class HashSkipListRep : public MemTableRep {
public :
public :
HashSkipListRep ( MemTableRep : : KeyComparator & compare , Arena * arena ,
HashSkipListRep ( MemTableRep : : KeyComparator & compare , Arena * arena ,
const SliceTransform * transform , size_t bucket_size ) ;
const SliceTransform * transform , size_t bucket_size ,
int32_t skiplist_height , int32_t skiplist_branching_factor ) ;
virtual void Insert ( const char * key ) override ;
virtual void Insert ( const char * key ) override ;
@ -47,6 +48,9 @@ class HashSkipListRep : public MemTableRep {
size_t bucket_size_ ;
size_t bucket_size_ ;
const int32_t skiplist_height_ ;
const int32_t skiplist_branching_factor_ ;
// Maps slices (which are transformed user keys) to buckets of keys sharing
// Maps slices (which are transformed user keys) to buckets of keys sharing
// the same transform.
// the same transform.
port : : AtomicPointer * buckets_ ;
port : : AtomicPointer * buckets_ ;
@ -215,8 +219,12 @@ class HashSkipListRep : public MemTableRep {
} ;
} ;
HashSkipListRep : : HashSkipListRep ( MemTableRep : : KeyComparator & compare ,
HashSkipListRep : : HashSkipListRep ( MemTableRep : : KeyComparator & compare ,
Arena * arena , const SliceTransform * transform , size_t bucket_size )
Arena * arena , const SliceTransform * transform ,
size_t bucket_size , int32_t skiplist_height ,
int32_t skiplist_branching_factor )
: bucket_size_ ( bucket_size ) ,
: bucket_size_ ( bucket_size ) ,
skiplist_height_ ( skiplist_height ) ,
skiplist_branching_factor_ ( skiplist_branching_factor ) ,
transform_ ( transform ) ,
transform_ ( transform ) ,
compare_ ( compare ) ,
compare_ ( compare ) ,
arena_ ( arena ) ,
arena_ ( arena ) ,
@ -239,7 +247,8 @@ HashSkipListRep::Bucket* HashSkipListRep::GetInitializedBucket(
auto bucket = GetBucket ( hash ) ;
auto bucket = GetBucket ( hash ) ;
if ( bucket = = nullptr ) {
if ( bucket = = nullptr ) {
auto addr = arena_ - > AllocateAligned ( sizeof ( Bucket ) ) ;
auto addr = arena_ - > AllocateAligned ( sizeof ( Bucket ) ) ;
bucket = new ( addr ) Bucket ( compare_ , arena_ ) ;
bucket = new ( addr ) Bucket ( compare_ , arena_ , skiplist_height_ ,
skiplist_branching_factor_ ) ;
buckets_ [ hash ] . Release_Store ( static_cast < void * > ( bucket ) ) ;
buckets_ [ hash ] . Release_Store ( static_cast < void * > ( bucket ) ) ;
}
}
return bucket ;
return bucket ;
@ -302,17 +311,23 @@ std::shared_ptr<MemTableRep::Iterator>
class HashSkipListRepFactory : public MemTableRepFactory {
class HashSkipListRepFactory : public MemTableRepFactory {
public :
public :
explicit HashSkipListRepFactory ( const SliceTransform * transform ,
explicit HashSkipListRepFactory (
size_t bucket_count = 1000000 )
const SliceTransform * transform ,
: transform_ ( transform ) ,
size_t bucket_count ,
bucket_count_ ( bucket_count ) { }
int32_t skiplist_height ,
int32_t skiplist_branching_factor )
: transform_ ( transform ) ,
bucket_count_ ( bucket_count ) ,
skiplist_height_ ( skiplist_height ) ,
skiplist_branching_factor_ ( skiplist_branching_factor ) { }
virtual ~ HashSkipListRepFactory ( ) { delete transform_ ; }
virtual ~ HashSkipListRepFactory ( ) { delete transform_ ; }
virtual std : : shared_ptr < MemTableRep > CreateMemTableRep (
virtual std : : shared_ptr < MemTableRep > CreateMemTableRep (
MemTableRep : : KeyComparator & compare , Arena * arena ) override {
MemTableRep : : KeyComparator & compare , Arena * arena ) override {
return std : : make_shared < HashSkipListRep > ( compare , arena , transform_ ,
return std : : make_shared < HashSkipListRep > ( compare , arena , transform_ ,
bucket_count_ ) ;
bucket_count_ , skiplist_height_ ,
skiplist_branching_factor_ ) ;
}
}
virtual const char * Name ( ) const override {
virtual const char * Name ( ) const override {
@ -324,11 +339,15 @@ class HashSkipListRepFactory : public MemTableRepFactory {
private :
private :
const SliceTransform * transform_ ;
const SliceTransform * transform_ ;
const size_t bucket_count_ ;
const size_t bucket_count_ ;
const int32_t skiplist_height_ ;
const int32_t skiplist_branching_factor_ ;
} ;
} ;
MemTableRepFactory * NewHashSkipListRepFactory (
MemTableRepFactory * NewHashSkipListRepFactory (
const SliceTransform * transform , size_t bucket_count ) {
const SliceTransform * transform , size_t bucket_count ,
return new HashSkipListRepFactory ( transform , bucket_count ) ;
int32_t skiplist_height , int32_t skiplist_branching_factor ) {
return new HashSkipListRepFactory ( transform , bucket_count ,
skiplist_height , skiplist_branching_factor ) ;
}
}
} // namespace rocksdb
} // namespace rocksdb