2014-12-09 17:45:33 +01:00
|
|
|
#pragma once
|
2015-10-15 13:10:20 +02:00
|
|
|
#ifndef MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
|
|
|
|
#define MESSMER_BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
|
2014-12-09 17:45:33 +01:00
|
|
|
|
2015-02-17 00:40:34 +01:00
|
|
|
#include "../../interface/Blob.h"
|
2016-07-15 21:06:41 +02:00
|
|
|
#include "datatreestore/LeafHandle.h"
|
2014-12-09 17:56:48 +01:00
|
|
|
|
|
|
|
#include <memory>
|
2015-10-05 03:45:00 +02:00
|
|
|
#include <boost/optional.hpp>
|
2019-01-13 08:21:12 +01:00
|
|
|
#include <boost/thread/shared_mutex.hpp>
|
2014-12-09 17:56:48 +01:00
|
|
|
|
2014-12-09 17:45:33 +01:00
|
|
|
namespace blobstore {
|
|
|
|
namespace onblocks {
|
2015-02-26 20:19:12 +01:00
|
|
|
namespace datanodestore {
|
|
|
|
class DataLeafNode;
|
|
|
|
}
|
2015-04-16 15:01:49 +02:00
|
|
|
namespace parallelaccessdatatreestore {
|
|
|
|
class DataTreeRef;
|
2014-12-13 19:17:08 +01:00
|
|
|
}
|
2014-12-09 17:45:33 +01:00
|
|
|
|
2015-11-27 14:06:48 +01:00
|
|
|
class BlobOnBlocks final: public Blob {
|
2014-12-09 17:45:33 +01:00
|
|
|
public:
|
2015-06-26 15:59:18 +02:00
|
|
|
BlobOnBlocks(cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> datatree);
|
2015-11-27 14:06:48 +01:00
|
|
|
~BlobOnBlocks();
|
2014-12-09 17:56:48 +01:00
|
|
|
|
2017-09-17 03:07:27 +02:00
|
|
|
const blockstore::BlockId &blockId() const override;
|
2015-02-27 00:18:26 +01:00
|
|
|
|
2015-02-26 17:33:47 +01:00
|
|
|
uint64_t size() const override;
|
|
|
|
void resize(uint64_t numBytes) override;
|
2014-12-09 17:56:48 +01:00
|
|
|
|
2015-10-05 03:45:00 +02:00
|
|
|
cpputils::Data readAll() const override;
|
2015-02-27 01:28:53 +01:00
|
|
|
void read(void *target, uint64_t offset, uint64_t size) const override;
|
2015-03-11 01:04:48 +01:00
|
|
|
uint64_t tryRead(void *target, uint64_t offset, uint64_t size) const override;
|
2015-02-27 01:28:53 +01:00
|
|
|
void write(const void *source, uint64_t offset, uint64_t size) override;
|
2015-02-26 20:19:12 +01:00
|
|
|
|
2015-04-09 23:41:51 +02:00
|
|
|
void flush() override;
|
|
|
|
|
2019-01-22 10:09:06 +01:00
|
|
|
uint32_t numNodes() const override;
|
|
|
|
|
2015-06-26 15:59:18 +02:00
|
|
|
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> releaseTree();
|
2015-03-06 02:21:20 +01:00
|
|
|
|
2014-12-09 17:56:48 +01:00
|
|
|
private:
|
2015-03-04 03:29:22 +01:00
|
|
|
|
2019-01-13 08:21:12 +01:00
|
|
|
uint64_t _tryRead(void *target, uint64_t offset, uint64_t size) const;
|
2015-10-05 03:45:00 +02:00
|
|
|
void _read(void *target, uint64_t offset, uint64_t count) const;
|
2016-07-15 21:06:41 +02:00
|
|
|
void _traverseLeaves(uint64_t offsetBytes, uint64_t sizeBytes, std::function<void (uint64_t leafOffset, datatreestore::LeafHandle leaf, uint32_t begin, uint32_t count)> onExistingLeaf, std::function<cpputils::Data (uint64_t beginByte, uint32_t count)> onCreateLeaf) const;
|
2015-02-26 20:19:12 +01:00
|
|
|
|
2015-06-26 15:59:18 +02:00
|
|
|
cpputils::unique_ref<parallelaccessdatatreestore::DataTreeRef> _datatree;
|
2015-11-27 14:06:48 +01:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BlobOnBlocks);
|
2014-12-09 17:45:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|