From 81763ef5215161bd08100ea98910ae6bb093aea6 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 13 Sep 2005 17:36:36 +0000 Subject: [PATCH 1/1] Mas codigo de AddKey --- src/btree.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/btree.cpp b/src/btree.cpp index cf01b2c..38873c6 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -55,7 +55,7 @@ void BTree::AddKey (const Clave &k) Clave* BTree::AddKeyR (const Clave *k, uint node_num) { - Clave *kout; + Clave *kout = NULL; std::list node_keys; /* Leo el nodo raiz para empezar a agregar */ @@ -67,18 +67,23 @@ Clave* BTree::AddKeyR (const Clave *k, uint node_num) if (node_header.free_space >= k->Size ()) { /* TODO : Insertar ordenado */ - //node_keys.push_back (BTreek->Clone ()); + /* Siempre se agrega en una hoja */ + node_keys.push_back (BTreeLeafData (k->Clone ())); + + WriteKeys (node, node_header, node_keys); + WriteNodoHeader (node, &node_header); + WriteBlock (node, node_num); + delete [] node; } else { /* Split */ + /* Lo que debe pasar : + * 1) Separar N/2 claves en "nodo" + * 2) Separar N/2-1 claves en un nuevo nodo + * 3) kout = clave del medio y mandarla al padre + */ + std::cout << "SPLIT" << std::endl; } - - WriteKeys (node, node_header, node_keys); - WriteNodoHeader (node, &node_header); - WriteBlock (node, node_num); - - delete [] node; - return kout; } -- 2.43.0