I have designed a B-Tree and I am trying to make this B-Tree store variables of any data type in-built or user-defined and I am, thus, using template programming to design this data structure. I started out creating a B-Tree for storing unsigned ints in the RAM and ultimately got it to run and modified the program such that the data structure got read and written from/to the disk rather than physical memory.
The current status of this project is that I have different classes for different data types such as int, string and user defined data types but in the process of coding the B-Tree I did not pay attention to the design of a vital internal data structure of the B-Tree i.e. the design and representation of the nodes of the B-Tree. The size of the nodes of the B-Tree are aligned according to the page size and this alignment changes as the data type changes such as string, user defined data type. I can't make this structure dynamic as apparently the members of the structure have to be declared at compile time.
For instance the node structure of the B-Tree for ints is represented as:
struct Node{
unsigned int k[NUMBER];
Node * ptrs[NUMBER+1];
//...other members
}__attribute__((packed));
The NUMBER is selected in such a way that the node fits on the 4096 boundary.
I do not know how to make this work for ALL data types! The code is huge and I am trying a number of ways to make the code work. One idea I had was to forward declare the struct Node in the B-Tree.cpp file and compile the code with only the relevant class files such as Int.cpp, String.cpp, Userdefined.cpp and include the definition of Node and NUMBER in those class files but the compiler is throwing an error of incomplete type Node. What should I do to fix my code such that the container works for all data types and the Node struct gets aligned on the 4096(page size) boundary? I greatly appreciate all your replies! Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire