compacted_db_impl.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #pragma once
  6. #ifndef ROCKSDB_LITE
  7. #include <string>
  8. #include <vector>
  9. #include "db/db_impl/db_impl.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. class CompactedDBImpl : public DBImpl {
  12. public:
  13. CompactedDBImpl(const DBOptions& options, const std::string& dbname);
  14. // No copying allowed
  15. CompactedDBImpl(const CompactedDBImpl&) = delete;
  16. void operator=(const CompactedDBImpl&) = delete;
  17. virtual ~CompactedDBImpl();
  18. static Status Open(const Options& options, const std::string& dbname,
  19. DB** dbptr);
  20. // Implementations of the DB interface
  21. using DB::Get;
  22. virtual Status Get(const ReadOptions& options,
  23. ColumnFamilyHandle* column_family, const Slice& key,
  24. PinnableSlice* value) override;
  25. using DB::MultiGet;
  26. virtual std::vector<Status> MultiGet(
  27. const ReadOptions& options,
  28. const std::vector<ColumnFamilyHandle*>&,
  29. const std::vector<Slice>& keys, std::vector<std::string>* values)
  30. override;
  31. using DBImpl::Put;
  32. virtual Status Put(const WriteOptions& /*options*/,
  33. ColumnFamilyHandle* /*column_family*/,
  34. const Slice& /*key*/, const Slice& /*value*/) override {
  35. return Status::NotSupported("Not supported in compacted db mode.");
  36. }
  37. using DBImpl::Merge;
  38. virtual Status Merge(const WriteOptions& /*options*/,
  39. ColumnFamilyHandle* /*column_family*/,
  40. const Slice& /*key*/, const Slice& /*value*/) override {
  41. return Status::NotSupported("Not supported in compacted db mode.");
  42. }
  43. using DBImpl::Delete;
  44. virtual Status Delete(const WriteOptions& /*options*/,
  45. ColumnFamilyHandle* /*column_family*/,
  46. const Slice& /*key*/) override {
  47. return Status::NotSupported("Not supported in compacted db mode.");
  48. }
  49. virtual Status Write(const WriteOptions& /*options*/,
  50. WriteBatch* /*updates*/) override {
  51. return Status::NotSupported("Not supported in compacted db mode.");
  52. }
  53. using DBImpl::CompactRange;
  54. virtual Status CompactRange(const CompactRangeOptions& /*options*/,
  55. ColumnFamilyHandle* /*column_family*/,
  56. const Slice* /*begin*/,
  57. const Slice* /*end*/) override {
  58. return Status::NotSupported("Not supported in compacted db mode.");
  59. }
  60. virtual Status DisableFileDeletions() override {
  61. return Status::NotSupported("Not supported in compacted db mode.");
  62. }
  63. virtual Status EnableFileDeletions(bool /*force*/) override {
  64. return Status::NotSupported("Not supported in compacted db mode.");
  65. }
  66. virtual Status GetLiveFiles(std::vector<std::string>& ret,
  67. uint64_t* manifest_file_size,
  68. bool /*flush_memtable*/) override {
  69. return DBImpl::GetLiveFiles(ret, manifest_file_size,
  70. false /* flush_memtable */);
  71. }
  72. using DBImpl::Flush;
  73. virtual Status Flush(const FlushOptions& /*options*/,
  74. ColumnFamilyHandle* /*column_family*/) override {
  75. return Status::NotSupported("Not supported in compacted db mode.");
  76. }
  77. using DB::IngestExternalFile;
  78. virtual Status IngestExternalFile(
  79. ColumnFamilyHandle* /*column_family*/,
  80. const std::vector<std::string>& /*external_files*/,
  81. const IngestExternalFileOptions& /*ingestion_options*/) override {
  82. return Status::NotSupported("Not supported in compacted db mode.");
  83. }
  84. using DB::CreateColumnFamilyWithImport;
  85. virtual Status CreateColumnFamilyWithImport(
  86. const ColumnFamilyOptions& /*options*/,
  87. const std::string& /*column_family_name*/,
  88. const ImportColumnFamilyOptions& /*import_options*/,
  89. const ExportImportFilesMetaData& /*metadata*/,
  90. ColumnFamilyHandle** /*handle*/) override {
  91. return Status::NotSupported("Not supported in compacted db mode.");
  92. }
  93. private:
  94. friend class DB;
  95. inline size_t FindFile(const Slice& key);
  96. Status Init(const Options& options);
  97. ColumnFamilyData* cfd_;
  98. Version* version_;
  99. const Comparator* user_comparator_;
  100. LevelFilesBrief files_;
  101. };
  102. } // namespace ROCKSDB_NAMESPACE
  103. #endif // ROCKSDB_LITE