void BTree::AddKey (const Clave &k)
{
uint left, right;
- Clave *kout = AddKeyR (k.Clone (), 0, left, right);
+ Clave *kout;
+
+ try {
+ kout = AddKeyR (k.Clone (), 0, left, right);
+ } catch (Exception *e) {
+ throw e;
+ }
if (kout) {
unsigned short level;
while (it != node_keys.end ()) {
datait = (*it);
- if (tree_type == TYPE_UNIQUE) {
+ if (tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
- if (tree_type == TYPE_UNIQUE) {
+ if (tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
posterior = it;
while (it != node_keys.end ()) {
- if (tree_type == TYPE_UNIQUE) {
+ if (tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*(*it))) {
throw new AddException ();
while (it != node_keys.end ()) {
datait = (*it);
- if (tree_type == TYPE_UNIQUE) {
+ if (tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
- if (tree_type == TYPE_UNIQUE) {
+ if (tree_type == TYPE_IDENTIFICACION) {
/* Verifico que la clave no existea ya en el arbol */
if ((*data) == (*datait)) {
throw new AddException ();
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);
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;
it++;
}
}
+
+int BTree::type () const
+{
+ return key_type;
+}