2015-04-16 15:01:49 +02:00
|
|
|
#include "parallelaccessdatatreestore/DataTreeRef.h"
|
|
|
|
#include "parallelaccessdatatreestore/ParallelAccessDataTreeStore.h"
|
2015-04-16 14:10:58 +02:00
|
|
|
#include <messmer/blockstore/implementations/parallelaccess/ParallelAccessBlockStore.h>
|
2015-02-17 00:40:34 +01:00
|
|
|
#include "datanodestore/DataLeafNode.h"
|
|
|
|
#include "datanodestore/DataNodeStore.h"
|
2015-02-25 22:48:39 +01:00
|
|
|
#include "datatreestore/DataTreeStore.h"
|
|
|
|
#include "datatreestore/DataTree.h"
|
2014-12-09 17:56:48 +01:00
|
|
|
#include "BlobStoreOnBlocks.h"
|
|
|
|
#include "BlobOnBlocks.h"
|
2015-06-21 17:43:45 +02:00
|
|
|
#include <messmer/cpp-utils/pointer/cast.h>
|
2015-07-22 13:42:44 +02:00
|
|
|
#include <messmer/cpp-utils/assert/assert.h>
|
2014-12-09 17:56:48 +01:00
|
|
|
|
2015-06-18 12:45:37 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
|
|
|
|
2014-12-09 17:56:48 +01:00
|
|
|
using blockstore::BlockStore;
|
2015-04-16 14:10:58 +02:00
|
|
|
using blockstore::parallelaccess::ParallelAccessBlockStore;
|
2014-12-13 19:17:08 +01:00
|
|
|
using blockstore::Key;
|
2015-03-06 02:21:20 +01:00
|
|
|
using cpputils::dynamic_pointer_move;
|
2015-06-18 12:45:37 +02:00
|
|
|
using boost::optional;
|
|
|
|
using boost::none;
|
2014-12-09 17:45:33 +01:00
|
|
|
|
|
|
|
namespace blobstore {
|
|
|
|
namespace onblocks {
|
|
|
|
|
2014-12-13 19:17:08 +01:00
|
|
|
using datanodestore::DataNodeStore;
|
2015-02-25 22:48:39 +01:00
|
|
|
using datatreestore::DataTreeStore;
|
2015-04-16 15:01:49 +02:00
|
|
|
using parallelaccessdatatreestore::ParallelAccessDataTreeStore;
|
2014-12-13 19:17:08 +01:00
|
|
|
|
2015-06-26 15:59:18 +02:00
|
|
|
BlobStoreOnBlocks::BlobStoreOnBlocks(unique_ref<BlockStore> blockStore, uint32_t blocksizeBytes)
|
|
|
|
: _dataTreeStore(make_unique_ref<ParallelAccessDataTreeStore>(make_unique_ref<DataTreeStore>(make_unique_ref<DataNodeStore>(make_unique_ref<ParallelAccessBlockStore>(std::move(blockStore)), blocksizeBytes)))) {
|
2014-12-09 17:45:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BlobStoreOnBlocks::~BlobStoreOnBlocks() {
|
|
|
|
}
|
|
|
|
|
2015-06-18 12:45:37 +02:00
|
|
|
unique_ref<Blob> BlobStoreOnBlocks::create() {
|
|
|
|
return make_unique_ref<BlobOnBlocks>(_dataTreeStore->createNewTree());
|
2014-12-09 17:56:48 +01:00
|
|
|
}
|
|
|
|
|
2015-06-18 12:45:37 +02:00
|
|
|
optional<unique_ref<Blob>> BlobStoreOnBlocks::load(const Key &key) {
|
2015-03-06 02:21:20 +01:00
|
|
|
auto tree = _dataTreeStore->load(key);
|
2015-06-26 15:59:18 +02:00
|
|
|
if (tree == none) {
|
2015-06-18 12:45:37 +02:00
|
|
|
return none;
|
2015-03-06 02:21:20 +01:00
|
|
|
}
|
2015-06-26 15:59:18 +02:00
|
|
|
return optional<unique_ref<Blob>>(make_unique_ref<BlobOnBlocks>(std::move(*tree)));
|
2015-03-06 02:21:20 +01:00
|
|
|
}
|
|
|
|
|
2015-06-18 12:45:37 +02:00
|
|
|
void BlobStoreOnBlocks::remove(unique_ref<Blob> blob) {
|
2015-03-06 02:21:20 +01:00
|
|
|
auto _blob = dynamic_pointer_move<BlobOnBlocks>(blob);
|
2015-07-22 13:42:44 +02:00
|
|
|
ASSERT(_blob != none, "Passed Blob in BlobStoreOnBlocks::remove() is not a BlobOnBlocks.");
|
2015-06-18 19:34:24 +02:00
|
|
|
_dataTreeStore->remove((*_blob)->releaseTree());
|
2014-12-09 17:56:48 +01:00
|
|
|
}
|
|
|
|
|
2014-12-09 17:45:33 +01:00
|
|
|
}
|
|
|
|
}
|