|
|
|
@ -940,13 +940,13 @@ TEST_F(DBTest, FlushSchedule) { |
|
|
|
|
namespace { |
|
|
|
|
class KeepFilter : public CompactionFilter { |
|
|
|
|
public: |
|
|
|
|
virtual bool Filter(int /*level*/, const Slice& /*key*/, |
|
|
|
|
const Slice& /*value*/, std::string* /*new_value*/, |
|
|
|
|
bool* /*value_changed*/) const override { |
|
|
|
|
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/, |
|
|
|
|
std::string* /*new_value*/, |
|
|
|
|
bool* /*value_changed*/) const override { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "KeepFilter"; } |
|
|
|
|
const char* Name() const override { return "KeepFilter"; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class KeepFilterFactory : public CompactionFilterFactory { |
|
|
|
@ -954,7 +954,7 @@ class KeepFilterFactory : public CompactionFilterFactory { |
|
|
|
|
explicit KeepFilterFactory(bool check_context = false) |
|
|
|
|
: check_context_(check_context) {} |
|
|
|
|
|
|
|
|
|
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
const CompactionFilter::Context& context) override { |
|
|
|
|
if (check_context_) { |
|
|
|
|
EXPECT_EQ(expect_full_compaction_.load(), context.is_full_compaction); |
|
|
|
@ -963,7 +963,7 @@ class KeepFilterFactory : public CompactionFilterFactory { |
|
|
|
|
return std::unique_ptr<CompactionFilter>(new KeepFilter()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "KeepFilterFactory"; } |
|
|
|
|
const char* Name() const override { return "KeepFilterFactory"; } |
|
|
|
|
bool check_context_; |
|
|
|
|
std::atomic_bool expect_full_compaction_; |
|
|
|
|
std::atomic_bool expect_manual_compaction_; |
|
|
|
@ -972,14 +972,14 @@ class KeepFilterFactory : public CompactionFilterFactory { |
|
|
|
|
class DelayFilter : public CompactionFilter { |
|
|
|
|
public: |
|
|
|
|
explicit DelayFilter(DBTestBase* d) : db_test(d) {} |
|
|
|
|
virtual bool Filter(int /*level*/, const Slice& /*key*/, |
|
|
|
|
const Slice& /*value*/, std::string* /*new_value*/, |
|
|
|
|
bool* /*value_changed*/) const override { |
|
|
|
|
bool Filter(int /*level*/, const Slice& /*key*/, const Slice& /*value*/, |
|
|
|
|
std::string* /*new_value*/, |
|
|
|
|
bool* /*value_changed*/) const override { |
|
|
|
|
db_test->env_->addon_time_.fetch_add(1000); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "DelayFilter"; } |
|
|
|
|
const char* Name() const override { return "DelayFilter"; } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
DBTestBase* db_test; |
|
|
|
@ -988,12 +988,12 @@ class DelayFilter : public CompactionFilter { |
|
|
|
|
class DelayFilterFactory : public CompactionFilterFactory { |
|
|
|
|
public: |
|
|
|
|
explicit DelayFilterFactory(DBTestBase* d) : db_test(d) {} |
|
|
|
|
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
const CompactionFilter::Context& /*context*/) override { |
|
|
|
|
return std::unique_ptr<CompactionFilter>(new DelayFilter(db_test)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "DelayFilterFactory"; } |
|
|
|
|
const char* Name() const override { return "DelayFilterFactory"; } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
DBTestBase* db_test; |
|
|
|
@ -1775,17 +1775,14 @@ TEST_F(DBTest, OverlapInLevel0) { |
|
|
|
|
TEST_F(DBTest, ComparatorCheck) { |
|
|
|
|
class NewComparator : public Comparator { |
|
|
|
|
public: |
|
|
|
|
virtual const char* Name() const override { |
|
|
|
|
return "rocksdb.NewComparator"; |
|
|
|
|
} |
|
|
|
|
virtual int Compare(const Slice& a, const Slice& b) const override { |
|
|
|
|
const char* Name() const override { return "rocksdb.NewComparator"; } |
|
|
|
|
int Compare(const Slice& a, const Slice& b) const override { |
|
|
|
|
return BytewiseComparator()->Compare(a, b); |
|
|
|
|
} |
|
|
|
|
virtual void FindShortestSeparator(std::string* s, |
|
|
|
|
const Slice& l) const override { |
|
|
|
|
void FindShortestSeparator(std::string* s, const Slice& l) const override { |
|
|
|
|
BytewiseComparator()->FindShortestSeparator(s, l); |
|
|
|
|
} |
|
|
|
|
virtual void FindShortSuccessor(std::string* key) const override { |
|
|
|
|
void FindShortSuccessor(std::string* key) const override { |
|
|
|
|
BytewiseComparator()->FindShortSuccessor(key); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -1808,18 +1805,15 @@ TEST_F(DBTest, ComparatorCheck) { |
|
|
|
|
TEST_F(DBTest, CustomComparator) { |
|
|
|
|
class NumberComparator : public Comparator { |
|
|
|
|
public: |
|
|
|
|
virtual const char* Name() const override { |
|
|
|
|
return "test.NumberComparator"; |
|
|
|
|
} |
|
|
|
|
virtual int Compare(const Slice& a, const Slice& b) const override { |
|
|
|
|
const char* Name() const override { return "test.NumberComparator"; } |
|
|
|
|
int Compare(const Slice& a, const Slice& b) const override { |
|
|
|
|
return ToNumber(a) - ToNumber(b); |
|
|
|
|
} |
|
|
|
|
virtual void FindShortestSeparator(std::string* s, |
|
|
|
|
const Slice& l) const override { |
|
|
|
|
void FindShortestSeparator(std::string* s, const Slice& l) const override { |
|
|
|
|
ToNumber(*s); // Check format
|
|
|
|
|
ToNumber(l); // Check format
|
|
|
|
|
} |
|
|
|
|
virtual void FindShortSuccessor(std::string* key) const override { |
|
|
|
|
void FindShortSuccessor(std::string* key) const override { |
|
|
|
|
ToNumber(*key); // Check format
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2253,7 +2247,7 @@ static void MTThreadBody(void* arg) { |
|
|
|
|
class MultiThreadedDBTest : public DBTest, |
|
|
|
|
public ::testing::WithParamInterface<int> { |
|
|
|
|
public: |
|
|
|
|
virtual void SetUp() override { option_config_ = GetParam(); } |
|
|
|
|
void SetUp() override { option_config_ = GetParam(); } |
|
|
|
|
|
|
|
|
|
static std::vector<int> GenerateOptionConfigs() { |
|
|
|
|
std::vector<int> optionConfigs; |
|
|
|
@ -2398,7 +2392,7 @@ class ModelDB : public DB { |
|
|
|
|
public: |
|
|
|
|
KVMap map_; |
|
|
|
|
|
|
|
|
|
virtual SequenceNumber GetSequenceNumber() const override { |
|
|
|
|
SequenceNumber GetSequenceNumber() const override { |
|
|
|
|
// no need to call this
|
|
|
|
|
assert(false); |
|
|
|
|
return 0; |
|
|
|
@ -2407,43 +2401,43 @@ class ModelDB : public DB { |
|
|
|
|
|
|
|
|
|
explicit ModelDB(const Options& options) : options_(options) {} |
|
|
|
|
using DB::Put; |
|
|
|
|
virtual Status Put(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& k, const Slice& v) override { |
|
|
|
|
Status Put(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k, |
|
|
|
|
const Slice& v) override { |
|
|
|
|
WriteBatch batch; |
|
|
|
|
batch.Put(cf, k, v); |
|
|
|
|
return Write(o, &batch); |
|
|
|
|
} |
|
|
|
|
using DB::Close; |
|
|
|
|
virtual Status Close() override { return Status::OK(); } |
|
|
|
|
Status Close() override { return Status::OK(); } |
|
|
|
|
using DB::Delete; |
|
|
|
|
virtual Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& key) override { |
|
|
|
|
Status Delete(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& key) override { |
|
|
|
|
WriteBatch batch; |
|
|
|
|
batch.Delete(cf, key); |
|
|
|
|
return Write(o, &batch); |
|
|
|
|
} |
|
|
|
|
using DB::SingleDelete; |
|
|
|
|
virtual Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& key) override { |
|
|
|
|
Status SingleDelete(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& key) override { |
|
|
|
|
WriteBatch batch; |
|
|
|
|
batch.SingleDelete(cf, key); |
|
|
|
|
return Write(o, &batch); |
|
|
|
|
} |
|
|
|
|
using DB::Merge; |
|
|
|
|
virtual Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, |
|
|
|
|
const Slice& k, const Slice& v) override { |
|
|
|
|
Status Merge(const WriteOptions& o, ColumnFamilyHandle* cf, const Slice& k, |
|
|
|
|
const Slice& v) override { |
|
|
|
|
WriteBatch batch; |
|
|
|
|
batch.Merge(cf, k, v); |
|
|
|
|
return Write(o, &batch); |
|
|
|
|
} |
|
|
|
|
using DB::Get; |
|
|
|
|
virtual Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/, |
|
|
|
|
const Slice& key, PinnableSlice* /*value*/) override { |
|
|
|
|
Status Get(const ReadOptions& /*options*/, ColumnFamilyHandle* /*cf*/, |
|
|
|
|
const Slice& key, PinnableSlice* /*value*/) override { |
|
|
|
|
return Status::NotSupported(key); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::MultiGet; |
|
|
|
|
virtual std::vector<Status> MultiGet( |
|
|
|
|
std::vector<Status> MultiGet( |
|
|
|
|
const ReadOptions& /*options*/, |
|
|
|
|
const std::vector<ColumnFamilyHandle*>& /*column_family*/, |
|
|
|
|
const std::vector<Slice>& keys, |
|
|
|
@ -2455,7 +2449,7 @@ class ModelDB : public DB { |
|
|
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE |
|
|
|
|
using DB::IngestExternalFile; |
|
|
|
|
virtual Status IngestExternalFile( |
|
|
|
|
Status IngestExternalFile( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const std::vector<std::string>& /*external_files*/, |
|
|
|
|
const IngestExternalFileOptions& /*options*/) override { |
|
|
|
@ -2463,23 +2457,23 @@ class ModelDB : public DB { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::IngestExternalFiles; |
|
|
|
|
virtual Status IngestExternalFiles( |
|
|
|
|
Status IngestExternalFiles( |
|
|
|
|
const std::vector<IngestExternalFileArg>& /*args*/) override { |
|
|
|
|
return Status::NotSupported("Not implemented"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status VerifyChecksum() override { |
|
|
|
|
Status VerifyChecksum() override { |
|
|
|
|
return Status::NotSupported("Not implemented."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::GetPropertiesOfAllTables; |
|
|
|
|
virtual Status GetPropertiesOfAllTables( |
|
|
|
|
Status GetPropertiesOfAllTables( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
TablePropertiesCollection* /*props*/) override { |
|
|
|
|
return Status(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status GetPropertiesOfTablesInRange( |
|
|
|
|
Status GetPropertiesOfTablesInRange( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, const Range* /*range*/, |
|
|
|
|
std::size_t /*n*/, TablePropertiesCollection* /*props*/) override { |
|
|
|
|
return Status(); |
|
|
|
@ -2487,19 +2481,18 @@ class ModelDB : public DB { |
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
|
|
|
|
|
using DB::KeyMayExist; |
|
|
|
|
virtual bool KeyMayExist(const ReadOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*key*/, std::string* /*value*/, |
|
|
|
|
bool* value_found = nullptr) override { |
|
|
|
|
bool KeyMayExist(const ReadOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, const Slice& /*key*/, |
|
|
|
|
std::string* /*value*/, |
|
|
|
|
bool* value_found = nullptr) override { |
|
|
|
|
if (value_found != nullptr) { |
|
|
|
|
*value_found = false; |
|
|
|
|
} |
|
|
|
|
return true; // Not Supported directly
|
|
|
|
|
} |
|
|
|
|
using DB::NewIterator; |
|
|
|
|
virtual Iterator* NewIterator( |
|
|
|
|
const ReadOptions& options, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
Iterator* NewIterator(const ReadOptions& options, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
if (options.snapshot == nullptr) { |
|
|
|
|
KVMap* saved = new KVMap; |
|
|
|
|
*saved = map_; |
|
|
|
@ -2510,38 +2503,33 @@ class ModelDB : public DB { |
|
|
|
|
return new ModelIter(snapshot_state, false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
virtual Status NewIterators( |
|
|
|
|
const ReadOptions& /*options*/, |
|
|
|
|
const std::vector<ColumnFamilyHandle*>& /*column_family*/, |
|
|
|
|
std::vector<Iterator*>* /*iterators*/) override { |
|
|
|
|
Status NewIterators(const ReadOptions& /*options*/, |
|
|
|
|
const std::vector<ColumnFamilyHandle*>& /*column_family*/, |
|
|
|
|
std::vector<Iterator*>* /*iterators*/) override { |
|
|
|
|
return Status::NotSupported("Not supported yet"); |
|
|
|
|
} |
|
|
|
|
virtual const Snapshot* GetSnapshot() override { |
|
|
|
|
const Snapshot* GetSnapshot() override { |
|
|
|
|
ModelSnapshot* snapshot = new ModelSnapshot; |
|
|
|
|
snapshot->map_ = map_; |
|
|
|
|
return snapshot; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual void ReleaseSnapshot(const Snapshot* snapshot) override { |
|
|
|
|
void ReleaseSnapshot(const Snapshot* snapshot) override { |
|
|
|
|
delete reinterpret_cast<const ModelSnapshot*>(snapshot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status Write(const WriteOptions& /*options*/, |
|
|
|
|
WriteBatch* batch) override { |
|
|
|
|
Status Write(const WriteOptions& /*options*/, WriteBatch* batch) override { |
|
|
|
|
class Handler : public WriteBatch::Handler { |
|
|
|
|
public: |
|
|
|
|
KVMap* map_; |
|
|
|
|
virtual void Put(const Slice& key, const Slice& value) override { |
|
|
|
|
void Put(const Slice& key, const Slice& value) override { |
|
|
|
|
(*map_)[key.ToString()] = value.ToString(); |
|
|
|
|
} |
|
|
|
|
virtual void Merge(const Slice& /*key*/, |
|
|
|
|
const Slice& /*value*/) override { |
|
|
|
|
void Merge(const Slice& /*key*/, const Slice& /*value*/) override { |
|
|
|
|
// ignore merge for now
|
|
|
|
|
// (*map_)[key.ToString()] = value.ToString();
|
|
|
|
|
} |
|
|
|
|
virtual void Delete(const Slice& key) override { |
|
|
|
|
map_->erase(key.ToString()); |
|
|
|
|
} |
|
|
|
|
void Delete(const Slice& key) override { map_->erase(key.ToString()); } |
|
|
|
|
}; |
|
|
|
|
Handler handler; |
|
|
|
|
handler.map_ = &map_; |
|
|
|
@ -2549,61 +2537,58 @@ class ModelDB : public DB { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::GetProperty; |
|
|
|
|
virtual bool GetProperty(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*property*/, |
|
|
|
|
std::string* /*value*/) override { |
|
|
|
|
bool GetProperty(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*property*/, std::string* /*value*/) override { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
using DB::GetIntProperty; |
|
|
|
|
virtual bool GetIntProperty(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*property*/, |
|
|
|
|
uint64_t* /*value*/) override { |
|
|
|
|
bool GetIntProperty(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*property*/, uint64_t* /*value*/) override { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
using DB::GetMapProperty; |
|
|
|
|
virtual bool GetMapProperty( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, const Slice& /*property*/, |
|
|
|
|
std::map<std::string, std::string>* /*value*/) override { |
|
|
|
|
bool GetMapProperty(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice& /*property*/, |
|
|
|
|
std::map<std::string, std::string>* /*value*/) override { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
using DB::GetAggregatedIntProperty; |
|
|
|
|
virtual bool GetAggregatedIntProperty(const Slice& /*property*/, |
|
|
|
|
uint64_t* /*value*/) override { |
|
|
|
|
bool GetAggregatedIntProperty(const Slice& /*property*/, |
|
|
|
|
uint64_t* /*value*/) override { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
using DB::GetApproximateSizes; |
|
|
|
|
virtual void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Range* /*range*/, int n, |
|
|
|
|
uint64_t* sizes, |
|
|
|
|
uint8_t /*include_flags*/ |
|
|
|
|
= INCLUDE_FILES) override { |
|
|
|
|
void GetApproximateSizes(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Range* /*range*/, int n, uint64_t* sizes, |
|
|
|
|
uint8_t /*include_flags*/ |
|
|
|
|
= INCLUDE_FILES) override { |
|
|
|
|
for (int i = 0; i < n; i++) { |
|
|
|
|
sizes[i] = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
using DB::GetApproximateMemTableStats; |
|
|
|
|
virtual void GetApproximateMemTableStats( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, const Range& /*range*/, |
|
|
|
|
uint64_t* const count, uint64_t* const size) override { |
|
|
|
|
void GetApproximateMemTableStats(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Range& /*range*/, |
|
|
|
|
uint64_t* const count, |
|
|
|
|
uint64_t* const size) override { |
|
|
|
|
*count = 0; |
|
|
|
|
*size = 0; |
|
|
|
|
} |
|
|
|
|
using DB::CompactRange; |
|
|
|
|
virtual Status CompactRange(const CompactRangeOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice* /*start*/, |
|
|
|
|
const Slice* /*end*/) override { |
|
|
|
|
Status CompactRange(const CompactRangeOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const Slice* /*start*/, const Slice* /*end*/) override { |
|
|
|
|
return Status::NotSupported("Not supported operation."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status SetDBOptions( |
|
|
|
|
Status SetDBOptions( |
|
|
|
|
const std::unordered_map<std::string, std::string>& /*new_options*/) |
|
|
|
|
override { |
|
|
|
|
return Status::NotSupported("Not supported operation."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::CompactFiles; |
|
|
|
|
virtual Status CompactFiles( |
|
|
|
|
Status CompactFiles( |
|
|
|
|
const CompactionOptions& /*compact_options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
const std::vector<std::string>& /*input_file_names*/, |
|
|
|
@ -2628,69 +2613,60 @@ class ModelDB : public DB { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::NumberLevels; |
|
|
|
|
virtual int NumberLevels(ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
int NumberLevels(ColumnFamilyHandle* /*column_family*/) override { return 1; } |
|
|
|
|
|
|
|
|
|
using DB::MaxMemCompactionLevel; |
|
|
|
|
virtual int MaxMemCompactionLevel( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
int MaxMemCompactionLevel(ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::Level0StopWriteTrigger; |
|
|
|
|
virtual int Level0StopWriteTrigger( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
int Level0StopWriteTrigger(ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const std::string& GetName() const override { return name_; } |
|
|
|
|
const std::string& GetName() const override { return name_; } |
|
|
|
|
|
|
|
|
|
virtual Env* GetEnv() const override { return nullptr; } |
|
|
|
|
Env* GetEnv() const override { return nullptr; } |
|
|
|
|
|
|
|
|
|
using DB::GetOptions; |
|
|
|
|
virtual Options GetOptions( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) const override { |
|
|
|
|
Options GetOptions(ColumnFamilyHandle* /*column_family*/) const override { |
|
|
|
|
return options_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using DB::GetDBOptions; |
|
|
|
|
virtual DBOptions GetDBOptions() const override { return options_; } |
|
|
|
|
DBOptions GetDBOptions() const override { return options_; } |
|
|
|
|
|
|
|
|
|
using DB::Flush; |
|
|
|
|
virtual Status Flush(const rocksdb::FlushOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
Status Flush(const rocksdb::FlushOptions& /*options*/, |
|
|
|
|
ColumnFamilyHandle* /*column_family*/) override { |
|
|
|
|
Status ret; |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
virtual Status Flush( |
|
|
|
|
Status Flush( |
|
|
|
|
const rocksdb::FlushOptions& /*options*/, |
|
|
|
|
const std::vector<ColumnFamilyHandle*>& /*column_families*/) override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status SyncWAL() override { return Status::OK(); } |
|
|
|
|
Status SyncWAL() override { return Status::OK(); } |
|
|
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE |
|
|
|
|
virtual Status DisableFileDeletions() override { return Status::OK(); } |
|
|
|
|
Status DisableFileDeletions() override { return Status::OK(); } |
|
|
|
|
|
|
|
|
|
virtual Status EnableFileDeletions(bool /*force*/) override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
virtual Status GetLiveFiles(std::vector<std::string>&, uint64_t* /*size*/, |
|
|
|
|
bool /*flush_memtable*/ = true) override { |
|
|
|
|
Status EnableFileDeletions(bool /*force*/) override { return Status::OK(); } |
|
|
|
|
Status GetLiveFiles(std::vector<std::string>&, uint64_t* /*size*/, |
|
|
|
|
bool /*flush_memtable*/ = true) override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status GetSortedWalFiles(VectorLogPtr& /*files*/) override { |
|
|
|
|
Status GetSortedWalFiles(VectorLogPtr& /*files*/) override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Status DeleteFile(std::string /*name*/) override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
Status DeleteFile(std::string /*name*/) override { return Status::OK(); } |
|
|
|
|
|
|
|
|
|
virtual Status GetUpdatesSince( |
|
|
|
|
Status GetUpdatesSince( |
|
|
|
|
rocksdb::SequenceNumber, |
|
|
|
|
std::unique_ptr<rocksdb::TransactionLogIterator>*, |
|
|
|
|
const TransactionLogIterator::ReadOptions& /*read_options*/ = |
|
|
|
@ -2698,52 +2674,48 @@ class ModelDB : public DB { |
|
|
|
|
return Status::NotSupported("Not supported in Model DB"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual void GetColumnFamilyMetaData( |
|
|
|
|
ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
ColumnFamilyMetaData* /*metadata*/) override {} |
|
|
|
|
void GetColumnFamilyMetaData(ColumnFamilyHandle* /*column_family*/, |
|
|
|
|
ColumnFamilyMetaData* /*metadata*/) override {} |
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
|
|
|
|
|
virtual Status GetDbIdentity(std::string& /*identity*/) const override { |
|
|
|
|
Status GetDbIdentity(std::string& /*identity*/) const override { |
|
|
|
|
return Status::OK(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual SequenceNumber GetLatestSequenceNumber() const override { return 0; } |
|
|
|
|
SequenceNumber GetLatestSequenceNumber() const override { return 0; } |
|
|
|
|
|
|
|
|
|
virtual bool SetPreserveDeletesSequenceNumber( |
|
|
|
|
SequenceNumber /*seqnum*/) override { |
|
|
|
|
bool SetPreserveDeletesSequenceNumber(SequenceNumber /*seqnum*/) override { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual ColumnFamilyHandle* DefaultColumnFamily() const override { |
|
|
|
|
return nullptr; |
|
|
|
|
} |
|
|
|
|
ColumnFamilyHandle* DefaultColumnFamily() const override { return nullptr; } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
class ModelIter : public Iterator { |
|
|
|
|
public: |
|
|
|
|
ModelIter(const KVMap* map, bool owned) |
|
|
|
|
: map_(map), owned_(owned), iter_(map_->end()) {} |
|
|
|
|
~ModelIter() { |
|
|
|
|
~ModelIter() override { |
|
|
|
|
if (owned_) delete map_; |
|
|
|
|
} |
|
|
|
|
virtual bool Valid() const override { return iter_ != map_->end(); } |
|
|
|
|
virtual void SeekToFirst() override { iter_ = map_->begin(); } |
|
|
|
|
virtual void SeekToLast() override { |
|
|
|
|
bool Valid() const override { return iter_ != map_->end(); } |
|
|
|
|
void SeekToFirst() override { iter_ = map_->begin(); } |
|
|
|
|
void SeekToLast() override { |
|
|
|
|
if (map_->empty()) { |
|
|
|
|
iter_ = map_->end(); |
|
|
|
|
} else { |
|
|
|
|
iter_ = map_->find(map_->rbegin()->first); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
virtual void Seek(const Slice& k) override { |
|
|
|
|
void Seek(const Slice& k) override { |
|
|
|
|
iter_ = map_->lower_bound(k.ToString()); |
|
|
|
|
} |
|
|
|
|
virtual void SeekForPrev(const Slice& k) override { |
|
|
|
|
void SeekForPrev(const Slice& k) override { |
|
|
|
|
iter_ = map_->upper_bound(k.ToString()); |
|
|
|
|
Prev(); |
|
|
|
|
} |
|
|
|
|
virtual void Next() override { ++iter_; } |
|
|
|
|
virtual void Prev() override { |
|
|
|
|
void Next() override { ++iter_; } |
|
|
|
|
void Prev() override { |
|
|
|
|
if (iter_ == map_->begin()) { |
|
|
|
|
iter_ = map_->end(); |
|
|
|
|
return; |
|
|
|
@ -2751,9 +2723,9 @@ class ModelDB : public DB { |
|
|
|
|
--iter_; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual Slice key() const override { return iter_->first; } |
|
|
|
|
virtual Slice value() const override { return iter_->second; } |
|
|
|
|
virtual Status status() const override { return Status::OK(); } |
|
|
|
|
Slice key() const override { return iter_->first; } |
|
|
|
|
Slice value() const override { return iter_->second; } |
|
|
|
|
Status status() const override { return Status::OK(); } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
const KVMap* const map_; |
|
|
|
@ -2821,7 +2793,7 @@ static bool CompareIterators(int step, DB* model, DB* db, |
|
|
|
|
class DBTestRandomized : public DBTest, |
|
|
|
|
public ::testing::WithParamInterface<int> { |
|
|
|
|
public: |
|
|
|
|
virtual void SetUp() override { option_config_ = GetParam(); } |
|
|
|
|
void SetUp() override { option_config_ = GetParam(); } |
|
|
|
|
|
|
|
|
|
static std::vector<int> GenerateOptionConfigs() { |
|
|
|
|
std::vector<int> option_configs; |
|
|
|
@ -5043,14 +5015,14 @@ class DelayedMergeOperator : public MergeOperator { |
|
|
|
|
public: |
|
|
|
|
explicit DelayedMergeOperator(DBTest* d) : db_test_(d) {} |
|
|
|
|
|
|
|
|
|
virtual bool FullMergeV2(const MergeOperationInput& /*merge_in*/, |
|
|
|
|
MergeOperationOutput* merge_out) const override { |
|
|
|
|
bool FullMergeV2(const MergeOperationInput& /*merge_in*/, |
|
|
|
|
MergeOperationOutput* merge_out) const override { |
|
|
|
|
db_test_->env_->addon_time_.fetch_add(1000); |
|
|
|
|
merge_out->new_value = ""; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
virtual const char* Name() const override { return "DelayedMergeOperator"; } |
|
|
|
|
const char* Name() const override { return "DelayedMergeOperator"; } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(DBTest, MergeTestTime) { |
|
|
|
@ -5186,7 +5158,7 @@ TEST_F(DBTest, EmptyCompactedDB) { |
|
|
|
|
TEST_F(DBTest, SuggestCompactRangeTest) { |
|
|
|
|
class CompactionFilterFactoryGetContext : public CompactionFilterFactory { |
|
|
|
|
public: |
|
|
|
|
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
std::unique_ptr<CompactionFilter> CreateCompactionFilter( |
|
|
|
|
const CompactionFilter::Context& context) override { |
|
|
|
|
saved_context = context; |
|
|
|
|
std::unique_ptr<CompactionFilter> empty_filter; |
|
|
|
|