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