Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
blockstore.h
1 #pragma once
2 #include "volume.h"
3 
4 namespace Akumuli {
5 namespace StorageEngine {
6 
8 typedef uint64_t LogicAddr;
9 
10 class Block;
11 
15 class BlockStore : public std::enable_shared_from_this<BlockStore>
16 {
17  std::unique_ptr<MetaVolume> meta_;
18  std::vector<std::unique_ptr<Volume>> volumes_;
19  std::vector<int> dirty_;
20  uint32_t current_volume_;
21  uint32_t current_gen_;
22 
23  BlockStore(std::string metapath, std::vector<std::string> volpaths);
24 
25  void advance_volume();
26 public:
29  static std::shared_ptr<BlockStore> open(std::string metapath, std::vector<std::string> volpaths);
30 
33  std::tuple<aku_Status, std::shared_ptr<Block> > read_block(LogicAddr addr);
34 
39  std::tuple<aku_Status, LogicAddr> append_block(uint8_t const* data);
40 
41  void flush();
42 
43  // TODO: add static create fn
44 };
45 
47 class Block {
48  std::weak_ptr<BlockStore> store_;
49  std::vector<uint8_t> data_;
50  LogicAddr addr_;
51 public:
52  Block(std::shared_ptr<BlockStore> bs, LogicAddr addr, std::vector<uint8_t>&& data);
53 
54  const uint8_t* get_data() const;
55 
56  size_t get_size() const;
57 };
58 
59 }} // namespace
std::tuple< aku_Status, std::shared_ptr< Block > > read_block(LogicAddr addr)
Definition: blockstore.cpp:80
Definition: blockstore.h:15
std::tuple< aku_Status, LogicAddr > append_block(uint8_t const *data)
Definition: blockstore.cpp:132
Represents memory block.
Definition: blockstore.h:47
static std::shared_ptr< BlockStore > open(std::string metapath, std::vector< std::string > volpaths)
Definition: blockstore.cpp:67