Struct KeyDataType

#include <bt.h>

A KeyDataType provides an abstraction of the (key, data) pair in a B+-tree node.

struct KeyDataEntry
{
	KeyType key;
	DataType data;
};

The following functions have been defined to interface with the (key, data) abstraction.

Functions

int KeyCmp(const void *key1, const void *key2, AttrType t)

compare the value of key1 and key2, given that they are both of type t. Return negative if key1 < key2, 0 if key1 == key2 and positive if key1 > key2.

int GetKeyLength(const void *key, const AttrType keyType)

Given a key and it's type keyType, return the length in bytes of this key.

int GetKeyDataLength(const void *key, const AttrType keyType, const NodeType nodeType)

Given a key, it's type keyType, and the nodeType of the B+tree node this key resides on, return the total length in bytes of (key, data) pair.

void MakeEntry (KeyDataEntry *entry, AttrType keyType, const void *key, NodeType nodeType, DataType data, int *len)

Construct a new (key, data) pair for a node of type nodeType, and copy into the memory location pointed to by entry. The type of a key is specified by keyType and len will be set to the length of the (key, data) pair in bytes.

void GetKeyData (void *key, DataType *data, KeyDataEntry *pair, int len, NodeType nodeType)

Given a pair (k, d) of length len bytes from a node of type nodeType, copy k into key, and d into data. If key is NULL, then k is not copied. If data is NULL, then d will not be copied.