2828#include " anticache/NVMAntiCacheDB.h"
2929#include " anticache/AntiCacheEvictionManager.h"
3030#include " execution/VoltDBEngine.h"
31+ #define MAX_LEVELS 5
32+
3133#endif
3234
3335namespace voltdb {
@@ -193,8 +195,8 @@ namespace voltdb {
193195 * Return the handle to disk-based storage object that we
194196 * can use to read and write tuples to
195197 */
196- AntiCacheDB* getAntiCacheDB () const {
197- return m_antiCacheDB;
198+ AntiCacheDB* getAntiCacheDB (int level ) const {
199+ return m_antiCacheDB[level] ;
198200 }
199201
200202 /* *
@@ -204,6 +206,14 @@ namespace voltdb {
204206 AntiCacheEvictionManager* getAntiCacheEvictionManager () const {
205207 return m_antiCacheEvictionManager;
206208 }
209+
210+ /* *
211+ * Return the AntiCacheDBType associated with the given AntiCacheDB
212+ */
213+
214+ AntiCacheDBType getAntiCacheDBType (int level) {
215+ return m_dbType[level];
216+ }
207217
208218 /* *
209219 * Enable the anti-caching feature in the EE.
@@ -213,17 +223,24 @@ namespace voltdb {
213223 void enableAntiCache (const VoltDBEngine *engine, std::string &dbDir, long blockSize, AntiCacheDBType dbType) {
214224 assert (m_antiCacheEnabled == false );
215225 m_antiCacheEnabled = true ;
216- m_dbType = dbType;
226+ m_levels = 0 ;
227+ addAntiCacheDB (dbDir, blockSize, dbType);
228+ m_antiCacheEvictionManager = new AntiCacheEvictionManager (engine);
229+ }
230+
231+ void addAntiCacheDB (std::string &dbDir, long blockSize, AntiCacheDBType dbType) {
232+ assert (m_antiCacheEnabled == true );
233+ m_dbType[m_levels] = dbType;
217234 // MJG: need a better error return (throw exception?)
218235 if (dbType == ANTICACHEDB_BERKELEY ) {
219- m_antiCacheDB = new BerkeleyAntiCacheDB (this , dbDir, blockSize);
236+ m_antiCacheDB[m_levels] = new BerkeleyAntiCacheDB (this , dbDir, blockSize);
220237 } else if (dbType == ANTICACHEDB_NVM ) {
221- m_antiCacheDB = new NVMAntiCacheDB (this , dbDir, blockSize);
238+ m_antiCacheDB[m_levels] = new NVMAntiCacheDB (this , dbDir, blockSize);
222239 } else {
223240 VOLT_ERROR (" Invalid AntiCacheDBType: %d! Aborting..." , (int )dbType);
224241 assert (m_antiCacheEnabled == false );
225- }
226- m_antiCacheEvictionManager = new AntiCacheEvictionManager (engine) ;
242+ }
243+ m_levels++ ;
227244 }
228245 #endif
229246
@@ -299,9 +316,10 @@ namespace voltdb {
299316 int64_t m_txnId;
300317
301318 #ifdef ANTICACHE
302- AntiCacheDB *m_antiCacheDB;
319+ AntiCacheDB *m_antiCacheDB[ MAX_LEVELS ] ;
303320 AntiCacheEvictionManager *m_antiCacheEvictionManager;
304- AntiCacheDBType m_dbType;
321+ AntiCacheDBType m_dbType[MAX_LEVELS ];
322+ int m_levels;
305323 #endif
306324
307325 #ifdef STORAGE_MMAP
0 commit comments