@ -27,6 +27,7 @@
# include "util/logging.h"
# include "util/logging.h"
# include "util/mutexlock.h"
# include "util/mutexlock.h"
# include "util/string_util.h"
# include "util/string_util.h"
# include "util/trace_replay.h"
namespace rocksdb {
namespace rocksdb {
@ -114,7 +115,8 @@ class DBIter final: public Iterator {
const MutableCFOptions & mutable_cf_options , const Comparator * cmp ,
const MutableCFOptions & mutable_cf_options , const Comparator * cmp ,
InternalIterator * iter , SequenceNumber s , bool arena_mode ,
InternalIterator * iter , SequenceNumber s , bool arena_mode ,
uint64_t max_sequential_skip_in_iterations ,
uint64_t max_sequential_skip_in_iterations ,
ReadCallback * read_callback , bool allow_blob )
ReadCallback * read_callback , DBImpl * db_impl , ColumnFamilyData * cfd ,
bool allow_blob )
: arena_mode_ ( arena_mode ) ,
: arena_mode_ ( arena_mode ) ,
env_ ( _env ) ,
env_ ( _env ) ,
logger_ ( cf_options . info_log ) ,
logger_ ( cf_options . info_log ) ,
@ -135,6 +137,8 @@ class DBIter final: public Iterator {
range_del_agg_ ( cf_options . internal_comparator , s ,
range_del_agg_ ( cf_options . internal_comparator , s ,
true /* collapse_deletions */ ) ,
true /* collapse_deletions */ ) ,
read_callback_ ( read_callback ) ,
read_callback_ ( read_callback ) ,
db_impl_ ( db_impl ) ,
cfd_ ( cfd ) ,
allow_blob_ ( allow_blob ) ,
allow_blob_ ( allow_blob ) ,
is_blob_ ( false ) ,
is_blob_ ( false ) ,
start_seqnum_ ( read_options . iter_start_seqnum ) {
start_seqnum_ ( read_options . iter_start_seqnum ) {
@ -344,6 +348,8 @@ class DBIter final: public Iterator {
LocalStatistics local_stats_ ;
LocalStatistics local_stats_ ;
PinnedIteratorsManager pinned_iters_mgr_ ;
PinnedIteratorsManager pinned_iters_mgr_ ;
ReadCallback * read_callback_ ;
ReadCallback * read_callback_ ;
DBImpl * db_impl_ ;
ColumnFamilyData * cfd_ ;
bool allow_blob_ ;
bool allow_blob_ ;
bool is_blob_ ;
bool is_blob_ ;
// for diff snapshots we want the lower bound on the seqnum;
// for diff snapshots we want the lower bound on the seqnum;
@ -1267,6 +1273,12 @@ void DBIter::Seek(const Slice& target) {
saved_key_ . Clear ( ) ;
saved_key_ . Clear ( ) ;
saved_key_ . SetInternalKey ( target , seq ) ;
saved_key_ . SetInternalKey ( target , seq ) ;
# ifndef ROCKSDB_LITE
if ( db_impl_ ! = nullptr & & cfd_ ! = nullptr ) {
db_impl_ - > TraceIteratorSeek ( cfd_ - > GetID ( ) , target ) ;
}
# endif // ROCKSDB_LITE
if ( iterate_lower_bound_ ! = nullptr & &
if ( iterate_lower_bound_ ! = nullptr & &
user_comparator_ - > Compare ( saved_key_ . GetUserKey ( ) ,
user_comparator_ - > Compare ( saved_key_ . GetUserKey ( ) ,
* iterate_lower_bound_ ) < 0 ) {
* iterate_lower_bound_ ) < 0 ) {
@ -1331,6 +1343,12 @@ void DBIter::SeekForPrev(const Slice& target) {
range_del_agg_ . InvalidateRangeDelMapPositions ( ) ;
range_del_agg_ . InvalidateRangeDelMapPositions ( ) ;
}
}
# ifndef ROCKSDB_LITE
if ( db_impl_ ! = nullptr & & cfd_ ! = nullptr ) {
db_impl_ - > TraceIteratorSeekForPrev ( cfd_ - > GetID ( ) , target ) ;
}
# endif // ROCKSDB_LITE
RecordTick ( statistics_ , NUMBER_DB_SEEK ) ;
RecordTick ( statistics_ , NUMBER_DB_SEEK ) ;
if ( iter_ - > Valid ( ) ) {
if ( iter_ - > Valid ( ) ) {
if ( prefix_extractor_ & & prefix_same_as_start_ ) {
if ( prefix_extractor_ & & prefix_same_as_start_ ) {
@ -1453,11 +1471,12 @@ Iterator* NewDBIterator(Env* env, const ReadOptions& read_options,
InternalIterator * internal_iter ,
InternalIterator * internal_iter ,
const SequenceNumber & sequence ,
const SequenceNumber & sequence ,
uint64_t max_sequential_skip_in_iterations ,
uint64_t max_sequential_skip_in_iterations ,
ReadCallback * read_callback , bool allow_blob ) {
ReadCallback * read_callback , DBImpl * db_impl ,
DBIter * db_iter =
ColumnFamilyData * cfd , bool allow_blob ) {
new DBIter ( env , read_options , cf_options , mutable_cf_options ,
DBIter * db_iter = new DBIter (
user_key_comparator , internal_iter , sequence , false ,
env , read_options , cf_options , mutable_cf_options , user_key_comparator ,
max_sequential_skip_in_iterations , read_callback , allow_blob ) ;
internal_iter , sequence , false , max_sequential_skip_in_iterations ,
read_callback , db_impl , cfd , allow_blob ) ;
return db_iter ;
return db_iter ;
}
}
@ -1504,13 +1523,14 @@ void ArenaWrappedDBIter::Init(Env* env, const ReadOptions& read_options,
const SequenceNumber & sequence ,
const SequenceNumber & sequence ,
uint64_t max_sequential_skip_in_iteration ,
uint64_t max_sequential_skip_in_iteration ,
uint64_t version_number ,
uint64_t version_number ,
ReadCallback * read_callback , bool allow_blob ,
ReadCallback * read_callback , DBImpl * db_impl ,
ColumnFamilyData * cfd , bool allow_blob ,
bool allow_refresh ) {
bool allow_refresh ) {
auto mem = arena_ . AllocateAligned ( sizeof ( DBIter ) ) ;
auto mem = arena_ . AllocateAligned ( sizeof ( DBIter ) ) ;
db_iter_ = new ( mem )
db_iter_ = new ( mem ) DBIter ( env , read_options , cf_options , mutable_cf_options ,
DBIter ( env , read_options , cf_options , mutable_cf_options ,
cf_options . user_comparator , nullptr , sequence ,
cf_options . user_comparator , nullptr , sequence , true ,
true , max_sequential_skip_in_iteration ,
max_sequential_skip_in_iteration , read_callback , allow_blob ) ;
read_callback , db_impl , cfd , allow_blob ) ;
sv_number_ = version_number ;
sv_number_ = version_number ;
allow_refresh_ = allow_refresh ;
allow_refresh_ = allow_refresh ;
}
}
@ -1534,7 +1554,8 @@ Status ArenaWrappedDBIter::Refresh() {
SuperVersion * sv = cfd_ - > GetReferencedSuperVersion ( db_impl_ - > mutex ( ) ) ;
SuperVersion * sv = cfd_ - > GetReferencedSuperVersion ( db_impl_ - > mutex ( ) ) ;
Init ( env , read_options_ , * ( cfd_ - > ioptions ( ) ) , sv - > mutable_cf_options ,
Init ( env , read_options_ , * ( cfd_ - > ioptions ( ) ) , sv - > mutable_cf_options ,
latest_seq , sv - > mutable_cf_options . max_sequential_skip_in_iterations ,
latest_seq , sv - > mutable_cf_options . max_sequential_skip_in_iterations ,
cur_sv_number , read_callback_ , allow_blob_ , allow_refresh_ ) ;
cur_sv_number , read_callback_ , db_impl_ , cfd_ , allow_blob_ ,
allow_refresh_ ) ;
InternalIterator * internal_iter = db_impl_ - > NewInternalIterator (
InternalIterator * internal_iter = db_impl_ - > NewInternalIterator (
read_options_ , cfd_ , sv , & arena_ , db_iter_ - > GetRangeDelAggregator ( ) ) ;
read_options_ , cfd_ , sv , & arena_ , db_iter_ - > GetRangeDelAggregator ( ) ) ;
@ -1556,7 +1577,7 @@ ArenaWrappedDBIter* NewArenaWrappedDbIterator(
ArenaWrappedDBIter * iter = new ArenaWrappedDBIter ( ) ;
ArenaWrappedDBIter * iter = new ArenaWrappedDBIter ( ) ;
iter - > Init ( env , read_options , cf_options , mutable_cf_options , sequence ,
iter - > Init ( env , read_options , cf_options , mutable_cf_options , sequence ,
max_sequential_skip_in_iterations , version_number , read_callback ,
max_sequential_skip_in_iterations , version_number , read_callback ,
allow_blob , allow_refresh ) ;
db_impl , cfd , allow_blob , allow_refresh ) ;
if ( db_impl ! = nullptr & & cfd ! = nullptr & & allow_refresh ) {
if ( db_impl ! = nullptr & & cfd ! = nullptr & & allow_refresh ) {
iter - > StoreRefreshInfo ( read_options , db_impl , cfd , read_callback ,
iter - > StoreRefreshInfo ( read_options , db_impl , cfd , read_callback ,
allow_blob ) ;
allow_blob ) ;