@ -3214,12 +3214,12 @@ Iterator* DBImpl::NewIterator(const ReadOptions& options,
SuperVersion * super_version = nullptr ;
SuperVersion * super_version = nullptr ;
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
auto cfd = cfh - > cfd ( ) ;
auto cfd = cfh - > cfd ( ) ;
mutex_ . Lock ( ) ;
if ( ! options . tailing ) {
if ( ! options . tailing ) {
mutex_ . Lock ( ) ;
super_version = cfd - > GetSuperVersion ( ) - > Ref ( ) ;
super_version = cfd - > GetSuperVersion ( ) - > Ref ( ) ;
latest_snapshot = versions_ - > LastSequence ( ) ;
latest_snapshot = versions_ - > LastSequence ( ) ;
mutex_ . Unlock ( ) ;
}
}
mutex_ . Unlock ( ) ;
Iterator * iter ;
Iterator * iter ;
if ( options . tailing ) {
if ( options . tailing ) {
@ -3227,11 +3227,12 @@ Iterator* DBImpl::NewIterator(const ReadOptions& options,
} else {
} else {
iter = NewInternalIterator ( options , cfd , super_version ) ;
iter = NewInternalIterator ( options , cfd , super_version ) ;
iter = NewDBIterator (
auto snapshot =
& dbname_ , env_ , * cfd - > full_options ( ) , cfd - > user_comparator ( ) , iter ,
options . snapshot ! = nullptr
( options . snapshot ! = nullptr
? reinterpret_cast < const SnapshotImpl * > ( options . snapshot ) - > number_
? reinterpret_cast < const SnapshotImpl * > ( options . snapshot ) - > number_
: latest_snapshot ;
: latest_snapshot ) ) ;
iter = NewDBIterator ( & dbname_ , env_ , * cfd - > full_options ( ) ,
cfd - > user_comparator ( ) , iter , snapshot ) ;
}
}
if ( options . prefix ) {
if ( options . prefix ) {
@ -3245,10 +3246,53 @@ Iterator* DBImpl::NewIterator(const ReadOptions& options,
Status DBImpl : : NewIterators (
Status DBImpl : : NewIterators (
const ReadOptions & options ,
const ReadOptions & options ,
const std : : vector < ColumnFamilyHandle * > & column_family ,
const std : : vector < ColumnFamilyHandle * > & column_families ,
std : : vector < Iterator * > * iterators ) {
std : : vector < Iterator * > * iterators ) {
// TODO(icanadi)
return Status : : NotSupported ( " Not yet! " ) ;
if ( options . prefix ) {
return Status : : NotSupported (
" NewIterators doesn't support ReadOptions::prefix " ) ;
}
iterators - > clear ( ) ;
iterators - > reserve ( column_families . size ( ) ) ;
SequenceNumber latest_snapshot = 0 ;
std : : vector < SuperVersion * > super_versions ;
super_versions . reserve ( column_families . size ( ) ) ;
if ( ! options . tailing ) {
mutex_ . Lock ( ) ;
latest_snapshot = versions_ - > LastSequence ( ) ;
for ( auto cfh : column_families ) {
auto cfd = reinterpret_cast < ColumnFamilyHandleImpl * > ( cfh ) - > cfd ( ) ;
super_versions . push_back ( cfd - > GetSuperVersion ( ) - > Ref ( ) ) ;
}
mutex_ . Unlock ( ) ;
}
if ( options . tailing ) {
for ( auto cfh : column_families ) {
auto cfd = reinterpret_cast < ColumnFamilyHandleImpl * > ( cfh ) - > cfd ( ) ;
iterators - > push_back ( new TailingIterator ( this , options , cfd ) ) ;
}
} else {
for ( size_t i = 0 ; i < column_families . size ( ) ; + + i ) {
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_families [ i ] ) ;
auto cfd = cfh - > cfd ( ) ;
auto snapshot =
options . snapshot ! = nullptr
? reinterpret_cast < const SnapshotImpl * > ( options . snapshot ) - > number_
: latest_snapshot ;
auto iter = NewInternalIterator ( options , cfd , super_versions [ i ] ) ;
iter = NewDBIterator ( & dbname_ , env_ , * cfd - > full_options ( ) ,
cfd - > user_comparator ( ) , iter , snapshot ) ;
iterators - > push_back ( iter ) ;
}
}
return Status : : OK ( ) ;
}
}
const Snapshot * DBImpl : : GetSnapshot ( ) {
const Snapshot * DBImpl : : GetSnapshot ( ) {