Author: Marc Munro Copyright (c) 2005 - 2011 Marc Munro License: BSD
Definition in file veil_bitmap.c.
#include <stdio.h>
#include "postgres.h"
#include "veil_datatypes.h"
#include "veil_funcs.h"
Go to the source code of this file.
Functions | |
void | vl_ClearBitmap (Bitmap *bitmap) |
Clear all bits in a Bitmap. | |
void | vl_NewBitmap (Bitmap **p_bitmap, bool shared, int32 min, int32 max) |
Return a newly initialised (empty) Bitmap. | |
void | vl_BitmapSetbit (Bitmap *bitmap, int32 bit) |
Set a bit within a Bitmap. | |
void | vl_BitmapClearbit (Bitmap *bitmap, int32 bit) |
Clear a bit within a Bitmap. | |
bool | vl_BitmapTestbit (Bitmap *bitmap, int32 bit) |
Test a bit within a Bitmap. | |
void | vl_BitmapUnion (Bitmap *target, Bitmap *source) |
Create the union of two bitmaps, updating the first with the result. | |
void | vl_BitmapIntersect (Bitmap *target, Bitmap *source) |
Create the intersection of two bitmaps, updating the first with the result. | |
int32 | vl_BitmapNextBit (Bitmap *bitmap, int32 bit, bool *found) |
Return the next set bit in the Bitmap. | |
Bitmap * | vl_BitmapFromArray (BitmapArray *bmarray, int32 elem) |
Return a specified Bitmap from a BitmapArray. | |
void | vl_ClearBitmapArray (BitmapArray *bmarray) |
Clear all bitmaps in the given BitmapArray. | |
void | vl_NewBitmapArray (BitmapArray **p_bmarray, bool shared, int32 arrayzero, int32 arraymax, int32 bitzero, int32 bitmax) |
Return a newly initialised (empty) BitmapArray. | |
static HTAB * | new_hash (char *name) |
Create a new hash table. | |
VarEntry * | vl_NextHashEntry (HTAB *hash, VarEntry *prev) |
Utility function for scanning the hash table of a BitmapHash. | |
void | vl_NewBitmapHash (BitmapHash **p_bmhash, char *name, int32 bitzero, int32 bitmax) |
Return a newly initialised (empty) BitmapHash. | |
Bitmap * | vl_BitmapFromHash (BitmapHash *bmhash, char *hashelem) |
Return a specified Bitmap from a BitmapHash. | |
Bitmap * | vl_AddBitmapToHash (BitmapHash *bmhash, char *hashelem) |
Create a newly allocated empty Bitmap to a BitmapHash. | |
bool | vl_BitmapHashHasKey (BitmapHash *bmhash, char *hashelem) |
Determine whether the supplied key exists in the BitmapHash. | |
Variables | |
static uint32 | bitmasks [] |
Array of bit positions for int32, indexed by bitno. |
void vl_ClearBitmap | ( | Bitmap * | bitmap | ) |
Clear all bits in a Bitmap.
bitmap | The Bitmap in which all bits are to be cleared |
Definition at line 41 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.
Referenced by vl_NewBitmap().
void vl_NewBitmap | ( | Bitmap ** | p_bitmap, | |
bool | shared, | |||
int32 | min, | |||
int32 | max | |||
) |
Return a newly initialised (empty) Bitmap.
The bitmap may already exist in which case it will be re-used if possible. The bitmap may be created in either session or shared memory depending on the value of shared.
p_bitmap | Pointer to an existing bitmap if one exists | |
shared | Whether to create the bitmap in shared memory | |
min | The smallest bit to be stored in the bitmap | |
max | The largest bit to be stored in the bitmap |
Definition at line 63 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitzero, DBG_SET_CANARY, DBG_SET_ELEMS, DBG_SET_TRAILER, DBG_TEST_CANARY, DBG_TEST_TRAILER, Bitmap::type, vl_ClearBitmap(), vl_free(), vl_malloc(), and vl_shmalloc().
Referenced by deserialise_one_bitmap().
void vl_BitmapSetbit | ( | Bitmap * | bitmap, | |
int32 | bit | |||
) |
Set a bit within a Bitmap.
If the bit is outside of the acceptable range, raise an error.
bitmap | The Bitmap within which the bit is to be set. | |
bit | The bit to be set. |
Definition at line 121 of file veil_bitmap.c.
References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, Bitmap::bitzero, BITZERO, DBG_CHECK_INDEX, DBG_TEST_CANARY, and DBG_TEST_TRAILER.
void vl_BitmapClearbit | ( | Bitmap * | bitmap, | |
int32 | bit | |||
) |
Clear a bit within a Bitmap.
If the bit is outside of the acceptable range, raise an error.
bitmap | The Bitmap within which the bit is to be cleared. | |
bit | The bit to be cleared. |
Definition at line 155 of file veil_bitmap.c.
References Bitmap::bitmax, and Bitmap::bitzero.
bool vl_BitmapTestbit | ( | Bitmap * | bitmap, | |
int32 | bit | |||
) |
Test a bit within a Bitmap.
If the bit is outside of the acceptable range return false.
bitmap | The Bitmap within which the bit is to be set. | |
bit | The bit to be tested. |
Definition at line 185 of file veil_bitmap.c.
Create the union of two bitmaps, updating the first with the result.
target | The Bitmap into which the result will be placed. | |
source | The Bitmap to be unioned into target. |
Definition at line 207 of file veil_bitmap.c.
References Bitmap::bitmax, and Bitmap::bitzero.
Referenced by deserialise_bitmap_hash().
Create the intersection of two bitmaps, updating the first with the result.
target | The Bitmap into which the result will be placed. | |
source | The Bitmap to be intersected into target. |
Definition at line 238 of file veil_bitmap.c.
References Bitmap::bitmax, and Bitmap::bitzero.
int32 vl_BitmapNextBit | ( | Bitmap * | bitmap, | |
int32 | bit, | |||
bool * | found | |||
) |
Return the next set bit in the Bitmap.
bitmap | The Bitmap being scanned. | |
bit | The starting bit from which to scan the bitmap | |
found | Boolean that will be set to true when a set bit has been found. |
Definition at line 272 of file veil_bitmap.c.
Bitmap* vl_BitmapFromArray | ( | BitmapArray * | bmarray, | |
int32 | elem | |||
) |
Return a specified Bitmap from a BitmapArray.
bmarray | The BitmapArray from which the result is to be returned. | |
elem | The index of the Bitmap within the array. |
Definition at line 298 of file veil_bitmap.c.
Referenced by veil_bitmap_array_bits().
void vl_ClearBitmapArray | ( | BitmapArray * | bmarray | ) |
Clear all bitmaps in the given BitmapArray.
bmarray | The BitmapArray to be cleared |
Definition at line 321 of file veil_bitmap.c.
References ARRAYELEMS, BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmax, BitmapArray::bitzero, and DBG_TEST_CANARY.
void vl_NewBitmapArray | ( | BitmapArray ** | p_bmarray, | |
bool | shared, | |||
int32 | arrayzero, | |||
int32 | arraymax, | |||
int32 | bitzero, | |||
int32 | bitmax | |||
) |
Return a newly initialised (empty) BitmapArray.
It may already exist in which case it will be re-used if possible. It may be created in either session or shared memory depending on the value of shared.
p_bmarray | Pointer to an existing bitmap if one exists. | |
shared | Whether to create the bitmap in shared memory | |
arrayzero | The lowest array index | |
arraymax | The highest array index | |
bitzero | The smallest bit to be stored in the bitmap | |
bitmax | The largest bit to be stored in the bitmap |
Definition at line 351 of file veil_bitmap.c.
Referenced by deserialise_bitmap_array().
static HTAB* new_hash | ( | char * | name | ) | [static] |
Create a new hash table.
This is allocated from session memory as BitmapHashes may not be declared as shared variables.
name | The name of the hash to be created. Note that we prefix this with "vl_" to prevent name collisions from other subsystems. |
Definition at line 434 of file veil_bitmap.c.
Utility function for scanning the hash table of a BitmapHash.
hash | The hash table being scanned | |
prev | The entry from which to scan, starting with NULL. |
Definition at line 459 of file veil_bitmap.c.
References BitmapHash::hash, VarEntry::obj, Object::type, and vl_NextHashEntry().
Referenced by serialise_bitmap_hash(), sizeof_bitmaps_in_hash(), and vl_NextHashEntry().
void vl_NewBitmapHash | ( | BitmapHash ** | p_bmhash, | |
char * | name, | |||
int32 | bitzero, | |||
int32 | bitmax | |||
) |
Return a newly initialised (empty) BitmapHash.
It may already exist in which case it will be re-used if possible. BitmapHash variables may only be created as session (not shared) variables.
p_bmhash | Pointer to an existing bitmap if one exists. | |
name | The name to be used for the hash table | |
bitzero | The smallest bit to be stored in the bitmap | |
bitmax | The largest bit to be stored in the bitmap |
Definition at line 484 of file veil_bitmap.c.
Referenced by deserialise_bitmap_hash().
Bitmap* vl_BitmapFromHash | ( | BitmapHash * | bmhash, | |
char * | hashelem | |||
) |
Return a specified Bitmap from a BitmapHash.
Raise an error if the returned object from the hash search is not a bitmap.
bmhash | The BitmapHash from which the result is to be returned. | |
hashelem | The key of the Bitmap within the hash. |
Definition at line 534 of file veil_bitmap.c.
References VarEntry::obj, and Object::type.
Bitmap* vl_AddBitmapToHash | ( | BitmapHash * | bmhash, | |
char * | hashelem | |||
) |
Create a newly allocated empty Bitmap to a BitmapHash.
bmhash | The BitmapHash to which to add the new Bitmap. | |
hashelem | The key for the new entry |
Definition at line 576 of file veil_bitmap.c.
Referenced by deserialise_bitmap_hash().
bool vl_BitmapHashHasKey | ( | BitmapHash * | bmhash, | |
char * | hashelem | |||
) |
Determine whether the supplied key exists in the BitmapHash.
bmhash | The BitmapHash to be tested | |
hashelem | The key to be tested |
Definition at line 619 of file veil_bitmap.c.
uint32 bitmasks[] [static] |
Initial value:
{0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, 0x00000200, 0x00000400, 0x00000800, 0x00001000, 0x00002000, 0x00004000, 0x00008000, 0x00010000, 0x00020000, 0x00040000, 0x00080000, 0x00100000, 0x00200000, 0x00400000, 0x00800000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000}
Definition at line 25 of file veil_bitmap.c.
Referenced by vl_BitmapSetbit().