-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt_node.h
107 lines (80 loc) · 2.13 KB
/
bt_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// 91574 Database II - C++ Programming
// Swathi Kurunji, UMass Lowell, MA, 2011
// bt_node.h - definition of class BtreeNode for this project.
#ifndef BT_NODE_H
#define BT_NODE_H
#include<iostream>
#include<cstdlib>
using namespace std;
#include "bt_errors.h"
// BtreeNode is the basic structure of B+tree nodes
// Each BtreeNode will be of one page size which is 1024
class BtreeNode
{
protected:
//NodeId nodeNo; //node number of the BtreeNode.
int type; //can be index or leaf
int keyCount; //number of keys in the node
KeyId key[MAX_NUM_KEYS]; //key of the record
BtreeNode *ptr[MAX_NUM_PTRS]; //In leaf node pointers will be null
BtreeNode *parentPtr;
public:
BtreeNode();
virtual ~BtreeNode();
//void init();
int get_keyCount();
void set_keyCount( int );
//set type of node
void set_type( int );
//get type of node. used while insertion, deletion or scan of record
int get_type();
KeyId getKey( int n )
{
return key[n];
}
void setKey( int n, KeyId newKey )
{
key[n] = newKey;
}
BtreeNode* getPtr( int n )
{
return ptr[n];
}
void setPtr( BtreeNode *pointer, int n )
{
ptr[n] = pointer;
}
BtreeNode* get_parentPtr();
void set_parentPtr( BtreeNode *pointer );
//insert function with 4 parameters - needed for BtreeIndex
virtual Status insertKey( KeyId, int, BtreeNode*& leftChild,
BtreeNode*& rightChild )
{
cout << "U r in wrong place" << endl;
return OK;
}
//insert function with 2 parameters - BtreeLeaf
virtual Status insertKey( KeyId, int )
{
cout << "U r in wrong place" << endl;
return OK;
}
virtual Status deleteKey( KeyId, int )
{
cout << "U r in wrong place" << endl;
return OK;
}
//search function with 3 parameters - needed for BtreeIndex, where childPtr will be set to the pointer on which we need to move downwards in tree
virtual Status searchKey( KeyId, int, BtreeNode*& childPtr )
{
cout << "U r in wrong place" << endl;
return OK;
}
//search function with 2 parameters - BtreeLeaf
virtual Status searchKey( KeyId, int )
{
cout << "U r in wrong place" << endl;
return OK;
}
};
#endif