~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sel_tree.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-22 18:24:12 UTC
  • mto: This revision was merged to the branch mainline in revision 2347.
  • Revision ID: olafvdspek@gmail.com-20110622182412-i5ttclkahy051fzj
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
static optimizer::SEL_ARG *key_or(optimizer::RangeParameter *param, optimizer::SEL_ARG *key1, optimizer::SEL_ARG *key2);
35
35
static bool eq_tree(optimizer::SEL_ARG* a, optimizer::SEL_ARG *b);
36
36
 
37
 
bool optimizer::sel_trees_can_be_ored(optimizer::SEL_TREE *tree1, 
38
 
                                      optimizer::SEL_TREE *tree2,
39
 
                                      optimizer::RangeParameter* param)
 
37
bool optimizer::sel_trees_can_be_ored(const SEL_TREE& tree1, const SEL_TREE& tree2, const RangeParameter& param)
40
38
{
41
 
  key_map common_keys= tree1->keys_map;
42
 
  common_keys&= tree2->keys_map;
 
39
  key_map common_keys= tree1.keys_map;
 
40
  common_keys&= tree2.keys_map;
43
41
 
44
42
  if (common_keys.none())
45
 
  {
46
43
    return false;
47
 
  }
48
44
 
49
45
  /* trees have a common key, check if they refer to same key part */
50
 
  optimizer::SEL_ARG **key1,**key2;
51
 
  for (uint32_t key_no=0; key_no < param->keys; key_no++)
 
46
  for (uint32_t key_no= 0; key_no < param.keys; key_no++)
52
47
  {
53
 
    if (common_keys.test(key_no))
54
 
    {
55
 
      key1= tree1->keys + key_no;
56
 
      key2= tree2->keys + key_no;
57
 
      if ((*key1)->part == (*key2)->part)
58
 
      {
59
 
        return true;
60
 
      }
61
 
    }
 
48
    if (common_keys.test(key_no) && tree1.keys[key_no]->part == tree2.keys[key_no]->part)
 
49
      return true;
62
50
  }
63
51
  return false;
64
52
}
155
143
  optimizer::SEL_TREE *result= NULL;
156
144
  key_map  result_keys;
157
145
  result_keys.reset();
158
 
  if (sel_trees_can_be_ored(tree1, tree2, param))
 
146
  if (sel_trees_can_be_ored(*tree1, *tree2, *param))
159
147
  {
160
148
    /* Join the trees key per key */
161
149
    optimizer::SEL_ARG **key1= NULL;