Permalink
Browse files

Allocate "in-space" NVM using Pool.hpp.

  • Loading branch information...
malin1993ml committed Nov 28, 2015
1 parent 8f339be commit ab56f88fd9f22650d74b356e7e4eb96a3f4d482a
@@ -29,7 +29,11 @@
namespace voltdb {
NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx) : PersistentTable(ctx, false) {
//NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx) : PersistentTable(ctx, false) {
NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx, const std::string name) : PersistentTable(ctx, false) {
delete m_pool;
m_pool = new Pool(1024 * 1024 * 1024, 1024, m_executorContext->getDBDir() + "/" + name, true);
}
@@ -52,7 +56,8 @@ const void* NVMEvictedTable::insertNVMEvictedTuple(TableTuple &source) {
m_tupleCount++;
// Then copy the source into the target
m_tmpTarget1.copyForPersistentInsert(source);
//m_tmpTarget1.copyForPersistentInsert(source);
m_tmpTarget1.copyForPersistentInsert(source, m_pool);
m_tmpTarget1.setDeletedFalse();
// Make sure this tuple is marked as evicted, so that we know it is an
@@ -28,6 +28,7 @@
#include "storage/persistenttable.h"
#include "common/executorcontext.hpp"
#include "common/Pool.hpp"
namespace voltdb {
@@ -44,12 +45,38 @@ class NVMEvictedTable : public PersistentTable {
void deleteNVMEvictedTuple(TableTuple source);
protected:
NVMEvictedTable(ExecutorContext *ctx);
};
inline void allocateNextBlock() {
#ifdef MEMCHECK
int bytes = m_schema->tupleLength() + TUPLE_HEADER_SIZE;
#else
int bytes = m_tableAllocationTargetSize;
#endif
char *memory = NULL;
VOLT_WARN("MMAP : PId:: %d Table: %s Bytes:: %d ",
m_executorContext->getPartitionId(), this->name().c_str(), bytes);
memory = (char*)m_pool->allocate(bytes);
VOLT_WARN("MMAP : Table: %s :: Memory Pointer : %p ",
this->name().c_str(), memory);
if (memory == NULL) {
VOLT_ERROR("MMAP : initialization error.");
throwFatalException("Failed to map file.");
}
m_data.push_back(memory);
m_allocatedTuples += m_tuplesPerBlock;
}
//NVMEvictedTable(ExecutorContext *ctx);
NVMEvictedTable(ExecutorContext *ctx, const std::string name);
};
}
#endif
@@ -29,7 +29,8 @@ StringRef::create(size_t size, Pool* dataPool)
if (dataPool != NULL)
{
retval =
new(dataPool->allocate(sizeof(StringRef))) StringRef(size, dataPool);
new StringRef(size, dataPool);
//new(dataPool->allocate(sizeof(StringRef))) StringRef(size, dataPool);
}
else
{
@@ -53,6 +53,10 @@ namespace voltdb
char* get();
const char* get() const;
inline bool isUsingPool() {
return m_tempPool;
}
private:
StringRef(std::size_t size);
StringRef(std::size_t size, Pool* dataPool);
@@ -124,7 +124,8 @@ namespace voltdb {
inline std::string getDBDir() const {
if (m_MMAPDir.empty())
return "/tmp"; // Default : "/tmp"
return "/mnt/pmfs/mmap_file"; // Default : "/tmp"
//return "/tmp"; // Default : "/tmp"
return (m_MMAPDir);
}
@@ -68,8 +68,10 @@ void PersistentTableUndoUpdateAction::release() {
for (std::vector<char*>::iterator i = oldUninlineableColumns.begin();
i != oldUninlineableColumns.end(); i++)
{
StringRef::destroy((StringRef*)(*i));
//delete [] (*i);
//if (!((StringRef*)(*i))->isUsingPool()) {
StringRef::destroy((StringRef*)(*i));
//delete [] (*i);
//}
}
}
@@ -707,7 +707,11 @@ bool PersistentTable::updateTuple(TableTuple &source, TableTuple &target, bool u
}
/** TODO : Not Using MMAP pool **/
target.copyForPersistentUpdate(source, NULL);
if (!target.isNVMEvicted()) {
target.copyForPersistentUpdate(source, NULL);
} else {
target.copyForPersistentUpdate(source, getNVMEvictedTable()->getPool());
}
ptuua->setNewTuple(target, pool);
@@ -224,7 +224,8 @@ Table* TableFactory::getNVMEvictedTable(voltdb::CatalogId databaseId,
TupleSchema* schema,
const std::string* columnNames) {
VOLT_DEBUG("Creating %s", name.c_str());
Table *table = new NVMEvictedTable(ctx);
//Table *table = new NVMEvictedTable(ctx);
Table *table = new NVMEvictedTable(ctx, name);
NVMEvictedTable *pTable = dynamic_cast<NVMEvictedTable*>(table);
pTable->m_indexCount = 0;

0 comments on commit ab56f88

Please sign in to comment.