]> git.llucax.com Git - z.facultad/75.52/treemulator.git/commitdiff
Implemento recuperacion de blockdata.
authorRicardo Markiewicz <rmarkie@fi.uba.ar>
Wed, 23 Nov 2005 03:01:19 +0000 (03:01 +0000)
committerRicardo Markiewicz <rmarkie@fi.uba.ar>
Wed, 23 Nov 2005 03:01:19 +0000 (03:01 +0000)
src/btree.cpp
src/btree.h
src/clave.h

index fc62f5ba108079ad1de6177848f5ad49e1ba88f6..575ca597b6eff9d07f4e21028df4015d188108c2 100644 (file)
@@ -582,6 +582,7 @@ void BTree::DelKeyFromLeaf (Clave *k, uint node_num, uint padre)
                if ((*data) == (*(*it))) {
                        BTreeData *aborrar = (*it);
                        node_keys.erase (it);
+                       deleted_block_data.push_back (aborrar->GetKey ()->GetBlockData ());
                        delete aborrar;
                        break;
                }
@@ -1301,7 +1302,15 @@ int BTree::type () const
 
 uint BTree::GetNextBlockData ()
 {
-       /* TODO : Implementar recuperacion */
-       return header.block_data_counter++;
+       uint n;
+       if (deleted_block_data.size ()) {
+               std::list<uint>::iterator it = deleted_block_data.begin ();
+               n = *it;
+               deleted_block_data.erase (it);
+       } else {
+               n = header.block_data_counter++;
+       }
+
+       return n;
 }
 
index 1c08df48b304d42637f715d7da9064d3bc72e5d3..36558f0b7de0dfac67c302ab09cf2867631bce8f 100644 (file)
@@ -328,6 +328,7 @@ class BTree {
                 */
                FILE *fp;
                std::list<uint> deleted_nodes;
+               std::list<uint> deleted_block_data;
 
 
                /* DEBUG */
index 1d746b86a48c3dd94aec27b035b9e26ba5fcde1c..cbf0cc463da720cc36ce9190c6a9ba4c03848423 100644 (file)
@@ -11,6 +11,7 @@ class Clave {
                virtual ~Clave () {}
 
                void SetBlockData (int i) { block_data = i; }
+               uint GetBlockData () { return block_data; }
 
                /** Retorna el tamaño en bytes que ocupa la clave */
                virtual uint Size () const = 0;