PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
multibitmapset.h File Reference
#include "nodes/bitmapset.h"
#include "nodes/pg_list.h"
Include dependency graph for multibitmapset.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Listmbms_add_member (List *a, int listidx, int bitidx)
 
Listmbms_add_members (List *a, const List *b)
 
Listmbms_int_members (List *a, const List *b)
 
bool mbms_is_member (int listidx, int bitidx, const List *a)
 
Bitmapsetmbms_overlap_sets (const List *a, const List *b)
 

Function Documentation

◆ mbms_add_member()

List * mbms_add_member ( List a,
int  listidx,
int  bitidx 
)

Definition at line 44 of file multibitmapset.c.

45{
46 Bitmapset *bms;
47 ListCell *lc;
48
49 if (listidx < 0 || bitidx < 0)
50 elog(ERROR, "negative multibitmapset member index not allowed");
51 /* Add empty elements as needed */
52 while (list_length(a) <= listidx)
53 a = lappend(a, NULL);
54 /* Update the target element */
55 lc = list_nth_cell(a, listidx);
56 bms = lfirst_node(Bitmapset, lc);
57 bms = bms_add_member(bms, bitidx);
58 lfirst(lc) = bms;
59 return a;
60}
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:815
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
int a
Definition: isn.c:68
List * lappend(List *list, void *datum)
Definition: list.c:339
#define lfirst(lc)
Definition: pg_list.h:172
#define lfirst_node(type, lc)
Definition: pg_list.h:176
static int list_length(const List *l)
Definition: pg_list.h:152
static ListCell * list_nth_cell(const List *list, int n)
Definition: pg_list.h:277

References a, bms_add_member(), elog, ERROR, lappend(), lfirst, lfirst_node, list_length(), and list_nth_cell().

Referenced by find_forced_null_vars(), and find_nonnullable_vars_walker().

◆ mbms_add_members()

List * mbms_add_members ( List a,
const List b 
)

Definition at line 71 of file multibitmapset.c.

72{
74 *lcb;
75
76 /* Add empty elements to a, as needed */
77 while (list_length(a) < list_length(b))
78 a = lappend(a, NULL);
79 /* forboth will stop at the end of the shorter list, which is fine */
80 forboth(lca, a, lcb, b)
81 {
83 const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
84
85 bmsa = bms_add_members(bmsa, bmsb);
86 lfirst(lca) = bmsa;
87 }
88 return a;
89}
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:917
int b
Definition: isn.c:69
Datum lca(PG_FUNCTION_ARGS)
Definition: ltree_op.c:568
#define forboth(cell1, list1, cell2, list2)
Definition: pg_list.h:518

References a, b, bms_add_members(), forboth, lappend(), lca(), lfirst, lfirst_node, and list_length().

Referenced by find_forced_null_vars(), find_nonnullable_vars_walker(), and reduce_outer_joins_pass2().

◆ mbms_int_members()

List * mbms_int_members ( List a,
const List b 
)

Definition at line 100 of file multibitmapset.c.

101{
102 ListCell *lca,
103 *lcb;
104
105 /* Remove any elements of a that are no longer of use */
107 /* forboth will stop at the end of the shorter list, which is fine */
108 forboth(lca, a, lcb, b)
109 {
111 const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
112
113 bmsa = bms_int_members(bmsa, bmsb);
114 lfirst(lca) = bmsa;
115 }
116 return a;
117}
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:1109
List * list_truncate(List *list, int new_size)
Definition: list.c:631

References a, b, bms_int_members(), forboth, lca(), lfirst, lfirst_node, list_length(), and list_truncate().

Referenced by find_nonnullable_vars_walker().

◆ mbms_is_member()

bool mbms_is_member ( int  listidx,
int  bitidx,
const List a 
)

Definition at line 126 of file multibitmapset.c.

127{
128 const Bitmapset *bms;
129
130 /* XXX better to just return false for negative indexes? */
131 if (listidx < 0 || bitidx < 0)
132 elog(ERROR, "negative multibitmapset member index not allowed");
133 if (listidx >= list_length(a))
134 return false;
135 bms = list_nth_node(Bitmapset, a, listidx);
136 return bms_is_member(bitidx, bms);
137}
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:510
#define list_nth_node(type, list, n)
Definition: pg_list.h:327

References a, bms_is_member(), elog, ERROR, list_length(), and list_nth_node.

◆ mbms_overlap_sets()

Bitmapset * mbms_overlap_sets ( const List a,
const List b 
)

Definition at line 146 of file multibitmapset.c.

147{
148 Bitmapset *result = NULL;
149 ListCell *lca,
150 *lcb;
151
152 /* forboth will stop at the end of the shorter list, which is fine */
153 forboth(lca, a, lcb, b)
154 {
155 const Bitmapset *bmsa = lfirst_node(Bitmapset, lca);
156 const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
157
158 if (bms_overlap(bmsa, bmsb))
159 result = bms_add_member(result, foreach_current_index(lca));
160 }
161 return result;
162}
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:582
#define foreach_current_index(var_or_cell)
Definition: pg_list.h:403

References a, b, bms_add_member(), bms_overlap(), forboth, foreach_current_index, lca(), and lfirst_node.

Referenced by reduce_outer_joins_pass2().