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