Shared Persistent Heap Data Environment Manual  1.1.0
Classes | Typedefs | Functions | Variables
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

static int SASIndexKeyCompare ( SASIndexKey_t op_a,
SASIndexKey_t op_b 
)
inlinestatic

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_aHandle of the left SASIndexKey_t.
op_bHandle 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.
static void SASIndexKeyCopy ( SASIndexKey_t dest,
SASIndexKey_t src 
)
inlinestatic

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
destHandle of the destination SASIndexKey_t.
srcHandle of the source SASIndexKey_t.
static void SASIndexKeyInitDouble ( SASIndexKey_t dest,
double  value 
)
inlinestatic

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
destHandle of the destination SASIndexKey_t.
valuesigned long long value which will be the key.
static void SASIndexKeyInitInt64 ( SASIndexKey_t dest,
signed long long  value 
)
inlinestatic

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
destHandle of the destination SASIndexKey_t.
valuesigned long long value which will be the key.
static void SASIndexKeyInitRef ( SASIndexKey_t dest,
void *  value 
)
inlinestatic

Initial a binary key @ destination with a address value.

Parameters
destHandle of the destination SASIndexKey_t.
valueAddress value which will be the key.
static void SASIndexKeyInitUInt64 ( SASIndexKey_t dest,
unsigned long long  value 
)
inlinestatic

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

Parameters
destHandle of the destination SASIndexKey_t.
valueunsigned long long value which will be the key.
static double SASIndexKeyReturn1stDouble ( SASIndexKey_t dest)
inlinestatic

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

Parameters
destHandle of the source SASIndexKey_t.
Returns
value of the 1st key element as a unsigned 64-bit integer.
static long long SASIndexKeyReturn1stInt64 ( SASIndexKey_t dest)
inlinestatic

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

Parameters
destHandle of the source SASIndexKey_t.
Returns
value of the 1st key element as a unsigned 64-bit integer.
static unsigned long long SASIndexKeyReturn1stUInt64 ( SASIndexKey_t dest)
inlinestatic

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

Parameters
destHandle of the source SASIndexKey_t.
Returns
value of the 1st key element as a unsigned 64-bit integer.
static size_t SASIndexKeySize ( SASIndexKey_t key)
inlinestatic

Return the binary index key copy_size.

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

Parameters
keyHandle of a SASIndexKey_t.
Returns
current copy_size of the referenced key.