2014-12-09 17:45:33 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
|
|
|
|
#define BLOBSTORE_IMPLEMENTATIONS_ONBLOCKS_BLOBONBLOCKS_H_
|
|
|
|
|
2015-02-17 00:40:34 +01:00
|
|
|
#include "../../interface/Blob.h"
|
2014-12-09 17:56:48 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
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-09 15:40:27 +02:00
|
|
|
namespace cachingdatatreestore {
|
|
|
|
class CachedDataTreeRef;
|
2014-12-13 19:17:08 +01:00
|
|
|
}
|
2014-12-09 17:45:33 +01:00
|
|
|
|
2014-12-09 17:56:48 +01:00
|
|
|
class BlobOnBlocks: public Blob {
|
2014-12-09 17:45:33 +01:00
|
|
|
public:
|
2015-04-09 15:40:27 +02:00
|
|
|
BlobOnBlocks(std::unique_ptr<cachingdatatreestore::CachedDataTreeRef> datatree);
|
2014-12-09 17:45:33 +01:00
|
|
|
virtual ~BlobOnBlocks();
|
2014-12-09 17:56:48 +01:00
|
|
|
|
2015-02-27 00:18:26 +01:00
|
|
|
blockstore::Key key() const override;
|
|
|
|
|
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-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 15:40:27 +02:00
|
|
|
std::unique_ptr<cachingdatatreestore::CachedDataTreeRef> 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
|
|
|
|
2015-03-04 20:58:39 +01:00
|
|
|
void traverseLeaves(uint64_t offsetBytes, uint64_t sizeBytes, std::function<void (uint64_t, datanodestore::DataLeafNode *, uint32_t, uint32_t)>) const;
|
2015-03-04 03:29:22 +01:00
|
|
|
void resizeIfSmallerThan(uint64_t neededSize);
|
2015-02-26 20:19:12 +01:00
|
|
|
|
2015-04-09 15:40:27 +02:00
|
|
|
std::unique_ptr<cachingdatatreestore::CachedDataTreeRef> _datatree;
|
2014-12-09 17:45:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|