@ -265,11 +265,12 @@ class LocalSavePoint {
# endif
# endif
} ;
} ;
template < typename Derived , typename Checker >
template < typename Derived >
class TimestampAssignerBase : public WriteBatch : : Handler {
class TimestampAssignerBase : public WriteBatch : : Handler {
public :
public :
explicit TimestampAssignerBase ( WriteBatch : : ProtectionInfo * prot_info ,
explicit TimestampAssignerBase (
Checker & & checker )
WriteBatch : : ProtectionInfo * prot_info ,
std : : function < Status ( uint32_t , size_t & ) > & & checker )
: prot_info_ ( prot_info ) , checker_ ( std : : move ( checker ) ) { }
: prot_info_ ( prot_info ) , checker_ ( std : : move ( checker ) ) { }
~ TimestampAssignerBase ( ) override { }
~ TimestampAssignerBase ( ) override { }
@ -360,27 +361,25 @@ class TimestampAssignerBase : public WriteBatch::Handler {
TimestampAssignerBase & operator = ( TimestampAssignerBase & & ) = delete ;
TimestampAssignerBase & operator = ( TimestampAssignerBase & & ) = delete ;
WriteBatch : : ProtectionInfo * const prot_info_ = nullptr ;
WriteBatch : : ProtectionInfo * const prot_info_ = nullptr ;
const Checker checker_ { } ;
const std : : function < Status ( uint32_t , size_t & ) > checker_ { } ;
size_t idx_ = 0 ;
size_t idx_ = 0 ;
} ;
} ;
template < typename Checker >
class SimpleListTimestampAssigner
class SimpleListTimestampAssigner
: public TimestampAssignerBase < SimpleListTimestampAssigner < Checker > ,
: public TimestampAssignerBase < SimpleListTimestampAssigner > {
Checker > {
public :
public :
explicit SimpleListTimestampAssigner ( WriteBatch : : ProtectionInfo * prot_info ,
explicit SimpleListTimestampAssigner (
Checker checker ,
WriteBatch : : ProtectionInfo * prot_info ,
std : : function < Status ( uint32_t , size_t & ) > & & checker ,
const std : : vector < Slice > & timestamps )
const std : : vector < Slice > & timestamps )
: TimestampAssignerBase < SimpleListTimestampAssigner < Checker > , Checker > (
: TimestampAssignerBase < SimpleListTimestampAssigner > ( prot_info ,
prot_info , std : : move ( checker ) ) ,
std : : move ( checker ) ) ,
timestamps_ ( timestamps ) { }
timestamps_ ( timestamps ) { }
~ SimpleListTimestampAssigner ( ) override { }
~ SimpleListTimestampAssigner ( ) override { }
private :
private :
friend class TimestampAssignerBase < SimpleListTimestampAssigner < Checker > ,
friend class TimestampAssignerBase < SimpleListTimestampAssigner > ;
Checker > ;
Status AssignTimestampImpl ( uint32_t cf , const Slice & key , size_t idx ) {
Status AssignTimestampImpl ( uint32_t cf , const Slice & key , size_t idx ) {
if ( idx > = timestamps_ . size ( ) ) {
if ( idx > = timestamps_ . size ( ) ) {
@ -398,21 +397,19 @@ class SimpleListTimestampAssigner
const std : : vector < Slice > & timestamps_ ;
const std : : vector < Slice > & timestamps_ ;
} ;
} ;
template < typename Checker >
class TimestampAssigner : public TimestampAssignerBase < TimestampAssigner > {
class TimestampAssigner
: public TimestampAssignerBase < TimestampAssigner < Checker > , Checker > {
public :
public :
explicit TimestampAssigner ( WriteBatch : : ProtectionInfo * prot_info ,
explicit TimestampAssigner ( WriteBatch : : ProtectionInfo * prot_info ,
Checker checker , const Slice & ts )
std : : function < Status ( uint32_t , size_t & ) > & & checker ,
: TimestampAssignerBase < TimestampAssigner < Checker > , Checker > (
const Slice & ts )
prot_info , std : : move ( checker ) ) ,
: TimestampAssignerBase < TimestampAssigner > ( prot_info , std : : move ( checker ) ) ,
timestamp_ ( ts ) {
timestamp_ ( ts ) {
assert ( ! timestamp_ . empty ( ) ) ;
assert ( ! timestamp_ . empty ( ) ) ;
}
}
~ TimestampAssigner ( ) override { }
~ TimestampAssigner ( ) override { }
private :
private :
friend class TimestampAssignerBase < TimestampAssigner < Checker > , Checker > ;
friend class TimestampAssignerBase < TimestampAssigner > ;
Status AssignTimestampImpl ( uint32_t cf , const Slice & key , size_t /*idx*/ ) {
Status AssignTimestampImpl ( uint32_t cf , const Slice & key , size_t /*idx*/ ) {
if ( timestamp_ . empty ( ) ) {
if ( timestamp_ . empty ( ) ) {
@ -429,18 +426,4 @@ class TimestampAssigner
const Slice timestamp_ ;
const Slice timestamp_ ;
} ;
} ;
template < typename Checker >
Status WriteBatch : : AssignTimestamp ( const Slice & ts , Checker checker ) {
TimestampAssigner < Checker > ts_assigner ( prot_info_ . get ( ) , checker , ts ) ;
return Iterate ( & ts_assigner ) ;
}
template < typename Checker >
Status WriteBatch : : AssignTimestamps ( const std : : vector < Slice > & ts_list ,
Checker checker ) {
SimpleListTimestampAssigner < Checker > ts_assigner ( prot_info_ . get ( ) , checker ,
ts_list ) ;
return Iterate ( & ts_assigner ) ;
}
} // namespace ROCKSDB_NAMESPACE
} // namespace ROCKSDB_NAMESPACE