]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef OS_KEYVALUESTORE_H | |
16 | #define OS_KEYVALUESTORE_H | |
17 | ||
18 | #include <string> | |
19 | #include <vector> | |
20 | #include "include/memory.h" | |
21 | #include "kv/KeyValueDB.h" | |
22 | #include "common/hobject.h" | |
23 | ||
24 | class SequencerPosition; | |
25 | ||
26 | /** | |
27 | * Encapsulates the FileStore key value store | |
28 | * | |
29 | * Implementations of this interface will be used to implement TMAP | |
30 | */ | |
31 | class ObjectMap { | |
32 | public: | |
33 | CephContext* cct; | |
34 | /// Set keys and values from specified map | |
35 | virtual int set_keys( | |
36 | const ghobject_t &oid, ///< [in] object containing map | |
37 | const map<string, bufferlist> &set, ///< [in] key to value map to set | |
38 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
39 | ) = 0; | |
40 | ||
41 | /// Set header | |
42 | virtual int set_header( | |
43 | const ghobject_t &oid, ///< [in] object containing map | |
44 | const bufferlist &bl, ///< [in] header to set | |
45 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
46 | ) = 0; | |
47 | ||
48 | /// Retrieve header | |
49 | virtual int get_header( | |
50 | const ghobject_t &oid, ///< [in] object containing map | |
51 | bufferlist *bl ///< [out] header to set | |
52 | ) = 0; | |
53 | ||
54 | /// Clear all map keys and values from oid | |
55 | virtual int clear( | |
56 | const ghobject_t &oid, ///< [in] object containing map | |
57 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
58 | ) = 0; | |
59 | ||
60 | /// Clear all map keys and values in to_clear from oid | |
61 | virtual int rm_keys( | |
62 | const ghobject_t &oid, ///< [in] object containing map | |
63 | const set<string> &to_clear, ///< [in] Keys to clear | |
64 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
65 | ) = 0; | |
66 | ||
67 | /// Clear all omap keys and the header | |
68 | virtual int clear_keys_header( | |
69 | const ghobject_t &oid, ///< [in] oid to clear | |
70 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
71 | ) = 0; | |
72 | ||
73 | /// Get all keys and values | |
74 | virtual int get( | |
75 | const ghobject_t &oid, ///< [in] object containing map | |
76 | bufferlist *header, ///< [out] Returned Header | |
77 | map<string, bufferlist> *out ///< [out] Returned keys and values | |
78 | ) = 0; | |
79 | ||
80 | /// Get values for supplied keys | |
81 | virtual int get_keys( | |
82 | const ghobject_t &oid, ///< [in] object containing map | |
83 | set<string> *keys ///< [out] Keys defined on oid | |
84 | ) = 0; | |
85 | ||
86 | /// Get values for supplied keys | |
87 | virtual int get_values( | |
88 | const ghobject_t &oid, ///< [in] object containing map | |
89 | const set<string> &keys, ///< [in] Keys to get | |
90 | map<string, bufferlist> *out ///< [out] Returned keys and values | |
91 | ) = 0; | |
92 | ||
93 | /// Check key existence | |
94 | virtual int check_keys( | |
95 | const ghobject_t &oid, ///< [in] object containing map | |
96 | const set<string> &keys, ///< [in] Keys to check | |
97 | set<string> *out ///< [out] Subset of keys defined on oid | |
98 | ) = 0; | |
99 | ||
100 | /// Get xattrs | |
101 | virtual int get_xattrs( | |
102 | const ghobject_t &oid, ///< [in] object | |
103 | const set<string> &to_get, ///< [in] keys to get | |
104 | map<string, bufferlist> *out ///< [out] subset of attrs/vals defined | |
105 | ) = 0; | |
106 | ||
107 | /// Get all xattrs | |
108 | virtual int get_all_xattrs( | |
109 | const ghobject_t &oid, ///< [in] object | |
110 | set<string> *out ///< [out] attrs and values | |
111 | ) = 0; | |
112 | ||
113 | /// set xattrs in to_set | |
114 | virtual int set_xattrs( | |
115 | const ghobject_t &oid, ///< [in] object | |
116 | const map<string, bufferlist> &to_set,///< [in] attrs/values to set | |
117 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
118 | ) = 0; | |
119 | ||
120 | /// remove xattrs in to_remove | |
121 | virtual int remove_xattrs( | |
122 | const ghobject_t &oid, ///< [in] object | |
123 | const set<string> &to_remove, ///< [in] attrs to remove | |
124 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
125 | ) = 0; | |
126 | ||
127 | ||
128 | /// Clone keys from oid map to target map | |
129 | virtual int clone( | |
130 | const ghobject_t &oid, ///< [in] object containing map | |
131 | const ghobject_t &target, ///< [in] target of clone | |
132 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
133 | ) { return 0; } | |
134 | ||
135 | /// Rename map because of name change | |
136 | virtual int rename( | |
137 | const ghobject_t &from, ///< [in] object containing map | |
138 | const ghobject_t &to, ///< [in] new name | |
139 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
140 | ) { return 0; } | |
141 | ||
142 | /// For testing clone keys from oid map to target map using faster but more complex method | |
143 | virtual int legacy_clone( | |
144 | const ghobject_t &oid, ///< [in] object containing map | |
145 | const ghobject_t &target, ///< [in] target of clone | |
146 | const SequencerPosition *spos=0 ///< [in] sequencer position | |
147 | ) { return 0; } | |
148 | ||
149 | /// Ensure all previous writes are durable | |
150 | virtual int sync( | |
151 | const ghobject_t *oid=0, ///< [in] object | |
152 | const SequencerPosition *spos=0 ///< [in] Sequencer | |
153 | ) { return 0; } | |
154 | ||
155 | virtual int check(std::ostream &out, bool repair = false) { return 0; } | |
156 | ||
224ce89b WB |
157 | virtual void compact() {} |
158 | ||
7c673cae FG |
159 | typedef KeyValueDB::GenericIteratorImpl ObjectMapIteratorImpl; |
160 | typedef ceph::shared_ptr<ObjectMapIteratorImpl> ObjectMapIterator; | |
161 | virtual ObjectMapIterator get_iterator(const ghobject_t &oid) { | |
162 | return ObjectMapIterator(); | |
163 | } | |
164 | ||
165 | ||
166 | ObjectMap(CephContext* cct) : cct(cct) {} | |
167 | virtual ~ObjectMap() {} | |
168 | }; | |
169 | ||
170 | #endif |