flush_block_policy.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #include "rocksdb/flush_block_policy.h"
  6. namespace ROCKSDB_NAMESPACE {
  7. // FlushBlockEveryKeyPolicy currently used only in tests.
  8. class FlushBlockEveryKeyPolicy : public FlushBlockPolicy {
  9. public:
  10. bool Update(const Slice& /*key*/, const Slice& /*value*/) override {
  11. if (!start_) {
  12. start_ = true;
  13. return false;
  14. }
  15. return true;
  16. }
  17. private:
  18. bool start_ = false;
  19. };
  20. class FlushBlockEveryKeyPolicyFactory : public FlushBlockPolicyFactory {
  21. public:
  22. explicit FlushBlockEveryKeyPolicyFactory() {}
  23. const char* Name() const override {
  24. return "FlushBlockEveryKeyPolicyFactory";
  25. }
  26. FlushBlockPolicy* NewFlushBlockPolicy(
  27. const BlockBasedTableOptions& /*table_options*/,
  28. const BlockBuilder& /*data_block_builder*/) const override {
  29. return new FlushBlockEveryKeyPolicy;
  30. }
  31. };
  32. } // namespace ROCKSDB_NAMESPACE