-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPlusTreeNode.h
executable file
·53 lines (41 loc) · 1006 Bytes
/
BPlusTreeNode.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
43
44
45
46
47
48
49
50
51
52
#ifndef _BPLUSTREENODE_H
#define _BPLUSTREENODE_H
#include <algorithm>
#include <cassert>
#include "BufferManager.h"
using namespace std;
#define NULLPOINTER -1
namespace BPlusTree {
typedef vector<char> Key; //Ë÷ÒýÖµÀàÐÍ
typedef int Pointer; //Ö¸ÕëÀàÐÍ
struct NodeHeader { //¿éÍ·
bool mIsUsed;
bool mIsLeaf;
int mKeyNumber;
Pointer mFather;
};
const int nodeHeaderSize = sizeof(NodeHeader);
const int pointerSize = sizeof(Pointer);
class Node {
public:
Node(int keySize);
Node(int keySize, int fileOffset);
Node(int keySize, int fileOffset, const vector<char>& blockData);
virtual ~Node();
friend class Tree;
//member function
vector<char> toData();
private:
int mKeySize;
bool mIsLeaf;
int mFileOffset;
Pointer mFather;
vector<Key> mKeys;
vector<Pointer> mPointers;
//member function
void initialNode(const vector<char>& blockData);
NodeHeader getNodeHeader();
static NodeHeader getNodeHeader(const vector<char>& blockData);
};
}
#endif