]> git.llucax.com Git - z.facultad/75.52/treemulator.git/commitdiff
Recuperacion de nodos eliminados.
authorRicardo Markiewicz <rmarkie@fi.uba.ar>
Tue, 1 Nov 2005 04:40:05 +0000 (04:40 +0000)
committerRicardo Markiewicz <rmarkie@fi.uba.ar>
Tue, 1 Nov 2005 04:40:05 +0000 (04:40 +0000)
src/btree.cpp
src/btree.h

index 3f6fba6e3c2a7f39ca0a33d7d3e1cc3a45e1ea79..81af642041af8670b6d9105e016af3cae521eee5 100644 (file)
@@ -714,13 +714,15 @@ void BTree::JoinNodes (uint node1, uint node2, uint padre, int tipohermano)
                WriteNodoHeader (npadre, &nhp);
                WriteBlock (npadre, padre);
 
-        /* TODO: Recuperar nodo1 y nodo2 */
+               deleted_nodes.push_back (node1);
+               deleted_nodes.push_back (node2);
        } else {
                WriteKeys (n1, nh1, newkeys);
                WriteNodoHeader (n1, &nh1);
                WriteBlock (n1, node1);
 
-               /* TODO : Recuperar node2 */
+               deleted_nodes.push_back (node2);
+
                /* Actualizo punero al padre */
                (*anterior)->SetChild (node1);
        
@@ -1135,11 +1137,18 @@ uchar *BTree::NewBlock (uint &num)
        uchar *node;
        BTreeNodeHeader nh;
 
-       fseek (fp, 0, SEEK_END);
-       filelen = ftell (fp);
+       std::list<uint>::iterator it;
+       it = deleted_nodes.begin ();
 
-       num = filelen/header.block_size - 1;
+       if (it != deleted_nodes.end ()) {
+               num = *it;
+               deleted_nodes.erase (it);
+       } else {
+               fseek (fp, 0, SEEK_END);
+               filelen = ftell (fp);
 
+               num = filelen/header.block_size - 1;
+       }
        node = new uchar[header.block_size];
        ReadNodoHeader (node, &nh);
        nh.level = 0;
index 5d05ae43226c6550642c56fe8c5c37ad515638da..2026eb018f904e27c0d834cba869365370a24f93 100644 (file)
@@ -321,6 +321,7 @@ class BTree {
                 *  \todo Ver si vale la pena
                 */
                FILE *fp;
+               std::list<uint> deleted_nodes;
 
 
                /* DEBUG */