2014-12-09 18:53:11 +01:00
|
|
|
#include "DataInnerNode.h"
|
2015-01-22 23:37:03 +01:00
|
|
|
#include "DataLeafNode.h"
|
|
|
|
#include "DataNode.h"
|
|
|
|
#include "DataNodeStore.h"
|
2014-12-09 18:53:11 +01:00
|
|
|
|
|
|
|
using blockstore::Block;
|
2014-12-13 19:17:08 +01:00
|
|
|
using blockstore::Key;
|
2014-12-09 18:53:11 +01:00
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
using std::runtime_error;
|
|
|
|
|
|
|
|
namespace blobstore {
|
|
|
|
namespace onblocks {
|
2014-12-13 19:17:08 +01:00
|
|
|
namespace datanodestore {
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2015-01-24 22:27:14 +01:00
|
|
|
DataNode::DataNode(DataNodeView node)
|
|
|
|
: _node(std::move(node)) {
|
2014-12-09 18:53:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DataNode::~DataNode() {
|
|
|
|
}
|
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
DataNodeView &DataNode::node() {
|
|
|
|
return const_cast<DataNodeView&>(const_cast<const DataNode*>(this)->node());
|
|
|
|
}
|
2014-12-10 16:48:00 +01:00
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
const DataNodeView &DataNode::node() const {
|
|
|
|
return _node;
|
2014-12-09 18:53:11 +01:00
|
|
|
}
|
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
const Key &DataNode::key() const {
|
2015-01-24 22:27:14 +01:00
|
|
|
return _node.key();
|
2014-12-09 18:53:11 +01:00
|
|
|
}
|
|
|
|
|
2014-12-13 17:43:02 +01:00
|
|
|
uint8_t DataNode::depth() const {
|
2015-01-22 23:37:03 +01:00
|
|
|
return *node().Depth();
|
2014-12-10 22:55:02 +01:00
|
|
|
}
|
2014-12-09 18:53:11 +01:00
|
|
|
|
2015-01-24 00:54:27 +01:00
|
|
|
unique_ptr<DataInnerNode> DataNode::convertToNewInnerNode(unique_ptr<DataNode> node, const DataNode &first_child) {
|
|
|
|
Key key = node->key();
|
|
|
|
auto block = node->_node.releaseBlock();
|
|
|
|
std::memset(block->data(), 0, block->size());
|
|
|
|
|
2015-02-20 19:46:52 +01:00
|
|
|
return DataInnerNode::InitializeNewNode(std::move(block), first_child);
|
2015-01-24 00:54:27 +01:00
|
|
|
}
|
2015-01-22 23:37:03 +01:00
|
|
|
|
2015-01-28 01:02:32 +01:00
|
|
|
void DataNode::flush() const {
|
|
|
|
_node.flush();
|
|
|
|
}
|
|
|
|
|
2014-12-09 18:53:11 +01:00
|
|
|
}
|
|
|
|
}
|
2014-12-13 19:17:08 +01:00
|
|
|
}
|