~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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
32
#pragma once
1905.1.1 by Brian Aker
Adding FileSort class.
33
34
namespace drizzled {
35
2252.1.13 by Olaf van der Spek
Common fwd
36
class FileSort 
37
{
1905.1.1 by Brian Aker
Adding FileSort class.
38
  Session &_session;
39
40
  uint32_t sortlength(SortField *sortorder, uint32_t s_length, bool *multi_byte_charset);
41
  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.
42
  ha_rows find_all_keys(SortParam *param, 
1905.1.1 by Brian Aker
Adding FileSort class.
43
                        optimizer::SqlSelect *select,
44
                        unsigned char **sort_keys,
2296.1.1 by Mark Atwood
Merge in Fixes of Brian's IOCACHE.
45
                        internal::io_cache_st *buffpek_pointers,
46
                        internal::io_cache_st *tempfile, internal::io_cache_st *indexfile);
1905.1.1 by Brian Aker
Adding FileSort class.
47
2296.1.1 by Mark Atwood
Merge in Fixes of Brian's IOCACHE.
48
  int merge_buffers(SortParam *param,internal::io_cache_st *from_file,
49
                    internal::io_cache_st *to_file, unsigned char *sort_buffer,
1905.1.2 by Brian Aker
Filesort fix.
50
                    buffpek *lastbuff,
51
                    buffpek *Fb,
52
                    buffpek *Tb,int flag);
53
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
54
  int merge_index(SortParam *param,
1905.1.2 by Brian Aker
Filesort fix.
55
                  unsigned char *sort_buffer,
56
                  buffpek *buffpek,
57
                  uint32_t maxbuffer,
2296.1.1 by Mark Atwood
Merge in Fixes of Brian's IOCACHE.
58
                  internal::io_cache_st *tempfile,
59
                  internal::io_cache_st *outfile);
1905.1.2 by Brian Aker
Filesort fix.
60
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
61
  int merge_many_buff(SortParam *param, unsigned char *sort_buffer,
1905.1.2 by Brian Aker
Filesort fix.
62
                      buffpek *buffpek,
2296.1.1 by Mark Atwood
Merge in Fixes of Brian's IOCACHE.
63
                      uint32_t *maxbuffer, internal::io_cache_st *t_file);
1905.1.2 by Brian Aker
Filesort fix.
64
2296.1.1 by Mark Atwood
Merge in Fixes of Brian's IOCACHE.
65
  uint32_t read_to_buffer(internal::io_cache_st *fromfile, buffpek *buffpek,
1905.1.2 by Brian Aker
Filesort fix.
66
                          uint32_t sort_length);
67
68
69
1905.1.1 by Brian Aker
Adding FileSort class.
70
public:
71
72
  FileSort(Session &arg);
73
74
  Session &getSession()
75
  {
76
    return _session;
77
  }
78
79
  ha_rows run(Table *table, SortField *sortorder, uint32_t s_length,
80
              optimizer::SqlSelect *select, ha_rows max_rows,
1908.1.1 by Brian Aker
Merge in encapsulations in filesort.
81
              bool sort_positions, ha_rows &examined_rows);
1905.1.1 by Brian Aker
Adding FileSort class.
82
83
};
84
85
} /* namespace drizzled */
86