~drizzle-trunk/drizzle/development

1905.1.1 by Brian Aker
Adding FileSort class.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2010 Brian Aker
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; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
21
/* 
22
  This is a "work in progress". The concept needs to be replicated throughout
23
  the code, but we will start with baby steps for the moment. To not incur
24
  cost until we are complete, for the moment it will do no allocation.
25
26
  This is mainly here so that it can be used in the SE interface for
27
  the time being.
28
29
  This will replace Table_ident.
30
  */
31
32
#ifndef DRIZZLED_FILESORT_H
33
#define DRIZZLED_FILESORT_H
34
35
namespace drizzled {
36
37
class Session;
38
class Table;
39
class SortField;
40
41
namespace optimizer {
42
class SqlSelect;
43
}
44
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
45
class SortParam;
46
1905.1.1 by Brian Aker
Adding FileSort class.
47
class FileSort {
48
  Session &_session;
49
50
  uint32_t sortlength(SortField *sortorder, uint32_t s_length, bool *multi_byte_charset);
51
  sort_addon_field *get_addon_fields(Field **ptabfield, uint32_t sortlength, uint32_t *plength);
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
52
  ha_rows find_all_keys(SortParam *param, 
1905.1.1 by Brian Aker
Adding FileSort class.
53
                        optimizer::SqlSelect *select,
54
                        unsigned char **sort_keys,
55
                        internal::IO_CACHE *buffpek_pointers,
56
                        internal::IO_CACHE *tempfile, internal::IO_CACHE *indexfile);
57
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
58
  int merge_buffers(SortParam *param,internal::IO_CACHE *from_file,
1905.1.2 by Brian Aker
Filesort fix.
59
                    internal::IO_CACHE *to_file, unsigned char *sort_buffer,
60
                    buffpek *lastbuff,
61
                    buffpek *Fb,
62
                    buffpek *Tb,int flag);
63
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
64
  int merge_index(SortParam *param,
1905.1.2 by Brian Aker
Filesort fix.
65
                  unsigned char *sort_buffer,
66
                  buffpek *buffpek,
67
                  uint32_t maxbuffer,
68
                  internal::IO_CACHE *tempfile,
69
                  internal::IO_CACHE *outfile);
70
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
71
  int merge_many_buff(SortParam *param, unsigned char *sort_buffer,
1905.1.2 by Brian Aker
Filesort fix.
72
                      buffpek *buffpek,
73
                      uint32_t *maxbuffer, internal::IO_CACHE *t_file);
74
75
  uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek *buffpek,
76
                          uint32_t sort_length);
77
78
79
1905.1.1 by Brian Aker
Adding FileSort class.
80
public:
81
82
  FileSort(Session &arg);
83
84
  Session &getSession()
85
  {
86
    return _session;
87
  }
88
89
  ha_rows run(Table *table, SortField *sortorder, uint32_t s_length,
90
              optimizer::SqlSelect *select, ha_rows max_rows,
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
91
              bool sort_positions, ha_rows &examined_rows);
1905.1.1 by Brian Aker
Adding FileSort class.
92
93
};
94
95
} /* namespace drizzled */
96
97
#endif /* DRIZZLED_FILESORT_H */