提交 c64ae05b 编写于 作者: I Islam AbdelRahman

Move TEST_NewInternalIterator to NewInternalIterator

Summary:
Long time ago we add InternalDumpCommand to ldb_tool https://reviews.facebook.net/D11517
This command is using TEST_NewInternalIterator although it's not a test. This patch move TEST_NewInternalIterator outside of db_impl_debug.cc

Test Plan:
make check
make static_lib

Reviewers: yhchiang, igor, sdong

Reviewed By: sdong

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D48561
上级 0be50ed1
...@@ -228,7 +228,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) { ...@@ -228,7 +228,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) {
Arena arena; Arena arena;
{ {
ScopedArenaIterator iter( ScopedArenaIterator iter(
dbfull()->TEST_NewInternalIterator(&arena, handles_[1])); dbfull()->NewInternalIterator(&arena, handles_[1]));
iter->SeekToFirst(); iter->SeekToFirst();
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
while (iter->Valid()) { while (iter->Valid()) {
...@@ -316,7 +316,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) { ...@@ -316,7 +316,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilter) {
count = 0; count = 0;
{ {
ScopedArenaIterator iter( ScopedArenaIterator iter(
dbfull()->TEST_NewInternalIterator(&arena, handles_[1])); dbfull()->NewInternalIterator(&arena, handles_[1]));
iter->SeekToFirst(); iter->SeekToFirst();
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
while (iter->Valid()) { while (iter->Valid()) {
...@@ -533,7 +533,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) { ...@@ -533,7 +533,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextManual) {
int count = 0; int count = 0;
int total = 0; int total = 0;
Arena arena; Arena arena;
ScopedArenaIterator iter(dbfull()->TEST_NewInternalIterator(&arena)); ScopedArenaIterator iter(dbfull()->NewInternalIterator(&arena));
iter->SeekToFirst(); iter->SeekToFirst();
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
while (iter->Valid()) { while (iter->Valid()) {
......
...@@ -3306,6 +3306,23 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family, ...@@ -3306,6 +3306,23 @@ Status DBImpl::AddFile(ColumnFamilyHandle* column_family,
} }
return status; 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<ColumnFamilyHandleImpl*>(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 #endif // ROCKSDB_LITE
Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options, Status DBImpl::CreateColumnFamily(const ColumnFamilyOptions& cf_options,
......
...@@ -248,6 +248,12 @@ class DBImpl : public DB { ...@@ -248,6 +248,12 @@ class DBImpl : public DB {
const Slice* begin, const Slice* end, const Slice* begin, const Slice* end,
bool disallow_trivial_move = false); 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 #ifndef ROCKSDB_LITE
// Extra methods (for testing) that are not in the public DB interface // Extra methods (for testing) that are not in the public DB interface
// Implemented in db_impl_debug.cc // Implemented in db_impl_debug.cc
...@@ -266,12 +272,6 @@ class DBImpl : public DB { ...@@ -266,12 +272,6 @@ class DBImpl : public DB {
// Wait for any compaction // Wait for any compaction
Status TEST_WaitForCompact(); 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 // Return the maximum overlapping data (in bytes) at next level for any
// file at a level >= 1. // file at a level >= 1.
int64_t TEST_MaxNextLevelOverlappingBytes(ColumnFamilyHandle* column_family = int64_t TEST_MaxNextLevelOverlappingBytes(ColumnFamilyHandle* column_family =
......
...@@ -19,23 +19,6 @@ uint64_t DBImpl::TEST_GetLevel0TotalSize() { ...@@ -19,23 +19,6 @@ uint64_t DBImpl::TEST_GetLevel0TotalSize() {
return default_cf_handle_->cfd()->current()->storage_info()->NumLevelBytes(0); 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<ColumnFamilyHandleImpl*>(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( int64_t DBImpl::TEST_MaxNextLevelOverlappingBytes(
ColumnFamilyHandle* column_family) { ColumnFamilyHandle* column_family) {
ColumnFamilyData* cfd; ColumnFamilyData* cfd;
......
...@@ -552,9 +552,9 @@ std::string DBTestBase::AllEntriesFor(const Slice& user_key, int cf) { ...@@ -552,9 +552,9 @@ std::string DBTestBase::AllEntriesFor(const Slice& user_key, int cf) {
Arena arena; Arena arena;
ScopedArenaIterator iter; ScopedArenaIterator iter;
if (cf == 0) { if (cf == 0) {
iter.set(dbfull()->TEST_NewInternalIterator(&arena)); iter.set(dbfull()->NewInternalIterator(&arena));
} else { } else {
iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf])); iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf]));
} }
InternalKey target(user_key, kMaxSequenceNumber, kTypeValue); InternalKey target(user_key, kMaxSequenceNumber, kTypeValue);
iter->Seek(target.Encode()); iter->Seek(target.Encode());
...@@ -934,9 +934,9 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) { ...@@ -934,9 +934,9 @@ void DBTestBase::validateNumberOfEntries(int numValues, int cf) {
ScopedArenaIterator iter; ScopedArenaIterator iter;
Arena arena; Arena arena;
if (cf != 0) { if (cf != 0) {
iter.set(dbfull()->TEST_NewInternalIterator(&arena, handles_[cf])); iter.set(dbfull()->NewInternalIterator(&arena, handles_[cf]));
} else { } else {
iter.set(dbfull()->TEST_NewInternalIterator(&arena)); iter.set(dbfull()->NewInternalIterator(&arena));
} }
iter->SeekToFirst(); iter->SeekToFirst();
ASSERT_EQ(iter->status().ok(), true); ASSERT_EQ(iter->status().ok(), true);
......
...@@ -809,7 +809,7 @@ void InternalDumpCommand::DoCommand() { ...@@ -809,7 +809,7 @@ void InternalDumpCommand::DoCommand() {
uint64_t s1=0,s2=0; uint64_t s1=0,s2=0;
// Setup internal key iterator // Setup internal key iterator
Arena arena; Arena arena;
ScopedArenaIterator iter(idb->TEST_NewInternalIterator(&arena)); ScopedArenaIterator iter(idb->NewInternalIterator(&arena));
Status st = iter->status(); Status st = iter->status();
if (!st.ok()) { if (!st.ok()) {
exec_state_ = exec_state_ =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册