+
+ it = node_keys.begin ();
+ uint used = 0;
+ while (used < total_size/2) {
+ BTreeData *d = (*it);
+ old_node_keys.push_back (d);
+ used += d->Size ();
+ it++;
+ }
+ kout = (*it++)->getClave (); // Esta se retorna al "padre" para que se la agregue
+
+ while (it != node_keys.end ()) {
+ BTreeData *d = (*it);
+ new_node_keys.push_back (d);
+ it++;
+ }
+
+ /* Guardo */
+ WriteKeys (node, node_header, old_node_keys);
+ WriteNodoHeader (node, &node_header);
+ WriteBlock (node, node_num);
+ WriteKeys (new_node, new_node_header, new_node_keys);
+ WriteNodoHeader (new_node, &new_node_header);
+ WriteBlock (new_node, new_node_num);
+
+ PrintNode (node_num);
+ PrintNode (new_node_num);
+
+ /* Paso los hijos */
+ left_child = node_num;
+ right_child = new_node_num;
+ delete [] new_node;
+ delete [] node;
+ }
+
+ return kout;
+}
+
+Clave* BTree::AddKeyOtherR (const Clave *k, uint node_num, uint &left_child, uint &right_child)
+{
+ Clave *kout = NULL;
+ std::list<BTreeData *> node_keys;
+
+ BTreeData *data = new BTreeLeafData (k->Clone ());
+
+ /* Leo el nodo raiz para empezar a agregar */
+ uchar *node = ReadBlock (node_num);
+ BTreeNodeHeader node_header;
+ ReadNodoHeader (node, &node_header);
+
+ node_keys = ReadKeys (node, node_header);
+
+ std::list<BTreeData *>::iterator it = node_keys.begin ();
+ std::list<BTreeData *>::iterator posterior;
+ std::list<BTreeData *>::iterator ultima;
+
+ /* Se supone que la primera es un hijo :) */
+ BTreeData *lchild = (*it++);
+ posterior = it;
+
+ while (it != node_keys.end ()) {
+ if ((*data) < (*(*it)))
+ break;
+ ultima = it;
+ it++;