]> git.proxmox.com Git - ceph.git/blame - ceph/src/os/ObjectMap.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / os / ObjectMap.h
CommitLineData
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
11fdf7f2 18#include <memory>
7c673cae
FG
19#include <string>
20#include <vector>
7c673cae
FG
21#include "kv/KeyValueDB.h"
22#include "common/hobject.h"
23
24class SequencerPosition;
25
26/**
27 * Encapsulates the FileStore key value store
28 *
29 * Implementations of this interface will be used to implement TMAP
30 */
31class ObjectMap {
32public:
33 CephContext* cct;
11fdf7f2 34 boost::scoped_ptr<KeyValueDB> db;
9f95a23c 35 /// std::Set keys and values from specified map
7c673cae
FG
36 virtual int set_keys(
37 const ghobject_t &oid, ///< [in] object containing map
9f95a23c 38 const std::map<std::string, ceph::buffer::list> &set, ///< [in] key to value map to set
7c673cae
FG
39 const SequencerPosition *spos=0 ///< [in] sequencer position
40 ) = 0;
41
9f95a23c 42 /// std::Set header
7c673cae
FG
43 virtual int set_header(
44 const ghobject_t &oid, ///< [in] object containing map
9f95a23c 45 const ceph::buffer::list &bl, ///< [in] header to set
7c673cae
FG
46 const SequencerPosition *spos=0 ///< [in] sequencer position
47 ) = 0;
48
49 /// Retrieve header
50 virtual int get_header(
51 const ghobject_t &oid, ///< [in] object containing map
9f95a23c 52 ceph::buffer::list *bl ///< [out] header to set
7c673cae
FG
53 ) = 0;
54
55 /// Clear all map keys and values from oid
56 virtual int clear(
57 const ghobject_t &oid, ///< [in] object containing map
58 const SequencerPosition *spos=0 ///< [in] sequencer position
59 ) = 0;
60
61 /// Clear all map keys and values in to_clear from oid
62 virtual int rm_keys(
63 const ghobject_t &oid, ///< [in] object containing map
9f95a23c 64 const std::set<std::string> &to_clear, ///< [in] Keys to clear
7c673cae
FG
65 const SequencerPosition *spos=0 ///< [in] sequencer position
66 ) = 0;
67
68 /// Clear all omap keys and the header
69 virtual int clear_keys_header(
70 const ghobject_t &oid, ///< [in] oid to clear
71 const SequencerPosition *spos=0 ///< [in] sequencer position
72 ) = 0;
73
74 /// Get all keys and values
75 virtual int get(
76 const ghobject_t &oid, ///< [in] object containing map
9f95a23c
TL
77 ceph::buffer::list *header, ///< [out] Returned Header
78 std::map<std::string, ceph::buffer::list> *out ///< [out] Returned keys and values
7c673cae
FG
79 ) = 0;
80
81 /// Get values for supplied keys
82 virtual int get_keys(
83 const ghobject_t &oid, ///< [in] object containing map
9f95a23c 84 std::set<std::string> *keys ///< [out] Keys defined on oid
7c673cae
FG
85 ) = 0;
86
87 /// Get values for supplied keys
88 virtual int get_values(
89 const ghobject_t &oid, ///< [in] object containing map
9f95a23c
TL
90 const std::set<std::string> &keys, ///< [in] Keys to get
91 std::map<std::string, ceph::buffer::list> *out ///< [out] Returned keys and values
7c673cae
FG
92 ) = 0;
93
94 /// Check key existence
95 virtual int check_keys(
96 const ghobject_t &oid, ///< [in] object containing map
9f95a23c
TL
97 const std::set<std::string> &keys, ///< [in] Keys to check
98 std::set<std::string> *out ///< [out] Subset of keys defined on oid
7c673cae
FG
99 ) = 0;
100
101 /// Get xattrs
102 virtual int get_xattrs(
103 const ghobject_t &oid, ///< [in] object
9f95a23c
TL
104 const std::set<std::string> &to_get, ///< [in] keys to get
105 std::map<std::string, ceph::buffer::list> *out ///< [out] subset of attrs/vals defined
7c673cae
FG
106 ) = 0;
107
108 /// Get all xattrs
109 virtual int get_all_xattrs(
110 const ghobject_t &oid, ///< [in] object
9f95a23c 111 std::set<std::string> *out ///< [out] attrs and values
7c673cae
FG
112 ) = 0;
113
9f95a23c 114 /// std::set xattrs in to_set
7c673cae
FG
115 virtual int set_xattrs(
116 const ghobject_t &oid, ///< [in] object
9f95a23c 117 const std::map<std::string, ceph::buffer::list> &to_set,///< [in] attrs/values to set
7c673cae
FG
118 const SequencerPosition *spos=0 ///< [in] sequencer position
119 ) = 0;
120
121 /// remove xattrs in to_remove
122 virtual int remove_xattrs(
123 const ghobject_t &oid, ///< [in] object
9f95a23c 124 const std::set<std::string> &to_remove, ///< [in] attrs to remove
7c673cae
FG
125 const SequencerPosition *spos=0 ///< [in] sequencer position
126 ) = 0;
127
128
129 /// Clone keys from oid map to target map
130 virtual int clone(
131 const ghobject_t &oid, ///< [in] object containing map
132 const ghobject_t &target, ///< [in] target of clone
133 const SequencerPosition *spos=0 ///< [in] sequencer position
134 ) { return 0; }
135
136 /// Rename map because of name change
137 virtual int rename(
138 const ghobject_t &from, ///< [in] object containing map
139 const ghobject_t &to, ///< [in] new name
140 const SequencerPosition *spos=0 ///< [in] sequencer position
141 ) { return 0; }
142
143 /// For testing clone keys from oid map to target map using faster but more complex method
144 virtual int legacy_clone(
145 const ghobject_t &oid, ///< [in] object containing map
146 const ghobject_t &target, ///< [in] target of clone
147 const SequencerPosition *spos=0 ///< [in] sequencer position
148 ) { return 0; }
149
150 /// Ensure all previous writes are durable
151 virtual int sync(
152 const ghobject_t *oid=0, ///< [in] object
153 const SequencerPosition *spos=0 ///< [in] Sequencer
154 ) { return 0; }
155
3efd9988 156 virtual int check(std::ostream &out, bool repair = false, bool force = false) { return 0; }
7c673cae 157
224ce89b
WB
158 virtual void compact() {}
159
11fdf7f2
TL
160 typedef KeyValueDB::SimplestIteratorImpl ObjectMapIteratorImpl;
161 typedef std::shared_ptr<ObjectMapIteratorImpl> ObjectMapIterator;
7c673cae
FG
162 virtual ObjectMapIterator get_iterator(const ghobject_t &oid) {
163 return ObjectMapIterator();
164 }
165
11fdf7f2 166 virtual KeyValueDB *get_db() { return nullptr; }
7c673cae 167
11fdf7f2 168 ObjectMap(CephContext* cct, KeyValueDB *db) : cct(cct), db(db) {}
7c673cae
FG
169 virtual ~ObjectMap() {}
170};
171
172#endif