2015-02-17 00:23:33 +01:00
|
|
|
#include <messmer/blockstore/implementations/ondisk/OnDiskBlock.h>
|
|
|
|
#include <messmer/blockstore/implementations/ondisk/OnDiskBlockStore.h>
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
using std::string;
|
|
|
|
using std::mutex;
|
|
|
|
using std::lock_guard;
|
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
|
|
|
|
namespace blockstore {
|
|
|
|
namespace ondisk {
|
|
|
|
|
|
|
|
OnDiskBlockStore::OnDiskBlockStore(const boost::filesystem::path &rootdir)
|
|
|
|
: _rootdir(rootdir) {}
|
|
|
|
|
2014-12-09 20:36:32 +01:00
|
|
|
unique_ptr<Block> OnDiskBlockStore::create(const Key &key, size_t size) {
|
2015-01-24 22:08:41 +01:00
|
|
|
auto block = OnDiskBlock::CreateOnDisk(_rootdir, key, size);
|
2014-12-09 17:19:59 +01:00
|
|
|
|
|
|
|
if (!block) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-12-09 20:36:32 +01:00
|
|
|
return std::move(block);
|
2014-12-09 17:19:59 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 20:36:32 +01:00
|
|
|
unique_ptr<Block> OnDiskBlockStore::load(const Key &key) {
|
2015-01-24 22:08:41 +01:00
|
|
|
return OnDiskBlock::LoadFromDisk(_rootdir, key);
|
2014-12-09 17:19:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|