diff --git a/db/db_compaction_filter_test.cc b/db/db_compaction_filter_test.cc index a48c86516..f7ca952a8 100644 --- a/db/db_compaction_filter_test.cc +++ b/db/db_compaction_filter_test.cc @@ -228,7 +228,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) { Arena arena; { ScopedArenaIterator iter( - dbfull()->TEST_NewInternalIterator(&arena, handles_[1])); + dbfull()->NewInternalIterator(&arena, handles_[1])); iter->SeekToFirst(); ASSERT_OK(iter->status()); while (iter->Valid()) { @@ -316,7 +316,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) { count = 0; { ScopedArenaIterator iter( - dbfull()->TEST_NewInternalIterator(&arena, handles_[1])); + dbfull()->NewInternalIterator(&arena, handles_[1])); iter->SeekToFirst(); ASSERT_OK(iter->status()); while (iter->Valid()) { @@ -533,7 +533,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) { int count = 0; int total = 0; Arena arena; - ScopedArenaIterator iter(dbfull()->TEST_NewInternalIterator(&arena)); + ScopedArenaIterator iter(dbfull()->NewInternalIterator(&arena)); iter->SeekToFirst(); ASSERT_OK(iter->status()); while (iter->Valid()) { diff --git a/db/db_impl.cc b/db/db_impl.cc index c8f6fdd52..f54384cd5 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3306,6 +3306,23 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family, } return status; } + +Iterator* DBImpl::NewInternalIterator(Arena* arena, + ColumnFamilyHandle* column_family) { + ColumnFamilyData* cfd; + if (column_family == nullptr) { + cfd = default_cf_handle_->cfd(); + } else { + auto cfh = reinterpret_cast(column_family); + cfd = cfh->cfd(); + } + + mutex_.Lock(); + SuperVersion* super_version = cfd->GetSuperVersion()->Ref(); + mutex_.Unlock(); + ReadOptions roptions; + return NewInternalIterator(roptions, cfd, super_version, arena); +} #endif // ROCKSDB_LITE Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options, diff --git a/db/db_impl.h b/db/db_impl.h index 35558773e..4db0cd069 100644 --- a/db/db_impl.h +++ b/db/db_impl.h @@ -248,6 +248,12 @@ class DBImpl : public DB { const Slice* begin, const Slice* end, bool disallow_trivial_move = false); + // Return an internal iterator over the current state of the database. + // The keys of this iterator are internal keys (see format.h). + // The returned iterator should be deleted when no longer needed. + Iterator* NewInternalIterator(Arena* arena, + ColumnFamilyHandle* column_family = nullptr); + #ifndef ROCKSDB_LITE // Extra methods (for testing) that are not in the public DB interface // Implemented in db_impl_debug.cc @@ -266,12 +272,6 @@ class DBImpl : public DB { // Wait for any compaction Status TEST_WaitForCompact(); - // Return an internal iterator over the current state of the database. - // The keys of this iterator are internal keys (see format.h). - // The returned iterator should be deleted when no longer needed. - Iterator* TEST_NewInternalIterator( - Arena* arena, ColumnFamilyHandle* column_family = nullptr); - // Return the maximum overlapping data (in bytes) at next level for any // file at a level >= 1. int64_t TEST_MaxNextLevelOverlappingBytes(ColumnFamilyHandle* column_family = diff --git a/db/db_impl_debug.cc b/db/db_impl_debug.cc index dc40fefc6..ee437ea2b 100644 --- a/db/db_impl_debug.cc +++ b/db/db_impl_debug.cc @@ -19,23 +19,6 @@ uint64_t DBImpl::TEST_GetLevel0TotalSize() { return default_cf_handle_->cfd()->current()->storage_info()->NumLevelBytes(0); } -Iterator* DBImpl::TEST_NewInternalIterator(Arena* arena, - ColumnFamilyHandle* column_family) { - ColumnFamilyData* cfd; - if (column_family == nullptr) { - cfd = default_cf_handle_->cfd(); - } else { - auto cfh = reinterpret_cast(column_family); - cfd = cfh->cfd(); - } - - mutex_.Lock(); - SuperVersion* super_version = cfd->GetSuperVersion()->Ref(); - mutex_.Unlock(); - ReadOptions roptions; - return NewInternalIterator(roptions, cfd, super_version, arena); -} - int64_t DBImpl::TEST_MaxNextLevelOverlappingBytes( ColumnFamilyHandle* column_family) { ColumnFamilyData* cfd; diff --git a/db/db_test_util.cc b/db/db_test_util.cc index b545f2104..4b7dd26db 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -552,9 +552,9 @@ std::string DBTestBase::AllEntriesFor(const Slice& user_key, int cf) { Arena arena; ScopedArenaIterator iter; if (cf == 0) { - iter.set(dbfull()->TEST_NewInternalIterator(&arena)); + iter.set(dbfull()->NewInternalIterator(&arena)); } else { - iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf])); + iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf])); } InternalKey target(user_key, kMaxSequenceNumber, kTypeValue); iter->Seek(target.Encode()); @@ -934,9 +934,9 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) { ScopedArenaIterator iter; Arena arena; if (cf != 0) { - iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf])); + iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf])); } else { - iter.set(dbfull()->TEST_NewInternalIterator(&arena)); + iter.set(dbfull()->NewInternalIterator(&arena)); } iter->SeekToFirst(); ASSERT_EQ(iter->status().ok(), true); diff --git a/util/ldb_cmd.cc b/util/ldb_cmd.cc index a441d7167..dfd4c1945 100644 --- a/util/ldb_cmd.cc +++ b/util/ldb_cmd.cc @@ -809,7 +809,7 @@ void InternalDumpCommand::DoCommand() { uint64_t s1=0,s2=0; // Setup internal key iterator Arena arena; - ScopedArenaIterator iter(idb->TEST_NewInternalIterator(&arena)); + ScopedArenaIterator iter(idb->NewInternalIterator(&arena)); Status st = iter->status(); if (!st.ok()) { exec_state_ =