blob: 789bb0992cd107dd355d940cbe89c6db90f04d50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
#ifndef KEY_VALUE_DB_H
#define KEY_VALUE_DB_H
#include "include/buffer.h"
#include <set>
#include <map>
#include <string>
#include <tr1/memory>
#include "ObjectMap.h"
using std::string;
/**
* Defines virtual interface to be implemented by key value store
*
* Kyoto Cabinet or LevelDB should implement this
*/
class KeyValueDB {
public:
class TransactionImpl {
public:
/// Set Keys
virtual void set(
const string &prefix, ///< [in] Prefix for keys
const std::map<string, bufferlist> &to_set ///< [in] keys/values to set
) = 0;
/// Removes Keys
virtual void rmkeys(
const string &prefix, ///< [in] Prefix to search for
const std::set<string> &keys ///< [in] Keys to remove
) = 0;
/// Removes keys beginning with prefix
virtual void rmkeys_by_prefix(
const string &prefix ///< [in] Prefix by which to remove keys
) = 0;
virtual ~TransactionImpl() {};
};
typedef std::tr1::shared_ptr< TransactionImpl > Transaction;
virtual Transaction get_transaction() = 0;
virtual int submit_transaction(Transaction) = 0;
virtual int submit_transaction_sync(Transaction t) {
return submit_transaction(t);
}
/// Retrieve Keys
virtual int get(
const string &prefix, ///< [in] Prefix for key
const std::set<string> &key, ///< [in] Key to retrieve
std::map<string, bufferlist> *out ///< [out] Key value retrieved
) = 0;
class IteratorImpl : public ObjectMap::ObjectMapIteratorImpl {
public:
virtual int seek_to_first() = 0;
virtual int seek_to_last() = 0;
virtual int upper_bound(const string &after) = 0;
virtual int lower_bound(const string &to) = 0;
virtual bool valid() = 0;
virtual int next() = 0;
virtual int prev() = 0;
virtual string key() = 0;
virtual bufferlist value() = 0;
virtual int status() = 0;
virtual ~IteratorImpl() {}
};
typedef std::tr1::shared_ptr< IteratorImpl > Iterator;
virtual Iterator get_iterator(const string &prefix) = 0;
virtual ~KeyValueDB() {}
};
#endif
|