~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/sel_imerge.h

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_OPTIMIZER_SEL_IMERGE_H
21
 
#define DRIZZLED_OPTIMIZER_SEL_IMERGE_H
22
 
 
23
 
#include "drizzled/memory/sql_alloc.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
namespace optimizer
29
 
{
30
 
 
31
 
class RangeParameter;
32
 
class SEL_TREE;
33
 
class SEL_ARG;
34
 
 
35
 
/*
36
 
  SEL_IMERGE is a list of possible ways to do index merge, i.e. it is
37
 
  a condition in the following form:
38
 
   (t_1||t_2||...||t_N) && (next)
39
 
 
40
 
  where all t_i are optimizer::SEL_TREEs, next is another SEL_IMERGE and no pair
41
 
  (t_i,t_j) contains SEL_ARGS for the same index.
42
 
 
43
 
  optimizer::SEL_TREE contained in SEL_IMERGE always has merges=NULL.
44
 
 
45
 
  This class relies on memory manager to do the cleanup.
46
 
*/
47
 
class SEL_IMERGE : public memory::SqlAlloc
48
 
{
49
 
  enum { PREALLOCED_TREES= 10};
50
 
public:
51
 
  SEL_TREE *trees_prealloced[PREALLOCED_TREES];
52
 
  SEL_TREE **trees;             /* trees used to do index_merge   */
53
 
  SEL_TREE **trees_next;        /* last of these trees            */
54
 
  SEL_TREE **trees_end;         /* end of allocated space         */
55
 
 
56
 
  SEL_ARG  ***best_keys;        /* best keys to read in optimizer::SEL_TREEs */
57
 
 
58
 
  SEL_IMERGE();
59
 
 
60
 
  /*
61
 
     Add optimizer::SEL_TREE to this index_merge without any checks,
62
 
 
63
 
     NOTES
64
 
     This function implements the following:
65
 
     (x_1||...||x_N) || t = (x_1||...||x_N||t), where x_i, t are optimizer::SEL_TREEs
66
 
 
67
 
     RETURN
68
 
     0 - OK
69
 
     -1 - Out of memory.
70
 
   */
71
 
  int or_sel_tree(RangeParameter *param, SEL_TREE *tree);
72
 
 
73
 
  /*
74
 
     Perform OR operation on this SEL_IMERGE and supplied optimizer::SEL_TREE new_tree,
75
 
     combining new_tree with one of the trees in this SEL_IMERGE if they both
76
 
     have SEL_ARGs for the same key.
77
 
 
78
 
     SYNOPSIS
79
 
     or_sel_tree_with_checks()
80
 
     param    Parameter from SqlSelect::test_quick_select
81
 
     new_tree optimizer::SEL_TREE with type KEY or KEY_SMALLER.
82
 
 
83
 
     NOTES
84
 
     This does the following:
85
 
     (t_1||...||t_k)||new_tree =
86
 
     either
87
 
     = (t_1||...||t_k||new_tree)
88
 
     or
89
 
     = (t_1||....||(t_j|| new_tree)||...||t_k),
90
 
 
91
 
     where t_i, y are optimizer::SEL_TREEs.
92
 
     new_tree is combined with the first t_j it has a SEL_ARG on common
93
 
     key with. As a consequence of this, choice of keys to do index_merge
94
 
     read may depend on the order of conditions in WHERE part of the query.
95
 
 
96
 
     RETURN
97
 
     0  OK
98
 
     1  One of the trees was combined with new_tree to optimizer::SEL_TREE::ALWAYS,
99
 
     and (*this) should be discarded.
100
 
     -1  An error occurred.
101
 
   */
102
 
  int or_sel_tree_with_checks(optimizer::RangeParameter *param, optimizer::SEL_TREE *new_tree);
103
 
 
104
 
  /*
105
 
     Perform OR operation on this index_merge and supplied index_merge list.
106
 
 
107
 
     RETURN
108
 
     0 - OK
109
 
     1 - One of conditions in result is always true and this SEL_IMERGE
110
 
     should be discarded.
111
 
     -1 - An error occurred
112
 
   */
113
 
  int or_sel_imerge_with_checks(optimizer::RangeParameter *param, SEL_IMERGE* imerge);
114
 
 
115
 
};
116
 
 
117
 
 
118
 
} /* namespace optimizer */
119
 
 
120
 
} /* namespace drizzled */
121
 
 
122
 
#endif /* DRIZZLED_OPTIMIZER_SEL_IMERGE_H */