-
Notifications
You must be signed in to change notification settings - Fork 50
/
SqLiteImpl.hpp
148 lines (126 loc) · 4.32 KB
/
SqLiteImpl.hpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#pragma once
#ifndef GEODE_SQLITEIMPL_SQLITEIMPL_H_
#define GEODE_SQLITEIMPL_SQLITEIMPL_H_
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "SqLiteHelper.hpp"
/**
* @file
*/
namespace apache {
namespace geode {
namespace client {
/**
* @class SqLite(3.7) Implementation SqLiteImpl.hpp
* SqLite API for overflow.
* The SqLiteImpl class derives from PersistenceManager base class and
* implements a persistent store with SqLite DB.
*
*/
class SqLiteImpl : public PersistenceManager {
/**
* @brief public methods
*/
public:
/**
* Initializes the DB for the region. SqLite settings are passed via
* diskProperties argument.
* @throws InitfailedException if persistence directory/environment directory
* initialization fails.
*/
void init(const std::shared_ptr<Region>& regionptr,
const std::shared_ptr<Properties>& diskProperties) override;
/**
* Stores a key-value pair in the SqLite implementation.
* @param key the key to write.
* @param value the value to write
* @throws DiskFailureException if the write fails due to disk failure.
*/
void write(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
std::shared_ptr<void>& dbHandle) override;
/**
* Writes the entire region into the SqLite implementation.
* @throws DiskFailureException if the write fails due to disk fail.
*/
bool writeAll() override;
/**
* Reads the value for the key from SqLite.
* @returns value of type std::shared_ptr<Cacheable>.
* @param key is the key for which the value has to be read.
* @throws IllegalArgumentException if the key is NULL.
* @throws DiskCorruptException if the data to be read is corrupt.
*/
std::shared_ptr<Cacheable> read(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<void>& dbHandle) override;
/**
* Read all the keys and values for a region stored in SqLite.
*/
bool readAll() override;
/**
* Invalidates an entry stored in SqLite.
* @throws IllegalArgumentException if the key is NULL.
* @throws RegionDestroyedException is the region is already destroyed.
* @throws EntryNotFoundException if the entry is not found on the disk.
*/
// void invalidate(const std::shared_ptr<CacheableKey>& key);
/**
* Destroys an entry stored in SqLite. .
* @throws IllegalArgumentException if the key is NULL.
* @throws RegionDestroyedException is the region is already destroyed.
* @throws EntryNotFoundException if the entry is not found on the disk.
*/
void destroy(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<void>& dbHandle) override;
/**
* Returns number of entries stored in SqLite for the region.
*/
// are we removing this method from PersistenceManager?
// int numEntries() const;
/**
* Destroys the region in the SqLite implementation.
* @throws RegionDestroyedException is the region is already destroyed.
*/
void destroyRegion();
/**
* Closes the SqLite persistence manager implementation.
* @throws ShutdownFailedException if clean-up of region and environment files
* fails..
*/
void close() override;
/**
* @brief destructor
*/
~SqLiteImpl() override = default;
/**
* @brief constructor
*/
SqLiteImpl();
/**
* @brief private members
*/
private:
std::unique_ptr<SqLiteHelper> m_sqliteHelper;
std::string m_regionDBFile;
std::string m_regionDir;
std::string m_persistanceDir;
};
} // namespace client
} // namespace geode
} // namespace apache
#endif // GEODE_SQLITEIMPL_SQLITEIMPL_H_