BlobOnBlocks stores DataTrees, not DataNodes

This commit is contained in:
Sebastian Messmer 2015-02-25 22:48:39 +01:00
parent 0f3314b31c
commit 0f40619a4a
4 changed files with 19 additions and 15 deletions

View File

@ -1,16 +1,17 @@
#include "BlobOnBlocks.h"
#include "datanodestore/DataNode.h"
#include "datatreestore/DataTree.h"
#include <cassert>
using std::unique_ptr;
namespace blobstore {
namespace onblocks {
using datanodestore::DataNode;
using datatreestore::DataTree;
BlobOnBlocks::BlobOnBlocks(unique_ptr<DataNode> rootnode)
: _rootnode(std::move(rootnode)) {
BlobOnBlocks::BlobOnBlocks(unique_ptr<DataTree> datatree)
: _datatree(std::move(datatree)) {
}
@ -23,7 +24,7 @@ size_t BlobOnBlocks::size() const {
}
void BlobOnBlocks::flush() const {
_rootnode->flush();
_datatree->flush();
}
}

View File

@ -8,13 +8,13 @@
namespace blobstore {
namespace onblocks {
namespace datanodestore {
class DataNode;
namespace datatreestore {
class DataTree;
}
class BlobOnBlocks: public Blob {
public:
BlobOnBlocks(std::unique_ptr<datanodestore::DataNode> rootnode);
BlobOnBlocks(std::unique_ptr<datatreestore::DataTree> datatree);
virtual ~BlobOnBlocks();
size_t size() const override;
@ -22,7 +22,7 @@ public:
void flush() const override;
private:
std::unique_ptr<datanodestore::DataNode> _rootnode;
std::unique_ptr<datatreestore::DataTree> _datatree;
};
}

View File

@ -1,5 +1,7 @@
#include "datanodestore/DataLeafNode.h"
#include "datanodestore/DataNodeStore.h"
#include "datatreestore/DataTreeStore.h"
#include "datatreestore/DataTree.h"
#include "BlobStoreOnBlocks.h"
#include "BlobOnBlocks.h"
@ -14,22 +16,23 @@ namespace blobstore {
namespace onblocks {
using datanodestore::DataNodeStore;
using datatreestore::DataTreeStore;
constexpr size_t BlobStoreOnBlocks::BLOCKSIZE_BYTES;
BlobStoreOnBlocks::BlobStoreOnBlocks(unique_ptr<BlockStore> blockStore)
: _nodes(make_unique<DataNodeStore>(std::move(blockStore), BLOCKSIZE_BYTES)) {
: _dataTreeStore(make_unique<DataTreeStore>(make_unique<DataNodeStore>(std::move(blockStore), BLOCKSIZE_BYTES))) {
}
BlobStoreOnBlocks::~BlobStoreOnBlocks() {
}
unique_ptr<Blob> BlobStoreOnBlocks::create() {
return make_unique<BlobOnBlocks>(_nodes->createNewLeafNode());
return make_unique<BlobOnBlocks>(_dataTreeStore->createNewTree());
}
unique_ptr<Blob> BlobStoreOnBlocks::load(const Key &key) {
return make_unique<BlobOnBlocks>(_nodes->load(key));
return make_unique<BlobOnBlocks>(_dataTreeStore->load(key));
}
}

View File

@ -7,8 +7,8 @@
namespace blobstore {
namespace onblocks {
namespace datanodestore {
class DataNodeStore;
namespace datatreestore {
class DataTreeStore;
}
class BlobStoreOnBlocks: public BlobStore {
@ -22,7 +22,7 @@ public:
std::unique_ptr<Blob> load(const blockstore::Key &key) override;
private:
std::unique_ptr<datanodestore::DataNodeStore> _nodes;
std::unique_ptr<datatreestore::DataTreeStore> _dataTreeStore;
};
}