diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/autocompact_test.cc | 5 | ||||
-rw-r--r-- | db/corruption_test.cc | 5 | ||||
-rw-r--r-- | db/db_test.cc | 69 | ||||
-rw-r--r-- | db/dbformat_test.cc | 5 | ||||
-rw-r--r-- | db/fault_injection_test.cc | 5 | ||||
-rw-r--r-- | db/filename_test.cc | 5 | ||||
-rw-r--r-- | db/log_test.cc | 5 | ||||
-rw-r--r-- | db/recovery_test.cc | 7 | ||||
-rw-r--r-- | db/skiplist.h | 2 | ||||
-rw-r--r-- | db/skiplist_test.cc | 5 | ||||
-rw-r--r-- | db/snapshot.h | 2 | ||||
-rw-r--r-- | db/table_cache.h | 4 | ||||
-rw-r--r-- | db/version_edit_test.cc | 5 | ||||
-rw-r--r-- | db/version_set.cc | 7 | ||||
-rw-r--r-- | db/version_set.h | 6 | ||||
-rw-r--r-- | db/version_set_test.cc | 5 | ||||
-rw-r--r-- | db/write_batch_test.cc | 5 |
17 files changed, 14 insertions, 133 deletions
diff --git a/db/autocompact_test.cc b/db/autocompact_test.cc index 3b7241b..69341e3 100644 --- a/db/autocompact_test.cc +++ b/db/autocompact_test.cc @@ -108,8 +108,3 @@ TEST_F(AutoCompactTest, ReadAll) { DoReads(kCount); } TEST_F(AutoCompactTest, ReadHalf) { DoReads(kCount / 2); } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/corruption_test.cc b/db/corruption_test.cc index a31f448..dc7da76 100644 --- a/db/corruption_test.cc +++ b/db/corruption_test.cc @@ -360,8 +360,3 @@ TEST_F(CorruptionTest, UnrelatedKeys) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/db_test.cc b/db/db_test.cc index 908b41d..9bd6e14 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -9,7 +9,6 @@ #include <string> #include "gtest/gtest.h" -#include "benchmark/benchmark.h" #include "db/db_impl.h" #include "db/filename.h" #include "db/version_set.h" @@ -2295,72 +2294,4 @@ TEST_F(DBTest, Randomized) { } while (ChangeOptions()); } -std::string MakeKey(unsigned int num) { - char buf[30]; - std::snprintf(buf, sizeof(buf), "%016u", num); - return std::string(buf); -} - -static void BM_LogAndApply(benchmark::State& state) { - const int num_base_files = state.range(0); - - std::string dbname = testing::TempDir() + "leveldb_test_benchmark"; - DestroyDB(dbname, Options()); - - DB* db = nullptr; - Options opts; - opts.create_if_missing = true; - Status s = DB::Open(opts, dbname, &db); - ASSERT_LEVELDB_OK(s); - ASSERT_TRUE(db != nullptr); - - delete db; - db = nullptr; - - Env* env = Env::Default(); - - port::Mutex mu; - MutexLock l(&mu); - - InternalKeyComparator cmp(BytewiseComparator()); - Options options; - VersionSet vset(dbname, &options, nullptr, &cmp); - bool save_manifest; - ASSERT_LEVELDB_OK(vset.Recover(&save_manifest)); - VersionEdit vbase; - uint64_t fnum = 1; - for (int i = 0; i < num_base_files; i++) { - InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); - InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); - vbase.AddFile(2, fnum++, 1 /* file size */, start, limit); - } - ASSERT_LEVELDB_OK(vset.LogAndApply(&vbase, &mu)); - - uint64_t start_micros = env->NowMicros(); - - for (auto st : state) { - VersionEdit vedit; - vedit.RemoveFile(2, fnum); - InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); - InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); - vedit.AddFile(2, fnum++, 1 /* file size */, start, limit); - vset.LogAndApply(&vedit, &mu); - } - uint64_t stop_micros = env->NowMicros(); - unsigned int us = stop_micros - start_micros; - char buf[16]; - std::snprintf(buf, sizeof(buf), "%d", num_base_files); - std::fprintf(stderr, - "BM_LogAndApply/%-6s %8" PRIu64 - " iters : %9u us (%7.0f us / iter)\n", - buf, state.iterations(), us, ((float)us) / state.iterations()); -} - -BENCHMARK(BM_LogAndApply)->Arg(1)->Arg(100)->Arg(10000)->Arg(100000); } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); - return RUN_ALL_TESTS(); -} diff --git a/db/dbformat_test.cc b/db/dbformat_test.cc index 4a11c4a..7f3f81a 100644 --- a/db/dbformat_test.cc +++ b/db/dbformat_test.cc @@ -126,8 +126,3 @@ TEST(FormatTest, InternalKeyDebugString) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/fault_injection_test.cc b/db/fault_injection_test.cc index 6eebafa..ef864a4 100644 --- a/db/fault_injection_test.cc +++ b/db/fault_injection_test.cc @@ -548,8 +548,3 @@ TEST_F(FaultInjectionTest, FaultTestWithLogReuse) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/filename_test.cc b/db/filename_test.cc index f291d72..9ac0111 100644 --- a/db/filename_test.cc +++ b/db/filename_test.cc @@ -125,8 +125,3 @@ TEST(FileNameTest, Construction) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/log_test.cc b/db/log_test.cc index 346b19c..d55d4dd 100644 --- a/db/log_test.cc +++ b/db/log_test.cc @@ -556,8 +556,3 @@ TEST_F(LogTest, ReadPastEnd) { CheckOffsetPastEndReturnsNoRecords(5); } } // namespace log } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/recovery_test.cc b/db/recovery_test.cc index 3db817e..1d9f621 100644 --- a/db/recovery_test.cc +++ b/db/recovery_test.cc @@ -18,7 +18,7 @@ namespace leveldb { class RecoveryTest : public testing::Test { public: RecoveryTest() : env_(Env::Default()), db_(nullptr) { - dbname_ = testing::TempDir() + "/recovery_test"; + dbname_ = testing::TempDir() + "recovery_test"; DestroyDB(dbname_, Options()); Open(); } @@ -332,8 +332,3 @@ TEST_F(RecoveryTest, ManifestMissing) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/skiplist.h b/db/skiplist.h index a59b45b..f716834 100644 --- a/db/skiplist.h +++ b/db/skiplist.h @@ -243,7 +243,7 @@ int SkipList<Key, Comparator>::RandomHeight() { // Increase height with probability 1 in kBranching static const unsigned int kBranching = 4; int height = 1; - while (height < kMaxHeight && ((rnd_.Next() % kBranching) == 0)) { + while (height < kMaxHeight && rnd_.OneIn(kBranching)) { height++; } assert(height > 0); diff --git a/db/skiplist_test.cc b/db/skiplist_test.cc index 79a5b86..1d355cb 100644 --- a/db/skiplist_test.cc +++ b/db/skiplist_test.cc @@ -366,8 +366,3 @@ TEST(SkipTest, Concurrent4) { RunConcurrent(4); } TEST(SkipTest, Concurrent5) { RunConcurrent(5); } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/snapshot.h b/db/snapshot.h index 9f1d664..817bb7b 100644 --- a/db/snapshot.h +++ b/db/snapshot.h @@ -25,7 +25,7 @@ class SnapshotImpl : public Snapshot { friend class SnapshotList; // SnapshotImpl is kept in a doubly-linked circular list. The SnapshotList - // implementation operates on the next/previous fields direcly. + // implementation operates on the next/previous fields directly. SnapshotImpl* prev_; SnapshotImpl* next_; diff --git a/db/table_cache.h b/db/table_cache.h index aac9bfc..db8a123 100644 --- a/db/table_cache.h +++ b/db/table_cache.h @@ -22,6 +22,10 @@ class Env; class TableCache { public: TableCache(const std::string& dbname, const Options& options, int entries); + + TableCache(const TableCache&) = delete; + TableCache& operator=(const TableCache&) = delete; + ~TableCache(); // Return an iterator for the specified file number (the corresponding diff --git a/db/version_edit_test.cc b/db/version_edit_test.cc index acafab0..a108c15 100644 --- a/db/version_edit_test.cc +++ b/db/version_edit_test.cc @@ -39,8 +39,3 @@ TEST(VersionEditTest, EncodeDecode) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/version_set.cc b/db/version_set.cc index 1963353..4e37bf9 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -626,7 +626,7 @@ class VersionSet::Builder { } // Apply all of the edits in *edit to the current state. - void Apply(VersionEdit* edit) { + void Apply(const VersionEdit* edit) { // Update compaction pointers for (size_t i = 0; i < edit->compact_pointers_.size(); i++) { const int level = edit->compact_pointers_[i].first; @@ -806,7 +806,6 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { // first call to LogAndApply (when opening the database). assert(descriptor_file_ == nullptr); new_manifest_file = DescriptorFileName(dbname_, manifest_file_number_); - edit->SetNextFile(next_file_number_); s = env_->NewWritableFile(new_manifest_file, &descriptor_file_); if (s.ok()) { descriptor_log_ = new log::Writer(descriptor_file_); @@ -1304,7 +1303,7 @@ Compaction* VersionSet::PickCompaction() { return c; } -// Finds the largest key in a vector of files. Returns true if files it not +// Finds the largest key in a vector of files. Returns true if files is not // empty. bool FindLargestKey(const InternalKeyComparator& icmp, const std::vector<FileMetaData*>& files, @@ -1392,6 +1391,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) { current_->GetOverlappingInputs(level + 1, &smallest, &largest, &c->inputs_[1]); + AddBoundaryInputs(icmp_, current_->files_[level + 1], &c->inputs_[1]); // Get entire range covered by compaction InternalKey all_start, all_limit; @@ -1414,6 +1414,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) { std::vector<FileMetaData*> expanded1; current_->GetOverlappingInputs(level + 1, &new_start, &new_limit, &expanded1); + AddBoundaryInputs(icmp_, current_->files_[level + 1], &expanded1); if (expanded1.size() == c->inputs_[1].size()) { Log(options_->info_log, "Expanding@%d %d+%d (%ld+%ld bytes) to %d+%d (%ld+%ld bytes)\n", diff --git a/db/version_set.h b/db/version_set.h index 69f3d70..ea0c925 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -59,9 +59,6 @@ bool SomeFileOverlapsRange(const InternalKeyComparator& icmp, class Version { public: - // Lookup the value for key. If found, store it in *val and - // return OK. Else return a non-OK status. Fills *stats. - // REQUIRES: lock is not held struct GetStats { FileMetaData* seek_file; int seek_file_level; @@ -72,6 +69,9 @@ class Version { // REQUIRES: This version has been saved (see VersionSet::SaveTo) void AddIterators(const ReadOptions&, std::vector<Iterator*>* iters); + // Lookup the value for key. If found, store it in *val and + // return OK. Else return a non-OK status. Fills *stats. + // REQUIRES: lock is not held Status Get(const ReadOptions&, const LookupKey& key, std::string* val, GetStats* stats); diff --git a/db/version_set_test.cc b/db/version_set_test.cc index dee6b4c..64bb983 100644 --- a/db/version_set_test.cc +++ b/db/version_set_test.cc @@ -329,8 +329,3 @@ TEST_F(AddBoundaryInputsTest, TestDisjoinFilePointers) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc index 64df9b8..1a3ea8f 100644 --- a/db/write_batch_test.cc +++ b/db/write_batch_test.cc @@ -130,8 +130,3 @@ TEST(WriteBatchTest, ApproximateSize) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} |