~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_ror_union_select.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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_QUICK_ROR_UNION_SELECT_H
 
21
#define DRIZZLED_OPTIMIZER_QUICK_ROR_UNION_SELECT_H
 
22
 
 
23
#include "drizzled/optimizer/range.h"
 
24
 
 
25
#include <vector>
 
26
 
 
27
namespace drizzled
 
28
{
 
29
 
 
30
namespace optimizer
 
31
{
 
32
 
 
33
class compare_functor;
 
34
 
 
35
/**
 
36
  Rowid-Ordered Retrieval index union select.
 
37
  This quick select produces union of row sequences returned by several
 
38
  quick select it "merges".
 
39
 
 
40
  All merged quick selects must return rowids in rowid order.
 
41
  QuickRorUnionSelect will return rows in rowid order, too.
 
42
 
 
43
  All merged quick selects are set not to retrieve full table records.
 
44
  ROR-union quick select always retrieves full records.
 
45
 
 
46
*/
 
47
class QuickRorUnionSelect : public QuickSelectInterface
 
48
{
 
49
public:
 
50
  QuickRorUnionSelect(Session *session, Table *table);
 
51
  ~QuickRorUnionSelect();
 
52
 
 
53
  /**
 
54
   * Do post-constructor initialization.
 
55
   * SYNOPSIS
 
56
   * QuickRorUnionSelect::init()
 
57
   *
 
58
   * RETURN
 
59
   * @retval 0      OK
 
60
   * @retval other  Error code
 
61
   */
 
62
  int  init();
 
63
 
 
64
  /**
 
65
   * Initialize quick select for row retrieval.
 
66
   * SYNOPSIS
 
67
   * reset()
 
68
   *
 
69
   * RETURN
 
70
   * @retval 0      OK
 
71
   * @retval other  Error code
 
72
   */
 
73
  int  reset(void);
 
74
 
 
75
  /**
 
76
   * Retrieve next record.
 
77
   * SYNOPSIS
 
78
   * QuickRorUnionSelect::get_next()
 
79
   *
 
80
   * NOTES
 
81
   * Enter/exit invariant:
 
82
   * For each quick select in the queue a {key,rowid} tuple has been
 
83
   * retrieved but the corresponding row hasn't been passed to output.
 
84
   *
 
85
   * RETURN
 
86
   * @retval 0     - Ok
 
87
   * @retval other - Error code if any error occurred.
 
88
   */
 
89
  int  get_next();
 
90
 
 
91
  bool reverse_sorted() const
 
92
  {
 
93
    return false;
 
94
  }
 
95
 
 
96
  bool unique_key_range() const
 
97
  {
 
98
    return false;
 
99
  }
 
100
 
 
101
  int get_type() const
 
102
  {
 
103
    return QS_TYPE_ROR_UNION;
 
104
  }
 
105
 
 
106
  void add_keys_and_lengths(String *key_names, String *used_lengths);
 
107
  void add_info_string(String *str);
 
108
  bool is_keys_used(const MyBitmap *fields);
 
109
 
 
110
  bool push_quick_back(QuickSelectInterface *quick_sel_range);
 
111
 
 
112
  std::vector<QuickSelectInterface *> quick_selects; /**< Merged quick selects */
 
113
 
 
114
  /** Priority queue for merge operation */
 
115
  std::priority_queue<QuickSelectInterface *, std::vector<QuickSelectInterface *>, compare_functor > *queue;
 
116
  memory::Root alloc; /**< Memory pool for this and merged quick selects data. */
 
117
 
 
118
  Session *session; /**< current thread */
 
119
  unsigned char *cur_rowid; /**< buffer used in get_next() */
 
120
  unsigned char *prev_rowid; /**< rowid of last row returned by get_next() */
 
121
  bool have_prev_rowid; /**< true if prev_rowid has valid data */
 
122
  uint32_t rowid_length; /**< table rowid length */
 
123
private:
 
124
  bool scans_inited;
 
125
};
 
126
 
 
127
} /* namespace optimizer */
 
128
 
 
129
} /* namespace drizzled */
 
130
 
 
131
#endif /* DRIZZLED_OPTIMIZER_QUICK_ROR_UNION_SELECT_H */