BTree::BTree (const std::string &name, unsigned int block_size, int tt, int kt, bool create_new_file)
{
- key_type = kt;
- tree_type = tt;
uchar *node;
BTreeNodeHeader nh;
/* Inicializo el header */
header.block_size = block_size;
+ header.tree_type = tt;
+ header.key_type = kt;
WriteFileHeader ();
/* Creo el primer bloque vacio */
while (it != node_keys.end ()) {
datait = (*it);
- if (tree_type == TYPE_IDENTIFICACION) {
+ if (header.tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
- if (tree_type == TYPE_IDENTIFICACION) {
+ if (header.tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
posterior = it;
while (it != node_keys.end ()) {
- if (tree_type == TYPE_IDENTIFICACION) {
+ if (header.tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*(*it))) {
throw new AddException ();
while (it != node_keys.end ()) {
datait = (*it);
- if (tree_type == TYPE_IDENTIFICACION) {
+ if (header.tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
- if (tree_type == TYPE_IDENTIFICACION) {
+ if (header.tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
for (uint i=0; i<count; i++) {
BTreeData *data;
if (node_header.level == 0) {
- data = new BTreeLeafData (node, key_type);
+ data = new BTreeLeafData (node, header.key_type);
} else {
- data = new BTreeData (node, key_type);
+ data = new BTreeData (node, header.key_type);
}
node += data->Size ();
keys.push_back (data);
void BTree::AbrevKey (std::list<BTreeData *> &lst)
{
/* Claves Fijas No se abrevian */
- if (key_type == KEY_FIXED) return;
+ if (header.key_type == KEY_FIXED) return;
BTreeData *primera = NULL;
std::list<BTreeData *>::iterator it = lst.begin ();
void BTree::DeAbrevKey (std::list<BTreeData *> &lst)
{
/* Claves Fijas No se abrevian */
- if (key_type == KEY_FIXED) return;
+ if (header.key_type == KEY_FIXED) return;
BTreeData *primera = NULL;
std::list<BTreeData *>::iterator it = lst.begin ();
int BTree::type () const
{
- return key_type;
+ return header.key_type;
}