src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
2 / 2
100.0%
Branches:
2 / 4
50.0%
Functions:
1 / 1
100.0%

storage/ssd_layout/ssd_layout.h
Line Branch Exec Source
1 #pragma once
2
3 #include <cstdint>
4 #include <string>
5 #include <utility>
6 #include <vector>
7
8 namespace ssd_layout {
9
10 inline constexpr uint64_t kMaxKey = (1ULL << 63) - 2;
11
12 enum class Strategy : uint32_t { kPlain = 0, kBandana = 1, kMaxEmbed = 2 };
13
14 struct Location {
15 uint64_t page_id = 0;
16 uint32_t byte_offset = 0;
17 16 bool operator==(const Location& other) const {
18
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 return page_id == other.page_id && byte_offset == other.byte_offset;
19 }
20 };
21
22 struct Hypergraph {
23 uint64_t vertex_count = 0;
24 std::vector<uint64_t> xpins;
25 std::vector<uint32_t> pins;
26 };
27
28 struct Artifact {
29 Strategy strategy = Strategy::kBandana;
30 uint32_t page_size = 4096;
31 uint32_t row_size = 0;
32 uint64_t checksum = 0;
33 std::vector<uint64_t> keys;
34 std::vector<std::vector<Location>> copies;
35 std::vector<std::vector<std::pair<uint64_t, uint32_t>>> pages;
36 };
37
38 Strategy ParseStrategy(const std::string& name);
39 const char* StrategyName(Strategy strategy);
40
41 Hypergraph ReadQueryLog(const std::string& path, bool binary);
42 std::vector<uint64_t>
43 ReadKeyMap(const std::string& path, uint64_t vertex_count);
44
45 Artifact Partition(const Hypergraph& graph,
46 const std::vector<uint64_t>& keys,
47 uint32_t page_size,
48 uint32_t row_size);
49 Artifact Replicate(const Artifact& partitioned,
50 const Hypergraph& graph,
51 const std::vector<uint64_t>& keys,
52 double rep_ratio);
53 Artifact Shrink(const Artifact& replicated, double rep_ratio);
54
55 Artifact Normalize(Artifact artifact);
56 void SaveArtifact(const Artifact& artifact, const std::string& path);
57 Artifact LoadArtifact(const std::string& path);
58 void CheckArtifact(
59 const Artifact& artifact, Strategy expected, uint32_t expected_row_size);
60
61 } // namespace ssd_layout
62