26 #define WORDNUM(x) ((x) / BITS_PER_BITMAPWORD)
27 #define BITNUM(x) ((x) % BITS_PER_BITMAPWORD)
29 #define BITMAPSET_SIZE(nwords) \
30 (offsetof(Bitmapset, words) + (nwords) * sizeof(bitmapword))
49 #define RIGHTMOST_ONE(x) ((signedbitmapword) (x) & -((signedbitmapword) (x)))
51 #define HAS_MULTIPLE_ONES(x) ((bitmapword) RIGHTMOST_ONE(x) != (x))
68 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
69 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
70 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
71 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
72 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
73 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
74 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
75 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
76 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
77 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
78 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
79 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
80 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
81 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
82 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
83 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
87 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
88 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
89 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
90 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
91 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
92 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
93 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
94 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
95 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
96 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
97 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
98 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
99 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
100 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
101 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
102 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
119 memcpy(result, a, size);
159 shortlen = shorter->
nwords;
160 for (i = 0; i < shortlen; i++)
166 for (; i < longlen; i++)
168 if (longer->
words[i] != 0)
185 elog(
ERROR,
"negative bitmapset member not allowed");
189 result->
nwords = wordnum + 1;
242 for (i = 0; i < otherlen; i++)
273 resultlen = result->
nwords;
274 for (i = 0; i < resultlen; i++)
298 for (i = 0; i < shortlen; i++)
320 for (i = 0; i < shortlen; i++)
329 for (; i < longlen; i++)
331 if (a->
words[i] != 0)
363 for (i = 0; i < shortlen; i++)
368 if ((aword & ~bword) != 0)
375 if ((bword & ~aword) != 0)
387 for (; i < longlen; i++)
389 if (a->
words[i] != 0)
401 for (; i < longlen; i++)
403 if (b->
words[i] != 0)
426 elog(
ERROR,
"negative bitmapset member not allowed");
452 for (i = 0; i < shortlen; i++)
476 for (i = 0; i < shortlen; i++)
482 for (; i < a->
nwords; i++)
484 if (a->
words[i] != 0)
505 for (wordnum = 0; wordnum < nwords; wordnum++)
512 elog(
ERROR,
"bitmapset has multiple members");
514 while ((w & 255) == 0)
548 for (wordnum = 0; wordnum < nwords; wordnum++)
557 while ((w & 255) == 0)
584 for (wordnum = 0; wordnum < nwords; wordnum++)
613 for (wordnum = 0; wordnum < nwords; wordnum++)
641 for (wordnum = 0; wordnum < nwords; wordnum++)
674 elog(
ERROR,
"negative bitmapset member not allowed");
683 int oldnwords = a->
nwords;
689 for (i = oldnwords; i < a->
nwords; i++)
711 elog(
ERROR,
"negative bitmapset member not allowed");
716 if (wordnum < a->nwords)
750 for (i = 0; i < otherlen; i++)
776 for (i = 0; i < shortlen; i++)
778 for (; i < a->
nwords; i++)
799 for (i = 0; i < shortlen; i++)
833 for (i = 0; i < otherlen; i++)
863 for (wordnum = 0; wordnum < nwords; wordnum++)
872 a->
words[wordnum] &= ~w;
875 while ((w & 255) == 0)
918 for (wordnum =
WORDNUM(prevbit); wordnum < nwords; wordnum++)
930 while ((w & 255) == 0)
960 for (lastword = a->
nwords; --lastword >= 0;)
962 if (a->
words[lastword] != 0)
#define DatumGetUInt32(X)
int bms_first_member(Bitmapset *a)
Bitmapset * bms_copy(const Bitmapset *a)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
bool bms_get_singleton_member(const Bitmapset *a, int *member)
#define HAS_MULTIPLE_ONES(x)
#define BITS_PER_BITMAPWORD
#define BITMAPSET_SIZE(nwords)
void pfree(void *pointer)
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
static const uint8 rightmost_one_pos[256]
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
uint32 bms_hash_value(const Bitmapset *a)
int bms_num_members(const Bitmapset *a)
Bitmapset * bms_make_singleton(int x)
bitmapword words[FLEXIBLE_ARRAY_MEMBER]
bool bms_is_empty(const Bitmapset *a)
BMS_Membership bms_membership(const Bitmapset *a)
void * palloc0(Size size)
int bms_singleton_member(const Bitmapset *a)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
static const uint8 number_of_ones[256]
BMS_Comparison bms_subset_compare(const Bitmapset *a, const Bitmapset *b)
void bms_free(Bitmapset *a)
Datum hash_any(register const unsigned char *k, register int keylen)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_member(Bitmapset *a, int x)
void * repalloc(void *pointer, Size size)
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)