sasindexkey.h File Reference

API for defining binary Index keys for B-Trees. More...

`#include <string.h>`

Go to the source code of this file.

## Classes

struct | SASIndexKey_t
| Index Key Handle structure for binary index B-trees. More...
union | sasindexkeymap_t
| Union of value types and key machine integer types. More...

## Typedefs

typedef unsigned long | machine_uint_t
| word size data unit used for binary keys.
typedef unsigned short | machine_uhalf_t
| data unit used to store copy and compare lengths.
typedef struct SASIndexKey_t | SASIndexKey_t
| Index Key Handle structure for binary index B-trees.

## Functions

static int | SASIndexKeyCompare (SASIndexKey_t *op_a, SASIndexKey_t *op_b)
| binary key compare logic for Index B-Tree keys. More...
static void | SASIndexKeyCopy (SASIndexKey_t *dest, SASIndexKey_t *src)
| Copy a binary key from source to destination. More...
static size_t | SASIndexKeySize (SASIndexKey_t *key)
| Return the binary index key copy_size. More...
static void | SASIndexKeyInitRef (SASIndexKey_t *dest, void *value)
| Initial a binary key @ destination with a address value. More...
static void | SASIndexKeyInitUInt64 (SASIndexKey_t *dest, unsigned long long value)
| Initial a binary key @ destination with a unsigned 64-bit integer value. More...
static unsigned long long | SASIndexKeyReturn1stUInt64 (SASIndexKey_t *dest)
| Return the value of the 1st binary key as a unsigned 64-bit integer value. More...
static void | SASIndexKeyInitInt64 (SASIndexKey_t *dest, signed long long value)
| Initial a binary key @ destination with a signed 64-bit integer value. More...
static long long | SASIndexKeyReturn1stInt64 (SASIndexKey_t *dest)
| Return the value of the 1st binary key as a signed 64-bit integer value. More...
static void | SASIndexKeyInitDouble (SASIndexKey_t *dest, double value)
| Initial a binary key @ destination with a signed 64-bit integer value. More...
static double | SASIndexKeyReturn1stDouble (SASIndexKey_t *dest)
| Return the value of the 1st binary key as a signed 64-bit integer value. More...

## Variables

const unsigned long | machine_sign_mask = (0x80000000)
| mask use to invert the signbit.
const unsigned long | double_exp_mask = (0x7ff00000)
| mask use to invert the exponent.
const unsigned long | double_mask = (0xffffffff)
| mask use to invert the sign and exponent.

## Detailed Description

API for defining binary Index keys for B-Trees.

Intialize the SASIndexKey_t structure with a sequence of values to be used as keys for SASIndex_t BTrees.

Todo:
  Enhance this API to build larger (multi-part) keys via a streams interface similar to interface in sphlfentry.h. We have enough to here to implement SPHContext_t but a generalized API would make SASIndex_t more useful.

## Function Documentation

## SASIndexKeyCompare()

static int SASIndexKeyCompare | ( | SASIndexKey_t * | op_a,
|  | SASIndexKey_t * | op_b
| ) |  |

inline static

binary key compare logic for Index B-Tree keys.

Optimized for comparing unsigned long integer word values that are the size of address pointers (void*) Also optimized for early (in the first or only word of the key) misscompare.

Parameters

  op_a | Handle of the left SASIndexKey_t.
  op_b | Handle of the right SASIndexKey_t.

Returns
  an integer value -1 for op_a < op_b, 0 for op_a == op_b, and +1 for op_a > op_b.

## SASIndexKeyCopy()

static void SASIndexKeyCopy | ( | SASIndexKey_t * | dest,
|  | SASIndexKey_t * | src
| ) |  |

inline static

Copy a binary key from source to destination.

Use the copy_size to copy the required header and the significant words of key data.

Parameters

  dest | Handle of the destination SASIndexKey_t.
  src | Handle of the source SASIndexKey_t.

## SASIndexKeyInitDouble()

static void SASIndexKeyInitDouble | ( | SASIndexKey_t * | dest,
|  | double | value
| ) |  |

inline static

Initial a binary key @ destination with a signed 64-bit integer value.

Note
  Need to flip the sign bit to get the correct ordering with a mix of signed and unsigned key values.

Parameters

  dest | Handle of the destination SASIndexKey_t.
  value | signed long long value which will be the key.

## SASIndexKeyInitInt64()

static void SASIndexKeyInitInt64 | ( | SASIndexKey_t * | dest,
|  | signed long long | value
| ) |  |

inline static

Initial a binary key @ destination with a signed 64-bit integer value.

Note
  Need to flip the sign bit to get the correct ordering with a mix of signed and unsigned key values.

Parameters

  dest | Handle of the destination SASIndexKey_t.
  value | signed long long value which will be the key.

## SASIndexKeyInitRef()

static void SASIndexKeyInitRef | ( | SASIndexKey_t * | dest,
|  | void * | value
| ) |  |

inline static

Initial a binary key @ destination with a address value.

Parameters

  dest | Handle of the destination SASIndexKey_t.
  value | Address value which will be the key.

## SASIndexKeyInitUInt64()

static void SASIndexKeyInitUInt64 | ( | SASIndexKey_t * | dest,
|  | unsigned long long | value
| ) |  |

inline static

Initial a binary key @ destination with a unsigned 64-bit integer value.

Parameters

  dest | Handle of the destination SASIndexKey_t.
  value | unsigned long long value which will be the key.

## SASIndexKeyReturn1stDouble()

static double SASIndexKeyReturn1stDouble | ( | SASIndexKey_t * | dest | ) |

inline static

Return the value of the 1st binary key as a signed 64-bit integer value.

Parameters

  dest | Handle of the source SASIndexKey_t.

Returns
  value of the 1st key element as a unsigned 64-bit integer.

## SASIndexKeyReturn1stInt64()

static long long SASIndexKeyReturn1stInt64 | ( | SASIndexKey_t * | dest | ) |

inline static

Return the value of the 1st binary key as a signed 64-bit integer value.

Parameters

  dest | Handle of the source SASIndexKey_t.

Returns
  value of the 1st key element as a unsigned 64-bit integer.

## SASIndexKeyReturn1stUInt64()

static unsigned long long SASIndexKeyReturn1stUInt64 | ( | SASIndexKey_t * | dest | ) |

inline static

Return the value of the 1st binary key as a unsigned 64-bit integer value.

Parameters

  dest | Handle of the source SASIndexKey_t.

Returns
  value of the 1st key element as a unsigned 64-bit integer.

## SASIndexKeySize()

static size_t SASIndexKeySize | ( | SASIndexKey_t * | key | ) |

inline static

Return the binary index key copy_size.

Use the copy_size to copy the required header and the significant words of key data.

Parameters

  key | Handle of a SASIndexKey_t.

Returns
  current copy_size of the referenced key.