#include "postgres.h"
#include "access/hash.h"
Go to the source code of this file.
#define BITMAPSET_SIZE | ( | nwords | ) | (offsetof(Bitmapset, words) + (nwords) * sizeof(bitmapword)) |
Definition at line 29 of file bitmapset.c.
Referenced by bms_copy(), and bms_make_singleton().
#define BITNUM | ( | x | ) | ((x) % BITS_PER_BITMAPWORD) |
Definition at line 27 of file bitmapset.c.
Referenced by bms_add_member(), bms_del_member(), bms_is_member(), and bms_make_singleton().
#define HAS_MULTIPLE_ONES | ( | x | ) | ((bitmapword) RIGHTMOST_ONE(x) != (x)) |
Definition at line 51 of file bitmapset.c.
Referenced by bms_membership(), and bms_singleton_member().
#define RIGHTMOST_ONE | ( | x | ) | ((signedbitmapword) (x) & -((signedbitmapword) (x))) |
Definition at line 49 of file bitmapset.c.
Referenced by bms_first_member().
#define WORDNUM | ( | x | ) | ((x) / BITS_PER_BITMAPWORD) |
Definition at line 26 of file bitmapset.c.
Referenced by bms_add_member(), bms_del_member(), bms_is_member(), and bms_make_singleton().
Definition at line 624 of file bitmapset.c.
References BITNUM, bms_make_singleton(), elog, ERROR, i, NULL, Bitmapset::nwords, pfree(), WORDNUM, and Bitmapset::words.
Referenced by _readBitmapset(), adjust_relid_set(), adjust_view_column_set(), alias_relid_set(), build_subplan(), check_index_only(), checkInsertTargets(), classify_index_clause_usage(), convert_EXISTS_sublink_to_join(), create_index_paths(), create_lateral_join_info(), DoCopy(), EvalPlanQualBegin(), ExecNestLoop(), ExecRecursiveUnion(), ExecReScanRecursiveUnion(), ExecReScanSetParamPlan(), ExecScanSubPlan(), ExplainPreScanNode(), finalize_plan(), finalize_primnode(), find_hash_columns(), find_unaggregated_cols_walker(), fixup_inherited_columns(), fixup_whole_row_references(), func_get_detail(), get_relids_in_jointree(), intorel_startup(), load_enum_cache_data(), make_datum_param(), make_one_rel(), make_row_comparison_op(), make_windowInputTargetList(), makeDependencyGraphWalker(), markRTEForSelectPriv(), offset_relid_set(), postgresGetForeignPaths(), pull_up_sublinks_jointree_recurse(), pull_varattnos_walker(), pull_varnos_walker(), qual_is_pushdown_safe(), RelationGetIndexAttrBitmap(), RememberFsyncRequest(), remove_rel_from_query(), RI_Initial_Check(), set_join_column_names(), SS_finalize_plan(), transformUpdateStmt(), translate_col_privs(), and view_is_auto_updatable().
{ int wordnum, bitnum; if (x < 0) elog(ERROR, "negative bitmapset member not allowed"); if (a == NULL) return bms_make_singleton(x); wordnum = WORDNUM(x); bitnum = BITNUM(x); if (wordnum >= a->nwords) { /* Slow path: make a larger set and union the input set into it */ Bitmapset *result; int nwords; int i; result = bms_make_singleton(x); nwords = a->nwords; for (i = 0; i < nwords; i++) result->words[i] |= a->words[i]; pfree(a); return result; } /* Fast path: x fits in existing set */ a->words[wordnum] |= ((bitmapword) 1 << bitnum); return a; }
Definition at line 682 of file bitmapset.c.
References bms_copy(), i, NULL, Bitmapset::nwords, pfree(), and Bitmapset::words.
Referenced by add_child_rel_equivalences(), add_eq_member(), add_vars_to_targetlist(), build_index_paths(), check_outerjoin_delay(), choose_bitmap_and(), create_lateral_join_info(), deconstruct_recurse(), finalize_plan(), make_outerjoininfo(), mark_placeholder_maybe_needed(), pull_varnos_walker(), reduce_outer_joins_pass1(), reduce_outer_joins_pass2(), SS_finalize_plan(), and update_placeholder_eval_levels().
{ Bitmapset *result; const Bitmapset *other; int otherlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return bms_copy(b); if (b == NULL) return a; /* Identify shorter and longer input; copy the longer one if needed */ if (a->nwords < b->nwords) { result = bms_copy(b); other = a; } else { result = a; other = b; } /* And union the shorter input into the result */ otherlen = other->nwords; for (i = 0; i < otherlen; i++) result->words[i] |= other->words[i]; if (result != a) pfree(a); return result; }
Definition at line 110 of file bitmapset.c.
References BITMAPSET_SIZE, NULL, Bitmapset::nwords, and palloc().
Referenced by _outBitmapset(), add_join_clause_to_rels(), adjust_relid_set(), adjust_view_column_set(), alias_relid_set(), bms_add_members(), bms_difference(), bms_intersect(), bms_union(), build_index_paths(), build_join_rel(), calc_nestloop_required_outer(), check_equivalence_delay(), check_outerjoin_delay(), choose_bitmap_and(), create_lateral_join_info(), distribute_qual_to_rels(), ExecCheckRTEPerms(), finalize_plan(), finalize_primnode(), fixup_inherited_columns(), fixup_whole_row_references(), generate_base_implied_equalities_const(), generate_base_implied_equalities_no_const(), get_bitmap_tree_required_outer(), get_loop_count(), load_enum_cache_data(), make_outerjoininfo(), materialize_finished_plan(), offset_relid_set(), postgresPlanForeignModify(), reconsider_full_join_clause(), reconsider_outer_join_clause(), RelationGetIndexAttrBitmap(), remove_join_clause_from_rels(), remove_rel_from_query(), setup_param_list(), and SS_finalize_plan().
Definition at line 662 of file bitmapset.c.
References BITNUM, elog, ERROR, NULL, WORDNUM, and Bitmapset::words.
Referenced by adjust_relid_set(), build_index_paths(), finalize_plan(), finalize_primnode(), fixup_whole_row_references(), postgresGetForeignPaths(), preprocess_rowmarks(), remove_rel_from_query(), substitute_multiple_relids_walker(), and TopologicalSort().
Definition at line 744 of file bitmapset.c.
References i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by calc_nestloop_required_outer(), and SS_finalize_plan().
Definition at line 283 of file bitmapset.c.
References bms_copy(), i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_child_rel_equivalences(), add_paths_to_joinrel(), check_partial_indexes(), and finalize_plan().
{ Bitmapset *result; int shortlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return NULL; if (b == NULL) return bms_copy(a); /* Copy the left input */ result = bms_copy(a); /* And remove b's bits from result */ shortlen = Min(a->nwords, b->nwords); for (i = 0; i < shortlen; i++) result->words[i] &= ~b->words[i]; return result; }
Definition at line 130 of file bitmapset.c.
References bms_is_empty(), i, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_path_precheck(), bitmap_match(), bms_equal_any(), choose_bitmap_and(), create_append_path(), create_merge_append_path(), create_unique_path(), find_ec_member_for_tle(), find_join_rel(), fix_indexqual_references(), generate_implied_equalities_for_column(), get_appendrel_parampathinfo(), get_baserel_parampathinfo(), get_eclass_for_sort_expr(), get_joinrel_parampathinfo(), join_is_legal(), join_is_removable(), make_join_rel(), make_one_rel(), match_pathkeys_to_index(), prepare_sort_from_pathkeys(), remove_rel_from_query(), and set_append_rel_pathlist().
{ const Bitmapset *shorter; const Bitmapset *longer; int shortlen; int longlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) { if (b == NULL) return true; return bms_is_empty(b); } else if (b == NULL) return bms_is_empty(a); /* Identify shorter and longer input */ if (a->nwords <= b->nwords) { shorter = a; longer = b; } else { shorter = b; longer = a; } /* And process */ shortlen = shorter->nwords; for (i = 0; i < shortlen; i++) { if (shorter->words[i] != longer->words[i]) return false; } longlen = longer->nwords; for (; i < longlen; i++) { if (longer->words[i] != 0) return false; } return true; }
int bms_first_member | ( | Bitmapset * | a | ) |
Definition at line 812 of file bitmapset.c.
References NULL, Bitmapset::nwords, RIGHTMOST_ONE, rightmost_one_pos, and Bitmapset::words.
Referenced by _outBitmapset(), add_join_clause_to_rels(), adjust_view_column_set(), alias_relid_set(), check_relation_privileges(), check_selective_binary_conversion(), convert_EXISTS_sublink_to_join(), ExecCheckRTEPerms(), find_hash_columns(), fixup_inherited_columns(), get_loop_count(), HeapSatisfiesHOTandKeyUpdate(), make_row_comparison_op(), mdsync(), offset_relid_set(), postgresPlanForeignModify(), remove_join_clause_from_rels(), and setup_param_list().
{ int nwords; int wordnum; if (a == NULL) return -1; nwords = a->nwords; for (wordnum = 0; wordnum < nwords; wordnum++) { bitmapword w = a->words[wordnum]; if (w != 0) { int result; w = RIGHTMOST_ONE(w); a->words[wordnum] &= ~w; result = wordnum * BITS_PER_BITMAPWORD; while ((w & 255) == 0) { w >>= 8; result += 8; } result += rightmost_one_pos[w & 255]; return result; } } return -1; }
void bms_free | ( | Bitmapset * | a | ) |
Definition at line 200 of file bitmapset.c.
References pfree().
Referenced by _outBitmapset(), add_join_clause_to_rels(), add_lateral_info(), adjust_view_column_set(), alias_relid_set(), calc_nestloop_required_outer(), check_index_only(), check_outerjoin_delay(), convert_EXISTS_sublink_to_join(), create_join_plan(), examine_variable(), ExecCheckRTEPerms(), ExecEndNode(), ExecReScan(), finalize_plan(), find_hash_columns(), fixup_inherited_columns(), func_get_detail(), get_loop_count(), has_legal_joinclause(), heap_update(), load_enum_cache_data(), make_join_rel(), mark_placeholder_maybe_needed(), mdsync(), NumRelids(), offset_relid_set(), qual_is_pushdown_safe(), reduce_outer_joins_pass2(), RelationDestroyRelation(), RememberFsyncRequest(), remove_join_clause_from_rels(), setup_param_list(), SS_finalize_plan(), try_hashjoin_path(), try_mergejoin_path(), try_nestloop_path(), UpdateChangedParamSet(), and view_is_auto_updatable().
{ if (a) pfree(a); }
Definition at line 853 of file bitmapset.c.
References DatumGetUInt32, hash_any(), NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by bitmap_hash().
{ int lastword; if (a == NULL) return 0; /* All empty sets hash to 0 */ for (lastword = a->nwords; --lastword >= 0;) { if (a->words[lastword] != 0) break; } if (lastword < 0) return 0; /* All empty sets hash to 0 */ return DatumGetUInt32(hash_any((const unsigned char *) a->words, (lastword + 1) * sizeof(bitmapword))); }
Definition at line 718 of file bitmapset.c.
References i, Min, NULL, Bitmapset::nwords, pfree(), and Bitmapset::words.
Referenced by check_outerjoin_delay(), find_nonnullable_rels_walker(), make_outerjoininfo(), and make_row_comparison_op().
{ int shortlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return NULL; if (b == NULL) { pfree(a); return NULL; } /* Intersect b into a; we need never copy */ shortlen = Min(a->nwords, b->nwords); for (i = 0; i < shortlen; i++) a->words[i] &= b->words[i]; for (; i < a->nwords; i++) a->words[i] = 0; return a; }
Definition at line 251 of file bitmapset.c.
References bms_copy(), i, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by make_outerjoininfo(), process_equivalence(), reconsider_full_join_clause(), reconsider_outer_join_clause(), and UpdateChangedParamSet().
{ Bitmapset *result; const Bitmapset *other; int resultlen; int i; /* Handle cases where either input is NULL */ if (a == NULL || b == NULL) return NULL; /* Identify shorter and longer input; copy the shorter one */ if (a->nwords <= b->nwords) { result = bms_copy(a); other = b; } else { result = bms_copy(b); other = a; } /* And intersect the longer input with the result */ resultlen = result->nwords; for (i = 0; i < resultlen; i++) result->words[i] &= other->words[i]; return result; }
Definition at line 589 of file bitmapset.c.
References NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_eq_member(), add_vars_to_targetlist(), bms_equal(), bms_is_subset(), bms_nonempty_difference(), bms_subset_compare(), build_index_paths(), calc_nestloop_required_outer(), check_partial_indexes(), convert_ANY_sublink_to_join(), convert_EXISTS_sublink_to_join(), create_foreignscan_plan(), create_lateral_join_info(), create_unique_path(), distribute_qual_to_rels(), ExecCheckRTEPerms(), ExecReScanSetParamPlan(), finalize_plan(), find_nonnullable_rels_walker(), get_appendrel_parampathinfo(), get_baserel_parampathinfo(), get_joinrel_parampathinfo(), is_pseudo_constant_clause_relids(), make_outerjoininfo(), make_restrictinfo_internal(), postgresGetForeignPaths(), process_equivalence(), pull_varnos_walker(), relation_has_unique_index_for(), remove_rel_from_query(), rewriteTargetView(), sepgsql_dml_privileges(), setup_param_list(), SS_finalize_plan(), TopologicalSort(), UpdateChangedParamSet(), and use_physical_tlist().
{ int nwords; int wordnum; if (a == NULL) return true; nwords = a->nwords; for (wordnum = 0; wordnum < nwords; wordnum++) { bitmapword w = a->words[wordnum]; if (w != 0) return false; } return true; }
Definition at line 419 of file bitmapset.c.
References BITNUM, elog, ERROR, NULL, Bitmapset::nwords, WORDNUM, and Bitmapset::words.
Referenced by add_lateral_info(), add_paths_to_joinrel(), adjust_relid_set(), adjust_rowcompare_for_index(), bms_is_subset_singleton(), check_redundant_nullability_qual(), check_relation_privileges(), checkInsertTargets(), create_index_paths(), create_nestloop_plan(), deparseTargetList(), enum_known_sorted(), examine_variable(), fixup_whole_row_references(), func_get_detail(), generate_implied_equalities_for_column(), has_join_restriction(), have_join_order_restriction(), InitPlan(), join_clause_is_movable_to(), join_is_legal(), join_is_removable(), make_outerjoininfo(), make_windowInputTargetList(), match_clause_to_indexcol(), match_rowcompare_to_indexcol(), plpgsql_param_fetch(), postgresGetForeignPaths(), preprocess_rowmarks(), process_subquery_nestloop_params(), qual_is_pushdown_safe(), remove_rel_from_query(), replace_nestloop_params_mutator(), set_join_column_names(), set_rtable_names(), substitute_multiple_relids_walker(), translate_col_privs(), TriggerEnabled(), and view_is_auto_updatable().
{ int wordnum, bitnum; /* XXX better to just return false for x<0 ? */ if (x < 0) elog(ERROR, "negative bitmapset member not allowed"); if (a == NULL) return false; wordnum = WORDNUM(x); bitnum = BITNUM(x); if (wordnum >= a->nwords) return false; if ((a->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0) return true; return false; }
Definition at line 307 of file bitmapset.c.
References bms_is_empty(), i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_child_rel_equivalences(), add_lateral_info(), add_placeholders_to_joinrel(), add_vars_to_targetlist(), check_index_only(), check_outerjoin_delay(), clause_sides_match_join(), convert_ANY_sublink_to_join(), convert_EXISTS_sublink_to_join(), create_index_paths(), create_nestloop_plan(), create_unique_path(), distribute_qual_to_rels(), drop_indexable_join_clauses(), eclass_already_used(), eclass_useful_for_merging(), final_cost_hashjoin(), finalize_plan(), generate_implied_equalities_for_column(), generate_join_implied_equalities_broken(), generate_join_implied_equalities_normal(), get_cheapest_fractional_path_for_pathkeys(), get_cheapest_path_for_pathkeys(), get_join_index_paths(), get_join_variables(), get_switched_clauses(), has_join_restriction(), has_relevant_eclass_joinclause(), have_join_order_restriction(), initial_cost_mergejoin(), is_simple_subquery(), join_clause_is_movable_into(), join_is_legal(), join_is_removable(), make_join_rel(), make_outerjoininfo(), process_subquery_nestloop_params(), reparameterize_path(), replace_nestloop_params_mutator(), subbuild_joinrel_joinlist(), subbuild_joinrel_restrictlist(), update_placeholder_eval_levels(), and use_physical_tlist().
{ int shortlen; int longlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return true; /* empty set is a subset of anything */ if (b == NULL) return bms_is_empty(a); /* Check common words */ shortlen = Min(a->nwords, b->nwords); for (i = 0; i < shortlen; i++) { if ((a->words[i] & ~b->words[i]) != 0) return false; } /* Check extra words */ if (a->nwords > b->nwords) { longlen = a->nwords; for (; i < longlen; i++) { if (a->words[i] != 0) return false; } } return true; }
Definition at line 765 of file bitmapset.c.
References i, NULL, Bitmapset::nwords, pfree(), and Bitmapset::words.
Referenced by add_paths_to_joinrel(), alias_relid_set(), finalize_primnode(), find_nonnullable_rels_walker(), find_placeholders_recurse(), get_base_rel_indexes(), get_bitmap_tree_required_outer(), get_relids_in_jointree(), process_equivalence(), pull_up_sublinks_jointree_recurse(), pull_varnos_walker(), and UpdateChangedParamSet().
{ Bitmapset *result; Bitmapset *other; int otherlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return b; if (b == NULL) return a; /* Identify shorter and longer input; use longer one as result */ if (a->nwords < b->nwords) { result = b; other = a; } else { result = a; other = b; } /* And union the shorter input into the result */ otherlen = other->nwords; for (i = 0; i < otherlen; i++) result->words[i] |= other->words[i]; if (other != result) /* pure paranoia */ pfree(other); return result; }
Bitmapset* bms_make_singleton | ( | int | x | ) |
Definition at line 178 of file bitmapset.c.
References BITMAPSET_SIZE, BITNUM, elog, ERROR, Bitmapset::nwords, palloc0(), WORDNUM, and Bitmapset::words.
Referenced by bms_add_member(), build_base_rel_tlists(), build_simple_rel(), check_partial_indexes(), create_lateral_join_info(), deconstruct_recurse(), extract_lateral_references(), find_nonnullable_rels_walker(), find_placeholders_recurse(), generate_join_implied_equalities(), get_base_rel_indexes(), get_relids_in_jointree(), load_enum_cache_data(), pull_up_sublinks_jointree_recurse(), pullup_replace_vars_callback(), and reduce_outer_joins_pass1().
{ Bitmapset *result; int wordnum, bitnum; if (x < 0) elog(ERROR, "negative bitmapset member not allowed"); wordnum = WORDNUM(x); bitnum = BITNUM(x); result = (Bitmapset *) palloc0(BITMAPSET_SIZE(wordnum + 1)); result->nwords = wordnum + 1; result->words[wordnum] = ((bitmapword) 1 << bitnum); return result; }
BMS_Membership bms_membership | ( | const Bitmapset * | a | ) |
Definition at line 560 of file bitmapset.c.
References BMS_EMPTY_SET, HAS_MULTIPLE_ONES, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_placeholders_to_base_rels(), bms_is_subset_singleton(), clauselist_selectivity(), distribute_qual_to_rels(), distribute_restrictinfo_to_rels(), examine_variable(), find_join_input_rel(), fix_placeholder_input_needed_levels(), generate_base_implied_equalities_broken(), generate_base_implied_equalities_const(), generate_base_implied_equalities_no_const(), join_is_removable(), and treat_as_join_clause().
{ BMS_Membership result = BMS_EMPTY_SET; int nwords; int wordnum; if (a == NULL) return BMS_EMPTY_SET; nwords = a->nwords; for (wordnum = 0; wordnum < nwords; wordnum++) { bitmapword w = a->words[wordnum]; if (w != 0) { if (result != BMS_EMPTY_SET || HAS_MULTIPLE_ONES(w)) return BMS_MULTIPLE; result = BMS_SINGLETON; } } return result; }
Definition at line 464 of file bitmapset.c.
References bms_is_empty(), i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_placeholders_to_base_rels(), add_placeholders_to_joinrel(), build_joinrel_tlist(), and use_physical_tlist().
{ int shortlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return false; if (b == NULL) return !bms_is_empty(a); /* Check words in common */ shortlen = Min(a->nwords, b->nwords); for (i = 0; i < shortlen; i++) { if ((a->words[i] & ~b->words[i]) != 0) return true; } /* Check extra words in a */ for (; i < a->nwords; i++) { if (a->words[i] != 0) return true; } return false; }
int bms_num_members | ( | const Bitmapset * | a | ) |
Definition at line 531 of file bitmapset.c.
References NULL, number_of_ones, Bitmapset::nwords, and Bitmapset::words.
Referenced by build_join_rel(), and NumRelids().
{ int result = 0; int nwords; int wordnum; if (a == NULL) return 0; nwords = a->nwords; for (wordnum = 0; wordnum < nwords; wordnum++) { bitmapword w = a->words[wordnum]; /* we assume here that bitmapword is an unsigned type */ while (w != 0) { result += number_of_ones[w & 255]; w >>= 8; } } return result; }
Definition at line 442 of file bitmapset.c.
References i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_child_rel_equivalences(), add_paths_to_joinrel(), calc_nestloop_required_outer(), calc_non_nestloop_required_outer(), check_outerjoin_delay(), choose_bitmap_and(), create_nestloop_path(), create_nestloop_plan(), create_unique_path(), distribute_qual_to_rels(), eclass_useful_for_merging(), ExecBRUpdateTriggers(), generate_implied_equalities_for_column(), generate_join_implied_equalities(), get_appendrel_parampathinfo(), get_baserel_parampathinfo(), get_joinrel_parampathinfo(), has_join_restriction(), has_legal_joinclause(), has_relevant_eclass_joinclause(), have_join_order_restriction(), have_relevant_eclass_joinclause(), have_relevant_joinclause(), join_clause_is_movable_into(), join_is_legal(), join_is_removable(), join_search_one_level(), make_join_rel(), make_outerjoininfo(), make_rels_by_clause_joins(), make_rels_by_clauseless_joins(), make_restrictinfo_internal(), match_join_clauses_to_index(), postgresGetForeignPaths(), reduce_outer_joins_pass2(), replace_nestloop_params_mutator(), select_outer_pathkeys_for_merge(), try_hashjoin_path(), try_mergejoin_path(), try_nestloop_path(), and update_placeholder_eval_levels().
int bms_singleton_member | ( | const Bitmapset * | a | ) |
Definition at line 496 of file bitmapset.c.
References elog, ERROR, HAS_MULTIPLE_ONES, NULL, Bitmapset::nwords, rightmost_one_pos, and Bitmapset::words.
Referenced by add_placeholders_to_base_rels(), distribute_restrictinfo_to_rels(), examine_variable(), find_join_input_rel(), fix_append_rel_relids(), generate_base_implied_equalities_no_const(), join_is_removable(), and remove_useless_joins().
{ int result = -1; int nwords; int wordnum; if (a == NULL) elog(ERROR, "bitmapset is empty"); nwords = a->nwords; for (wordnum = 0; wordnum < nwords; wordnum++) { bitmapword w = a->words[wordnum]; if (w != 0) { if (result >= 0 || HAS_MULTIPLE_ONES(w)) elog(ERROR, "bitmapset has multiple members"); result = wordnum * BITS_PER_BITMAPWORD; while ((w & 255) == 0) { w >>= 8; result += 8; } result += rightmost_one_pos[w & 255]; } } if (result < 0) elog(ERROR, "bitmapset is empty"); return result; }
BMS_Comparison bms_subset_compare | ( | const Bitmapset * | a, | |
const Bitmapset * | b | |||
) |
Definition at line 344 of file bitmapset.c.
References BMS_EQUAL, bms_is_empty(), BMS_SUBSET1, BMS_SUBSET2, i, Min, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by add_path(), consider_index_join_outer_rels(), and set_cheapest().
{ BMS_Comparison result; int shortlen; int longlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) { if (b == NULL) return BMS_EQUAL; return bms_is_empty(b) ? BMS_EQUAL : BMS_SUBSET1; } if (b == NULL) return bms_is_empty(a) ? BMS_EQUAL : BMS_SUBSET2; /* Check common words */ result = BMS_EQUAL; /* status so far */ shortlen = Min(a->nwords, b->nwords); for (i = 0; i < shortlen; i++) { bitmapword aword = a->words[i]; bitmapword bword = b->words[i]; if ((aword & ~bword) != 0) { /* a is not a subset of b */ if (result == BMS_SUBSET1) return BMS_DIFFERENT; result = BMS_SUBSET2; } if ((bword & ~aword) != 0) { /* b is not a subset of a */ if (result == BMS_SUBSET2) return BMS_DIFFERENT; result = BMS_SUBSET1; } } /* Check extra words */ if (a->nwords > b->nwords) { longlen = a->nwords; for (; i < longlen; i++) { if (a->words[i] != 0) { /* a is not a subset of b */ if (result == BMS_SUBSET1) return BMS_DIFFERENT; result = BMS_SUBSET2; } } } else if (a->nwords < b->nwords) { longlen = b->nwords; for (; i < longlen; i++) { if (b->words[i] != 0) { /* b is not a subset of a */ if (result == BMS_SUBSET2) return BMS_DIFFERENT; result = BMS_SUBSET1; } } } return result; }
Definition at line 217 of file bitmapset.c.
References bms_copy(), i, NULL, Bitmapset::nwords, and Bitmapset::words.
Referenced by calc_nestloop_required_outer(), calc_non_nestloop_required_outer(), check_partial_indexes(), check_relation_privileges(), consider_index_join_outer_rels(), create_join_clause(), create_join_plan(), create_nestloop_path(), create_unique_path(), deconstruct_recurse(), finalize_plan(), generate_base_implied_equalities_const(), generate_base_implied_equalities_no_const(), generate_join_implied_equalities(), get_baserel_parampathinfo(), get_joinrel_parampathinfo(), has_legal_joinclause(), join_is_removable(), make_join_rel(), make_outerjoininfo(), make_restrictinfo_internal(), mark_placeholder_maybe_needed(), postgresGetForeignPaths(), pull_up_sublinks_jointree_recurse(), remove_useless_joins(), and substitute_multiple_relids_walker().
{ Bitmapset *result; const Bitmapset *other; int otherlen; int i; /* Handle cases where either input is NULL */ if (a == NULL) return bms_copy(b); if (b == NULL) return bms_copy(a); /* Identify shorter and longer input; copy the longer one */ if (a->nwords <= b->nwords) { result = bms_copy(b); other = a; } else { result = bms_copy(a); other = b; } /* And union the shorter input into the result */ otherlen = other->nwords; for (i = 0; i < otherlen; i++) result->words[i] |= other->words[i]; return result; }
const uint8 number_of_ones[256] [static] |
{ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }
Definition at line 86 of file bitmapset.c.
Referenced by bms_num_members().
const uint8 rightmost_one_pos[256] [static] |
{ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }
Definition at line 67 of file bitmapset.c.
Referenced by bms_first_member(), and bms_singleton_member().