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
main
Islam AbdelRahman 9 years ago
parent 0be50ed12c
commit c64ae05b1c
  1. 6
      db/db_compaction_filter_test.cc
  2. 17
      db/db_impl.cc
  3. 12
      db/db_impl.h
  4. 17
      db/db_impl_debug.cc
  5. 8
      db/db_test_util.cc
  6. 2
      util/ldb_cmd.cc

@ -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) {
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) {
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,
} }
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 {
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 {
// 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() {
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) {
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) {
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() {
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_ =

Loading…
Cancel
Save