-
Notifications
You must be signed in to change notification settings - Fork 0
/
btree_node.h
44 lines (40 loc) · 1.15 KB
/
btree_node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <stdint.h>
#include <map>
#include <vector>
class BTreeNode {
public:
BTreeNode(int order, uint64_t ref, bool is_leaf);
BTreeNode(BTreeNode &&);
friend bool operator==(const BTreeNode &, const BTreeNode &);
void put(int key);
void put(const BTreeNode &node);
uint64_t next(int key) const;
std::map<int, uint64_t> keys() const;
void removeKey(int key);
int order() const;
int keysNum() const;
bool isFull() const;
uint64_t ref() const;
bool isLeaf() const;
uint64_t sentinel() const;
int minKey() const;
int maxKey() const;
bool contains(int key) const;
uint64_t nextChild(int key) const;
uint64_t prevChild(int key) const;
void setIsLeaf(bool is_leaf);
void setSentinel(uint64_t child);
void setKeysNum(int keys_num);
void addChild(int key, uint64_t child);
int serialize(uint8_t *page) const;
static BTreeNode deserialize(const uint8_t *page, int page_size);
static int maxNodeSerializationSize(int order);
private:
int _order;
int _keys_num;
uint64_t _ref;
bool _is_leaf;
uint64_t _sentinel;
std::map<int, uint64_t> _keys;
};