mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
PaxStore.hpp
Go to the documentation of this file.
1#pragma once
2
6
7
8namespace m {
9
12{
13#ifndef NDEBUG
14 static constexpr std::size_t ALLOCATION_SIZE = 1UL << 30;
15#else
16 static constexpr std::size_t ALLOCATION_SIZE = 1UL << 37;
17#endif
18
19 static constexpr uint32_t BLOCK_SIZE = 1UL << 12;
20
21 private:
24 std::size_t num_rows_ = 0;
25 std::size_t capacity_;
26 uint32_t *offsets_;
27 uint32_t block_size_;
28 std::size_t num_rows_per_block_;
29
30 public:
31 PaxStore(const Table &table, uint32_t block_size_in_bytes = BLOCK_SIZE);
32 ~PaxStore();
33
34 virtual std::size_t num_rows() const override { return num_rows_; }
35 std::size_t num_rows_per_block() const { return num_rows_per_block_; }
36 uint32_t block_size() const { return block_size_; }
37
38 uint32_t offset(uint32_t idx) const {
39 M_insist(idx <= table().num_attrs(), "index out of range");
40 return offsets_[idx];
41 }
42 uint32_t offset(const Attribute &attr) const { return offset(attr.id); }
43
44 void append() override {
45 if (num_rows_ == capacity_)
46 throw std::logic_error("row store exceeds capacity");
47 ++num_rows_;
48 }
49
50 void drop() override {
52 --num_rows_;
53 }
54
56 const memory::Memory & memory() const override { return data_; }
57
58 void dump(std::ostream &out) const override;
59 using Store::dump;
60
61 private:
66};
67
68}
#define M_insist(...)
Definition: macro.hpp:129
‍mutable namespace
Definition: Backend.hpp:10
An attribute of a table.
Definition: Schema.hpp:289
std::size_t id
the internal identifier of the attribute, unique within its table
Definition: Schema.hpp:292
This class implements a generic PAX store.
Definition: PaxStore.hpp:12
uint32_t block_size_
the size of a PAX block, in bytes; includes padding
Definition: PaxStore.hpp:27
std::size_t num_rows_per_block() const
Definition: PaxStore.hpp:35
void dump() const
Definition: Store.cpp:14
static constexpr std::size_t ALLOCATION_SIZE
1 GiB
Definition: PaxStore.hpp:14
void compute_block_offsets()
Computes the offsets of the columns within a PAX block, the rows size, the number of rows that fit in...
Definition: PaxStore.cpp:29
const memory::Memory & memory() const override
Returns the memory of the store.
Definition: PaxStore.hpp:56
uint32_t block_size() const
Definition: PaxStore.hpp:36
memory::Memory data_
the underlying memory containing the data
Definition: PaxStore.hpp:23
virtual std::size_t num_rows() const override
Return the number of rows in this store.
Definition: PaxStore.hpp:34
std::size_t num_rows_per_block_
the number of rows within a PAX block
Definition: PaxStore.hpp:28
std::size_t num_rows_
the number of rows in use
Definition: PaxStore.hpp:24
uint32_t offset(uint32_t idx) const
Definition: PaxStore.hpp:38
memory::LinearAllocator allocator_
the memory allocator
Definition: PaxStore.hpp:22
static constexpr uint32_t BLOCK_SIZE
4 KiB
Definition: PaxStore.hpp:19
void drop() override
Drop the most recently appended row.
Definition: PaxStore.hpp:50
void append() override
Append a row to the store.
Definition: PaxStore.hpp:44
std::size_t capacity_
the number of available rows
Definition: PaxStore.hpp:25
uint32_t offset(const Attribute &attr) const
Definition: PaxStore.hpp:42
uint32_t * offsets_
the offsets of each column within a PAX block, in bits
Definition: PaxStore.hpp:26
Defines a generic store interface.
Definition: Store.hpp:22
void dump() const
Definition: Store.cpp:14
const Table & table() const
Definition: Store.hpp:36
A table is a sorted set of attributes.
Definition: Schema.hpp:388
This is the simplest kind of allocator.
Definition: memory.hpp:139
Represents a mapping created by a memory::Allocator.
Definition: memory.hpp:78