#include "btree_data.h"
+#include "btree.h"
-BTreeData::BTreeData (uchar *node)
+BTreeData::BTreeData (uchar *node, int tree_type)
{
/* TODO : Aca deberia detectar el tipo de clave (necesito
* info desde el arbol
*/
- clave = new ClaveFija (node);
+ if (tree_type == BTree::KEY_FIXED)
+ clave = new ClaveFija (node);
+ else
+ clave = new ClaveVariable (node);
node += clave->Size ();
memcpy (&hijo, node, sizeof (uint));
{
uint s = sizeof (uint);
if (clave) s += clave->Size ();
-
+ else std::cout << "No tengo clave\n";
return s;
}
bool BTreeData::operator < (const BTreeData &data) const
{
+ if (!data.clave) return false;
+
return (*clave) < (*(data.clave));
}
+bool BTreeData::operator == (const BTreeData &data) const
+{
+ if (!data.clave) return false;
+
+ return (*clave) == (*(data.clave));
+}
+
+BTreeLeafData::BTreeLeafData (uchar *node, int key_type)
+{
+ if (key_type == BTree::KEY_FIXED)
+ clave = new ClaveFija (node);
+ else
+ clave = new ClaveVariable (node);
+}
BTreeLeafData::~BTreeLeafData ()
{
uint BTreeLeafData::Size () const
{
- std::cout << "BTreeLeafData::Size()" << std::endl;
if (!clave) {
std::cout << "BTreeLeafData::Size : No tengo clave!" << std::endl;
return 0;
uint BTreeChildData::Size () const
{
- std::cout << "BTreeChildData::Size()" << std::endl;
return sizeof (uint);
}