]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | |
6 | #pragma once | |
7 | ||
8 | #ifndef ROCKSDB_LITE | |
9 | ||
7c673cae | 10 | #include <string> |
494da23a | 11 | #include <vector> |
f67539c2 | 12 | #include "db/db_impl/db_impl.h" |
7c673cae | 13 | |
f67539c2 | 14 | namespace ROCKSDB_NAMESPACE { |
7c673cae FG |
15 | |
16 | class DBImplReadOnly : public DBImpl { | |
17 | public: | |
18 | DBImplReadOnly(const DBOptions& options, const std::string& dbname); | |
f67539c2 TL |
19 | // No copying allowed |
20 | DBImplReadOnly(const DBImplReadOnly&) = delete; | |
21 | void operator=(const DBImplReadOnly&) = delete; | |
22 | ||
7c673cae FG |
23 | virtual ~DBImplReadOnly(); |
24 | ||
25 | // Implementations of the DB interface | |
26 | using DB::Get; | |
27 | virtual Status Get(const ReadOptions& options, | |
28 | ColumnFamilyHandle* column_family, const Slice& key, | |
29 | PinnableSlice* value) override; | |
30 | ||
31 | // TODO: Implement ReadOnly MultiGet? | |
32 | ||
33 | using DBImpl::NewIterator; | |
34 | virtual Iterator* NewIterator(const ReadOptions&, | |
35 | ColumnFamilyHandle* column_family) override; | |
36 | ||
37 | virtual Status NewIterators( | |
38 | const ReadOptions& options, | |
39 | const std::vector<ColumnFamilyHandle*>& column_families, | |
40 | std::vector<Iterator*>* iterators) override; | |
41 | ||
42 | using DBImpl::Put; | |
11fdf7f2 TL |
43 | virtual Status Put(const WriteOptions& /*options*/, |
44 | ColumnFamilyHandle* /*column_family*/, | |
45 | const Slice& /*key*/, const Slice& /*value*/) override { | |
7c673cae FG |
46 | return Status::NotSupported("Not supported operation in read only mode."); |
47 | } | |
48 | using DBImpl::Merge; | |
11fdf7f2 TL |
49 | virtual Status Merge(const WriteOptions& /*options*/, |
50 | ColumnFamilyHandle* /*column_family*/, | |
51 | const Slice& /*key*/, const Slice& /*value*/) override { | |
7c673cae FG |
52 | return Status::NotSupported("Not supported operation in read only mode."); |
53 | } | |
54 | using DBImpl::Delete; | |
11fdf7f2 TL |
55 | virtual Status Delete(const WriteOptions& /*options*/, |
56 | ColumnFamilyHandle* /*column_family*/, | |
57 | const Slice& /*key*/) override { | |
7c673cae FG |
58 | return Status::NotSupported("Not supported operation in read only mode."); |
59 | } | |
60 | using DBImpl::SingleDelete; | |
11fdf7f2 TL |
61 | virtual Status SingleDelete(const WriteOptions& /*options*/, |
62 | ColumnFamilyHandle* /*column_family*/, | |
63 | const Slice& /*key*/) override { | |
7c673cae FG |
64 | return Status::NotSupported("Not supported operation in read only mode."); |
65 | } | |
11fdf7f2 TL |
66 | virtual Status Write(const WriteOptions& /*options*/, |
67 | WriteBatch* /*updates*/) override { | |
7c673cae FG |
68 | return Status::NotSupported("Not supported operation in read only mode."); |
69 | } | |
70 | using DBImpl::CompactRange; | |
11fdf7f2 TL |
71 | virtual Status CompactRange(const CompactRangeOptions& /*options*/, |
72 | ColumnFamilyHandle* /*column_family*/, | |
73 | const Slice* /*begin*/, | |
74 | const Slice* /*end*/) override { | |
7c673cae FG |
75 | return Status::NotSupported("Not supported operation in read only mode."); |
76 | } | |
77 | ||
78 | using DBImpl::CompactFiles; | |
79 | virtual Status CompactFiles( | |
11fdf7f2 TL |
80 | const CompactionOptions& /*compact_options*/, |
81 | ColumnFamilyHandle* /*column_family*/, | |
82 | const std::vector<std::string>& /*input_file_names*/, | |
83 | const int /*output_level*/, const int /*output_path_id*/ = -1, | |
494da23a TL |
84 | std::vector<std::string>* const /*output_file_names*/ = nullptr, |
85 | CompactionJobInfo* /*compaction_job_info*/ = nullptr) override { | |
7c673cae FG |
86 | return Status::NotSupported("Not supported operation in read only mode."); |
87 | } | |
88 | ||
89 | virtual Status DisableFileDeletions() override { | |
90 | return Status::NotSupported("Not supported operation in read only mode."); | |
91 | } | |
92 | ||
11fdf7f2 | 93 | virtual Status EnableFileDeletions(bool /*force*/) override { |
7c673cae FG |
94 | return Status::NotSupported("Not supported operation in read only mode."); |
95 | } | |
494da23a TL |
96 | virtual Status GetLiveFiles(std::vector<std::string>& ret, |
97 | uint64_t* manifest_file_size, | |
98 | bool /*flush_memtable*/) override { | |
99 | return DBImpl::GetLiveFiles(ret, manifest_file_size, | |
100 | false /* flush_memtable */); | |
7c673cae FG |
101 | } |
102 | ||
103 | using DBImpl::Flush; | |
11fdf7f2 TL |
104 | virtual Status Flush(const FlushOptions& /*options*/, |
105 | ColumnFamilyHandle* /*column_family*/) override { | |
7c673cae FG |
106 | return Status::NotSupported("Not supported operation in read only mode."); |
107 | } | |
108 | ||
109 | using DBImpl::SyncWAL; | |
110 | virtual Status SyncWAL() override { | |
111 | return Status::NotSupported("Not supported operation in read only mode."); | |
112 | } | |
113 | ||
114 | using DB::IngestExternalFile; | |
115 | virtual Status IngestExternalFile( | |
11fdf7f2 TL |
116 | ColumnFamilyHandle* /*column_family*/, |
117 | const std::vector<std::string>& /*external_files*/, | |
118 | const IngestExternalFileOptions& /*ingestion_options*/) override { | |
7c673cae FG |
119 | return Status::NotSupported("Not supported operation in read only mode."); |
120 | } | |
121 | ||
f67539c2 TL |
122 | using DB::CreateColumnFamilyWithImport; |
123 | virtual Status CreateColumnFamilyWithImport( | |
124 | const ColumnFamilyOptions& /*options*/, | |
125 | const std::string& /*column_family_name*/, | |
126 | const ImportColumnFamilyOptions& /*import_options*/, | |
127 | const ExportImportFilesMetaData& /*metadata*/, | |
128 | ColumnFamilyHandle** /*handle*/) override { | |
129 | return Status::NotSupported("Not supported operation in read only mode."); | |
130 | } | |
131 | ||
7c673cae FG |
132 | private: |
133 | friend class DB; | |
7c673cae | 134 | }; |
f67539c2 | 135 | } // namespace ROCKSDB_NAMESPACE |
7c673cae FG |
136 | |
137 | #endif // !ROCKSDB_LITE |