Remove fixed block identifiers
This commit is contained in:
committed by
Patrick Niklaus
parent
f3b7ab92ff
commit
4a9fdca7b2
@@ -15,17 +15,16 @@ ProcessMemoryAllocator::ProcessMemoryAllocator(const storage::StorageConfig &con
|
||||
storage::Storage storage(config);
|
||||
|
||||
// Calculate the layout/size of the memory block
|
||||
internal_layout = std::make_unique<storage::DataLayout>();
|
||||
storage.PopulateLayout(*internal_layout);
|
||||
storage.PopulateLayout(internal_layout);
|
||||
|
||||
// Allocate the memory block, then load data from files into it
|
||||
internal_memory = std::make_unique<char[]>(internal_layout->GetSizeOfLayout());
|
||||
storage.PopulateData(*internal_layout, internal_memory.get());
|
||||
internal_memory = std::make_unique<char[]>(internal_layout.GetSizeOfLayout());
|
||||
storage.PopulateData(internal_layout, internal_memory.get());
|
||||
}
|
||||
|
||||
ProcessMemoryAllocator::~ProcessMemoryAllocator() {}
|
||||
|
||||
storage::DataLayout &ProcessMemoryAllocator::GetLayout() { return *internal_layout.get(); }
|
||||
const storage::DataLayout &ProcessMemoryAllocator::GetLayout() { return internal_layout; }
|
||||
char *ProcessMemoryAllocator::GetMemory() { return internal_memory.get(); }
|
||||
|
||||
} // namespace datafacade
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "engine/datafacade/shared_memory_allocator.hpp"
|
||||
|
||||
#include "storage/serialization.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include "boost/assert.hpp"
|
||||
@@ -16,17 +19,21 @@ SharedMemoryAllocator::SharedMemoryAllocator(storage::SharedDataType data_region
|
||||
|
||||
BOOST_ASSERT(storage::SharedMemory::RegionExists(data_region));
|
||||
m_large_memory = storage::makeSharedMemory(data_region);
|
||||
|
||||
storage::io::BufferReader reader(GetMemory());
|
||||
storage::serialization::read(reader, data_layout);
|
||||
layout_size = reader.GetPosition();
|
||||
}
|
||||
|
||||
SharedMemoryAllocator::~SharedMemoryAllocator() {}
|
||||
|
||||
storage::DataLayout &SharedMemoryAllocator::GetLayout()
|
||||
const storage::DataLayout &SharedMemoryAllocator::GetLayout()
|
||||
{
|
||||
return *reinterpret_cast<storage::DataLayout *>(m_large_memory->Ptr());
|
||||
return data_layout;
|
||||
}
|
||||
char *SharedMemoryAllocator::GetMemory()
|
||||
{
|
||||
return reinterpret_cast<char *>(m_large_memory->Ptr()) + sizeof(storage::DataLayout);
|
||||
return reinterpret_cast<char *>(m_large_memory->Ptr()) + layout_size;
|
||||
}
|
||||
|
||||
} // namespace datafacade
|
||||
|
||||
Reference in New Issue
Block a user