pgbitmap
Postgres extension providing a bitmap type
pgbitmap.c File Reference

Define a bitmap type for postgres. More...

#include "pgbitmap.h"

Macros

#define INT32SIZE_B64   7
 
#define INT64SIZE_B64   12
 

Functions

static unsigned b64_encode (const char *src, unsigned len, char *dst)
 
static unsigned b64_decode (const char *src, unsigned len, char *dst)
 
static boolean bitmapEmpty (Bitmap *bitmap)
 
static void clearBitmap (Bitmap *bitmap)
 
static BitmapnewBitmap (int32 min, int32 max)
 
bool bitmapTestbit (Bitmap *bitmap, int32 bit)
 
BitmapbitmapCopy (Bitmap *bitmap)
 
static BitmapextendBitmap (Bitmap *bitmap, int32 bit)
 
static void doSetBit (Bitmap *bitmap, int32 bit)
 
static BitmapbitmapSetbit (Bitmap *bitmap, int32 bit)
 
static int32 bitmapNextBit (Bitmap *bitmap, int32 inbit, bool *found)
 
static char * serialise_bitmap (Bitmap *bitmap)
 
static void reduceBitmap (Bitmap *bitmap)
 
static void doClearBit (Bitmap *bitmap, int32 bit)
 
static BitmapbitmapClearbit (Bitmap *bitmap, int32 bit)
 
static BitmapbitmapSetMin (Bitmap *bitmap, int bitmin)
 
static BitmapbitmapSetMax (Bitmap *bitmap, int bitmax)
 
static bool bitmapEqual (Bitmap *bitmap1, Bitmap *bitmap2)
 
static BitmapbitmapUnion (Bitmap *bitmap1, Bitmap *bitmap2)
 
static BitmapbitmapIntersect (Bitmap *bitmap1, Bitmap *bitmap2)
 
static BitmapbitmapMinus (Bitmap *bitmap1, Bitmap *bitmap2)
 
static void serialise_int32 (char **p_stream, int32 value)
 
static int32 deserialise_int32 (char **p_stream)
 
static void serialise_stream (char **p_stream, int32 bytes, char *instream)
 
static int streamlen (int32 bytes)
 
static void deserialise_stream (char **p_stream, int32 bytes, char *outstream)
 
static Bitmapdeserialise_bitmap (char *charstream)
 
static int bitmapCmp (Bitmap *bitmap1, Bitmap *bitmap2)
 
Datum bitmap_in (FunctionCallInfo fcinfo)
 
Datum bitmap_out (FunctionCallInfo fcinfo)
 
Datum bitmap_is_empty (FunctionCallInfo fcinfo)
 
Datum bitmap_bitmin (FunctionCallInfo fcinfo)
 
Datum bitmap_bitmax (FunctionCallInfo fcinfo)
 
Datum bitmap_bits (FunctionCallInfo fcinfo)
 
Datum bitmap_new_empty (FunctionCallInfo fcinfo)
 
Datum bitmap_new (FunctionCallInfo fcinfo)
 
Datum bitmap_setbit (FunctionCallInfo fcinfo)
 
Datum bitmap_testbit (FunctionCallInfo fcinfo)
 
Datum bitmap_setmin (FunctionCallInfo fcinfo)
 
Datum bitmap_setmax (FunctionCallInfo fcinfo)
 
Datum bitmap_equal (FunctionCallInfo fcinfo)
 
Datum bitmap_nequal (FunctionCallInfo fcinfo)
 
Datum bitmap_cmp (FunctionCallInfo fcinfo)
 
Datum bitmap_lt (FunctionCallInfo fcinfo)
 
Datum bitmap_le (FunctionCallInfo fcinfo)
 
Datum bitmap_gt (FunctionCallInfo fcinfo)
 
Datum bitmap_ge (FunctionCallInfo fcinfo)
 
Datum bitmap_union (FunctionCallInfo fcinfo)
 
Datum bitmap_clearbit (FunctionCallInfo fcinfo)
 
Datum bitmap_intersection (FunctionCallInfo fcinfo)
 
Datum bitmap_minus (FunctionCallInfo fcinfo)
 

Variables

static uint64 bitmasks [64]
 
static const char _base64 []
 
static const short b64lookup [128]
 

Detailed Description

Define a bitmap type for postgres.

Author: Marc Munro
Copyright (c) 2020 Marc Munro
License: BSD

Macro Definition Documentation

◆ INT32SIZE_B64

#define INT32SIZE_B64   7

The length of a 64-bit integer as a base64 string. This should really be 8 but the last char is always '=' so we can optimise it away.

◆ INT64SIZE_B64

#define INT64SIZE_B64   12

The length of a 32-bit integer as a base64 string.

Function Documentation

◆ bitmap_bitmax()

Datum bitmap_bitmax ( FunctionCallInfo  fcinfo)

bitmap_bitmax(bitmap bitmap) returns boolean Return the highest bit set in the bitmap, or NULL if none are set. This relies on bitmap->bitmax always identifying the highest numbered bit in the bitset, unless the bitmap is empty.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap being examined.
Returns
integer The lowest bit set in the bitmap or NULL if there are no bits set.
Here is the call graph for this function:

◆ bitmap_bitmin()

Datum bitmap_bitmin ( FunctionCallInfo  fcinfo)

bitmap_bitmin(bitmap bitmap) returns boolean Return the lowest bit set in the bitmap, or NULL if none are set. This relies on bitmap->bitmin always identifying the lowest numbered bit in the bitset, unless the bitmap is empty.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap being examined.
Returns
integer The lowest bit set in the bitmap or NULL if there are no bits set.
Here is the call graph for this function:

◆ bitmap_bits()

Datum bitmap_bits ( FunctionCallInfo  fcinfo)

bitmap_bits(name text) returns setof int4 Return the set of all bits set in the specified Bitmap.

Parameters
fcinfoname text The name of the bitmap.
Returns
setof int4The set of bits that are set in the bitmap.
Here is the call graph for this function:

◆ bitmap_clearbit()

Datum bitmap_clearbit ( FunctionCallInfo  fcinfo)

bitmap_clearbit(bitmap bitmap, bit int4) returns bool Clear the given bit in the bitmap, returning FALSE.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap to be manipulated.
bitno int4 The bitnumber to be set.
Returns
bool TRUE
Here is the call graph for this function:

◆ bitmap_cmp()

Datum bitmap_cmp ( FunctionCallInfo  fcinfo)

bitmap_cmp(bitmap1 bitmap, bitmap2 bitmap) returns bool Return result of comparison of bitmap1's string representation with bitmap2's.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
int4 result of comparison
Here is the call graph for this function:

◆ bitmap_equal()

Datum bitmap_equal ( FunctionCallInfo  fcinfo)

bitmap_equal(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if the bitmaps are equivalent,

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true if the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_ge()

Datum bitmap_ge ( FunctionCallInfo  fcinfo)

bitmap_ge(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if bitmap1's string representation should be sorted later than, or the same as, bitmap2's.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true unless the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_gt()

Datum bitmap_gt ( FunctionCallInfo  fcinfo)

bitmap_gt(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if bitmap1's string representation should be sorted later than bitmap2's.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true unless the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_in()

Datum bitmap_in ( FunctionCallInfo  fcinfo)

bitmap_in(serialised_bitmap text) returns bitmap Create a Bitmap initialised from a (base64) text value.

Parameters
fcinfoParams as described_below
serialised_bitmap text A base64 serialiastion of a bitmap value.
Returns
Bitmap the newly created bitmap
Here is the call graph for this function:

◆ bitmap_intersection()

Datum bitmap_intersection ( FunctionCallInfo  fcinfo)

bitmap_intersection(bitmap1 bitmap, bitmap2 bitmap) returns bitmap Return the intersection of 2 bitmaps. This can be used as an aggregate function in which case the bitmap1 parameter will be null for the first call. In this case simply return the second argument.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bitmap the intersection of the two bitmaps.
Here is the call graph for this function:

◆ bitmap_is_empty()

Datum bitmap_is_empty ( FunctionCallInfo  fcinfo)

bitmap_is_empty(bitmap bitmap) returns boolean Predicate to identify whether a bitmap is empty or not.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap being examined. bitmap value.
Returns
boolean true, if the bitmap has no bits.
Here is the call graph for this function:

◆ bitmap_le()

Datum bitmap_le ( FunctionCallInfo  fcinfo)

bitmap_le(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if bitmap1's string representation should be sorted earlier than, or the same as, bitmap2's.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true unless the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_lt()

Datum bitmap_lt ( FunctionCallInfo  fcinfo)

bitmap_lt(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if bitmap1's string representation should be sorted earlier than bitmap2's.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true unless the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_minus()

Datum bitmap_minus ( FunctionCallInfo  fcinfo)

bitmap_minus(bitmap1 bitmap, bitmap2 bitmap) returns bitmap Return the bitmap1 with all bits from bitmap2 subtracted (cleared) from it.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bitmap the subtraction of the two bitmaps.
Here is the call graph for this function:

◆ bitmap_nequal()

Datum bitmap_nequal ( FunctionCallInfo  fcinfo)

bitmap_nequal(bitmap1 bitmap, bitmap2 bitmap) returns bool Return true if the bitmaps are not equivalent,

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bool true unless the bitmaps contain the same bits.
Here is the call graph for this function:

◆ bitmap_new()

Datum bitmap_new ( FunctionCallInfo  fcinfo)

bitmap_new() returns bitmap; Create or re-initialise a Bitmap, for dealing with a named range of values.

Parameters
fcinfoParams as described_below
bitno int32 The first integer value to be recorded in the bitmap
Returns
Bitmap the newly allocated bitmap
Here is the call graph for this function:

◆ bitmap_new_empty()

Datum bitmap_new_empty ( FunctionCallInfo  fcinfo)

bitmap_new_empty() returns bitmap; Create an empty Bitmap, for dealing with a named range of values.

Parameters
fcinfoParams as described_below
Returns
Bitmap the newly allocated bitmap
Here is the call graph for this function:

◆ bitmap_out()

Datum bitmap_out ( FunctionCallInfo  fcinfo)

bitmap_out(bitmap bitmap) returns text Create a (base64) text representation of a bitmap.

Parameters
fcinfoParams as described_below
bitmap bitmap A base64 serialiastion of a bitmap value.
Returns
cstring the newly serialised text stream.
Here is the call graph for this function:

◆ bitmap_setbit()

Datum bitmap_setbit ( FunctionCallInfo  fcinfo)

bitmap_setbit(bitmap bitmap, bit int4) returns bool Set the given bit in the bitmap, returning TRUE. This can be used as an aggregate function in which case the bitmap parameter will be null for the first call. In this case simply create a bitmap from the second argument.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap to be manipulated.
bitno int4 The bitnumber to be set.
Returns
bitmap The result.
Here is the call graph for this function:

◆ bitmap_setmax()

Datum bitmap_setmax ( FunctionCallInfo  fcinfo)

bitmap_setmax(bitmap bitmap, bitmax int4) returns bitmap Return a new bitmap having no bits greater than bitmax

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap to be manipulated.
bitmax int4 The new maximum bit.
Returns
bitmap The new bitmap.
Here is the call graph for this function:

◆ bitmap_setmin()

Datum bitmap_setmin ( FunctionCallInfo  fcinfo)

bitmap_setmin(bitmap bitmap, bitmin int4) returns bitmap Return a new bitmap having no bits less than bitmin

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap to be manipulated.
bitmin int4 The new minimum bit.
Returns
bitmap The new bitmap.
Here is the call graph for this function:

◆ bitmap_testbit()

Datum bitmap_testbit ( FunctionCallInfo  fcinfo)

bitmap_testbit(bitmap bitmap, bit int4) returns bool Test the given bit in the bitmap, returning TRUE if it is 1.

Parameters
fcinfoParams as described_below
bitmap bitmap The bitmap to be manipulated.
bitno int4 The bitnumber to be tested.
Returns
bool the truth value of the bit.
Here is the call graph for this function:

◆ bitmap_union()

Datum bitmap_union ( FunctionCallInfo  fcinfo)

bitmap_union(bitmap1 bitmap, bitmap2 bitmap) returns bitmap Return the union of 2 bitmaps. This can be used as an aggregate function in which case the bitmap1 parameter will be null for the first call. In this case simply return the second argument.

Parameters
fcinfoParams as described_below
bitmap1 bitmap The first bitmap
bitmap2 bitmap The second bitmap
Returns
bitmap the union of the two bitmaps.
Here is the call graph for this function:

◆ bitmapClearbit()

static Bitmap* bitmapClearbit ( Bitmap bitmap,
int32  bit 
)
static

Clear a bit within a Bitmap.

Parameters
bitmapThe Bitmap within which the bit is to be cleared.
bitThe bit to be cleared.
Returns
The original bitmap, possibly shrunk, with the specified bit cleared.
Here is the call graph for this function:

◆ bitmapCmp()

static int bitmapCmp ( Bitmap bitmap1,
Bitmap bitmap2 
)
static

Compare 2 bitmaps for indexing/sorting purposes

Parameters
bitmap1The first Bitmap to be compared
bitmap2The second Bitmap to be compared
Returns
< 0, 0, or > 0 like strcmp
Here is the call graph for this function:

◆ bitmapCopy()

Bitmap* bitmapCopy ( Bitmap bitmap)

Create a copy of a bitmap.

Parameters
bitmapThe original bitmap
Returns
Copy of bitmap.
Here is the call graph for this function:

◆ bitmapEmpty()

static boolean bitmapEmpty ( Bitmap bitmap)
static

Predicate identifying whether the bitmap is empty. This takes a pretty simplistic view of what it means to be empty: any properly contructed non-empty bitmap will have bits set in at least the bitmin and bitmax positions,

Parameters
bitmapThe Bitmap being scanned.
Returns
True if the bit at bitmin is zero.

◆ bitmapEqual()

static bool bitmapEqual ( Bitmap bitmap1,
Bitmap bitmap2 
)
static

Test for equality of 2 bitmaps

Parameters
bitmap1The first Bitmap to be compared
bitmap2The second Bitmap to be compared
Returns
True if the bitmaps are the same.
Here is the call graph for this function:

◆ bitmapIntersect()

static Bitmap* bitmapIntersect ( Bitmap bitmap1,
Bitmap bitmap2 
)
static

Create the intersection of two bitmaps.

Parameters
bitmap1The first Bitmap to be intersected.
bitmap2The second Bitmap, to be intersected with bitmap1.
Returns
A newly allocated bitmap which is the intersection
Here is the call graph for this function:

◆ bitmapMinus()

static Bitmap* bitmapMinus ( Bitmap bitmap1,
Bitmap bitmap2 
)
static

Create the subtraction of two bitmaps.

Parameters
bitmap1The Bitmap from which bitmap2 will be subtracted
bitmap2The Bitmap to be subtracted from from bitmap1.
Returns
A newly allocated bitmap which is the subtraction
Here is the call graph for this function:

◆ bitmapNextBit()

static int32 bitmapNextBit ( Bitmap bitmap,
int32  inbit,
bool *  found 
)
static

Return the next set bit in the Bitmap.

Parameters
bitmapThe Bitmap being scanned.
inbitThe starting bit from which to scan the bitmap
foundBoolean that will be set to true when a set bit has been found.
Returns
The bit id of the found bit, or the inbit parameter if no set bits were found.
Here is the call graph for this function:

◆ bitmapSetbit()

static Bitmap* bitmapSetbit ( Bitmap bitmap,
int32  bit 
)
static

Return a new Bitmap with bit set.

Parameters
bitmapThe Bitmap within which the bit is to be set.
bitThe bit to be set.
Returns
New bitmap with the specified bit set.
Here is the call graph for this function:

◆ bitmapSetMax()

static Bitmap* bitmapSetMax ( Bitmap bitmap,
int  bitmax 
)
static

Ensure bitmax of bitmap is no more than parameter

Parameters
bitmapThe Bitmap to be modified
bitmaxThe new minimum value
Returns
A newly allocated bitmap which has no higher bits than bitmax
Here is the call graph for this function:

◆ bitmapSetMin()

static Bitmap* bitmapSetMin ( Bitmap bitmap,
int  bitmin 
)
static

Ensure bitmin of bitmap is no less than parameter. This provides the means to quickly truncate a bitmap.

Parameters
bitmapThe Bitmap to be modified
bitminThe new minimum value
Returns
A newly allocated bitmap which has no lower bits than bitmin
Here is the call graph for this function:

◆ bitmapTestbit()

bool bitmapTestbit ( Bitmap bitmap,
int32  bit 
)

Test a bit within a Bitmap. If the bit is outside of the acceptable range return false.

Parameters
bitmapThe Bitmap within which the bit is to be set.
bitThe bit to be tested.
Returns
True if the bit is set, false otherwise.

◆ bitmapUnion()

static Bitmap* bitmapUnion ( Bitmap bitmap1,
Bitmap bitmap2 
)
static

Create the union of two bitmaps.

Parameters
bitmap1The first Bitmap to be unioned.
bitmap2The second Bitmap, to be unioned with bitmap1.
Returns
A newly allocated bitmap which is the union
Here is the call graph for this function:

◆ clearBitmap()

static void clearBitmap ( Bitmap bitmap)
static

Clear all bits in a Bitmap.

Parameters
bitmapThe Bitmap within which all bits are to be cleared

◆ deserialise_bitmap()

static Bitmap* deserialise_bitmap ( char *  charstream)
static

De-serialise a bitmap.

Parameters
charstreamThe serialised character string containing the bitmap.
Here is the call graph for this function:

◆ deserialise_int32()

static int32 deserialise_int32 ( char **  p_stream)
static

De-serialise an int32 value from a base64 character stream.

Parameters
p_streamPointer into the stream currently being read. must be large enought to take the contents to be written. This pointer is updated to point to the next free slot in the stream after reading the int32 value.
Returns
the int32 value read from the stream

◆ deserialise_stream()

static void deserialise_stream ( char **  p_stream,
int32  bytes,
char *  outstream 
)
static

De-serialise a binary stream.

Parameters
p_streamPointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream.
bytesThe number of bytes to be read
outstreamPointer into the pre-allocated memory are into which the binary from p_stream is to be written.
Here is the call graph for this function:

◆ doClearBit()

static void doClearBit ( Bitmap bitmap,
int32  bit 
)
static

Clear a bit within a Bitmap.

Parameters
bitmapThe Bitmap within which the bit is to be cleared.
bitThe bit to be set.
Returns
Possibly new bitmap with the specified bit set.

◆ doSetBit()

static void doSetBit ( Bitmap bitmap,
int32  bit 
)
static

Set a bit within a Bitmap.

Parameters
bitmapThe Bitmap within which the bit is to be set.
bitThe bit to be set.
Returns
Possibly new bitmap with the specified bit set.
Here is the call graph for this function:

◆ extendBitmap()

static Bitmap* extendBitmap ( Bitmap bitmap,
int32  bit 
)
static

Take an existing bitmap, and return a larger copy that will be able to store a specified bit.

Parameters
bitmapThe original bitmap
bitA new bit that the returned bitmap must be capable of storing.
Returns
New bitmap with appropriate bitmin and bitmax values.
Here is the call graph for this function:

◆ newBitmap()

static Bitmap* newBitmap ( int32  min,
int32  max 
)
static

Return a new, possibly uninitialised, Bitmap.

Parameters
minThe lowest value bit to be stored in the bitmap
maxThe highest value bit to be stored in the bitmap
Returns
New appropriately sized bitmap.

◆ reduceBitmap()

static void reduceBitmap ( Bitmap bitmap)
static

Take an existing Bitmap, and shrink it to be bounded by the elements containing the highest and lowest bits.

Parameters
bitmapThe original Bitmap
Returns
Bitmap with updated bitmin and bitmax values.
Here is the call graph for this function:

◆ serialise_bitmap()

static char * serialise_bitmap ( Bitmap bitmap)
static

Serialise a bitmap.

Parameters
bitmapThe bitmap to be serialised.
Here is the call graph for this function:

◆ serialise_int32()

static void serialise_int32 ( char **  p_stream,
int32  value 
)
static

Serialise an int32 value as a base64 stream (truncated to save a byte) into *p_stream.

Parameters
p_streamPointer into stream currently being written. This must be large enought to take the contents to be written. This pointer is updated to point to the next free slot in the stream after writing the int32 value, and is null terminated at that position.
valueThe value to be written to the stream.

◆ serialise_stream()

static void serialise_stream ( char **  p_stream,
int32  bytes,
char *  instream 
)
static

Serialise a binary stream as a base64 stream into *p_stream.

Parameters
p_streamPointer into stream currently being written. This pointer is updated to point to the next free slot in the stream after writing the contents of instream and is null terminated at that position.
bytesThe number of bytes to be written.
instreamThe binary stream to be written.

◆ streamlen()

static int streamlen ( int32  bytes)
static

Return the length of a base64 encoded stream for a binary stream of ::bytes length.

Parameters
bytesThe length of the input binary stream in bytes
Returns
The length of the base64 character stream required to represent the input stream.

Variable Documentation

◆ _base64

const char _base64[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

◆ b64lookup

const short b64lookup[128]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
}

◆ bitmasks

uint64 bitmasks[64]
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,
0x0000000100000000, 0x0000000200000000,
0x0000000400000000, 0x0000000800000000,
0x0000001000000000, 0x0000002000000000,
0x0000004000000000, 0x0000008000000000,
0x0000010000000000, 0x0000020000000000,
0x0000040000000000, 0x0000080000000000,
0x0000100000000000, 0x0000200000000000,
0x0000400000000000, 0x0000800000000000,
0x0001000000000000, 0x0002000000000000,
0x0004000000000000, 0x0008000000000000,
0x0010000000000000, 0x0020000000000000,
0x0040000000000000, 0x0080000000000000,
0x0100000000000000, 0x0200000000000000,
0x0400000000000000, 0x0800000000000000,
0x1000000000000000, 0x2000000000000000,
0x4000000000000000, 0x8000000000000000}

Array of bit positions for int64, indexed by bitno.