From 477697002803b11be48f7a9317c6c0f82e646cb9 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Wed, 23 Nov 2005 02:47:02 +0000 Subject: [PATCH 1/1] Incremento automatico de block_data. --- src/btree.cpp | 11 +++++++++-- src/btree.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/btree.cpp b/src/btree.cpp index 77967bf..fc62f5b 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -19,6 +19,7 @@ BTree::BTree (const std::string &name, unsigned int block_size, int tt, int kt, header.block_size = block_size; header.tree_type = tt; header.key_type = kt; + header.block_data_counter = 0; WriteFileHeader (); /* Creo el primer bloque vacio */ @@ -100,8 +101,7 @@ void BTree::AddKey (const Clave &k) Clave *kout, *in; in = k.Clone (); - /* TODO : Hacer un contador con recuperacion */ - in->SetBlockData (0); + in->SetBlockData ( GetNextBlockData () ); try { kout = AddKeyR (in->Clone (), 0, left, right); @@ -1298,3 +1298,10 @@ int BTree::type () const { return header.key_type; } + +uint BTree::GetNextBlockData () +{ + /* TODO : Implementar recuperacion */ + return header.block_data_counter++; +} + diff --git a/src/btree.h b/src/btree.h index 6feb5a8..1c08df4 100644 --- a/src/btree.h +++ b/src/btree.h @@ -210,6 +210,7 @@ struct BTreeFileHeader { uint block_size; int tree_type; int key_type; + uint block_data_counter; }; /** Encabezado de un bloque */ @@ -319,6 +320,8 @@ class BTree { std::string filename; BTreeFileHeader header; + uint GetNextBlockData (); + /** Apunta al archivo de datos, asi se abre solo 1 vez * * \todo Ver si vale la pena -- 2.43.0