2 #include "btree_data.h"
5 BTreeData::BTreeData (uchar *node, int tree_type)
7 /* TODO : Aca deberia detectar el tipo de clave (necesito
10 if (tree_type == BTree::KEY_FIXED)
11 clave = new ClaveFija (node);
13 clave = new ClaveVariable (node);
14 node += clave->Size ();
16 memcpy (&hijo, node, sizeof (uint));
19 BTreeData::BTreeData (Clave *k, uint child)
25 BTreeData::~BTreeData ()
31 uint BTreeData::Size () const
33 uint s = sizeof (uint);
34 if (clave) s += clave->Size ();
35 else std::cout << "No tengo clave\n";
39 uchar* BTreeData::ToArray () const
41 uchar *out = new uchar[Size()];
43 uchar *n = clave->ToArray ();
44 memcpy (out, n, clave->Size ());
45 memcpy (out+clave->Size (), &hijo, sizeof (uint));
48 memcpy (out, &hijo, sizeof (uint));
52 bool BTreeData::operator < (const BTreeData &data) const
54 if (!data.clave) return false;
56 return (*clave) < (*(data.clave));
59 bool BTreeData::operator == (const BTreeData &data) const
61 if (!data.clave) return false;
63 return (*clave) == (*(data.clave));
66 BTreeLeafData::BTreeLeafData (uchar *node, int key_type)
68 if (key_type == BTree::KEY_FIXED)
69 clave = new ClaveFija (node);
71 clave = new ClaveVariable (node);
74 BTreeLeafData::~BTreeLeafData ()
78 uint BTreeLeafData::Size () const
81 std::cout << "BTreeLeafData::Size : No tengo clave!" << std::endl;
84 return clave->Size ();
87 uchar* BTreeLeafData::ToArray () const
89 return clave->ToArray ();
92 BTreeChildData::BTreeChildData (uchar *node)
94 memcpy (&hijo, node, sizeof (uint));
97 BTreeChildData::~BTreeChildData ()
101 uint BTreeChildData::Size () const
103 return sizeof (uint);
106 uchar* BTreeChildData::ToArray () const
108 uchar *out = new uchar[Size()];
109 memcpy (out, &hijo, sizeof (uint));