~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 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
 */
1 by brian
clean slate
19
1122.2.10 by Monty Taylor
Fixed all of the include guards.
20
#ifndef DRIZZLED_SQL_SORT_H
21
#define DRIZZLED_SQL_SORT_H
471 by Monty Taylor
Added header protections.
22
1241.9.46 by Monty Taylor
Removed some more evil.
23
#include <unistd.h>
1241.9.23 by Monty Taylor
Removed sql_table.h from server_includes.h.
24
#include "drizzled/base.h"
1241.9.45 by Monty Taylor
Added a header for qsort_cmp.
25
#include "drizzled/qsort_cmp.h"
1241.9.12 by Monty Taylor
Trims more out of server_includes.h.
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
29
30
namespace internal
31
{
32
typedef struct st_io_cache IO_CACHE;
33
}
34
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
35
class Field;
1241.9.30 by Monty Taylor
More cruft gone.
36
class Table;
1711.6.1 by Brian Aker
Style on structure cleanup
37
class SortField;
471 by Monty Taylor
Added header protections.
38
1241.9.45 by Monty Taylor
Added a header for qsort_cmp.
39
1 by brian
clean slate
40
/* Defines used by filesort and uniques */
41
42
#define MERGEBUFF		7
43
#define MERGEBUFF2		15
44
45
/*
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
46
   The structure sort_addon_field describes a fixed layout
1 by brian
clean slate
47
   for field values appended to sorted values in records to be sorted
48
   in the sort buffer.
49
   Only fixed layout is supported now.
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
50
   Null bit maps for the appended values is placed before the values
1 by brian
clean slate
51
   themselves. Offsets are from the last sorted field, that is from the
52
   record referefence, which is still last component of sorted records.
53
   It is preserved for backward compatiblility.
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
54
   The structure is used tp store values of the additional fields
1 by brian
clean slate
55
   in the sort buffer. It is used also when these values are read
56
   from a temporary file/buffer. As the reading procedures are beyond the
57
   scope of the 'filesort' code the values have to be retrieved via
58
   the callback function 'unpack_addon_fields'.
59
*/
60
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
61
class sort_addon_field {  /* Sort addon packed field */
62
public:
1 by brian
clean slate
63
  Field *field;          /* Original field */
482 by Brian Aker
Remove uint.
64
  uint32_t   offset;         /* Offset from the last sorted field */
65
  uint32_t   null_offset;    /* Offset to to null bit from the last sorted field */
66
  uint32_t   length;         /* Length in the sort buffer */
206 by Brian Aker
Removed final uint dead types.
67
  uint8_t  null_bit;       /* Null bit mask for the field */
1711.6.1 by Brian Aker
Style on structure cleanup
68
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
69
  sort_addon_field() :
1711.6.1 by Brian Aker
Style on structure cleanup
70
    field(NULL),
71
    offset(0),
72
    null_offset(0),
73
    length(0),
74
    null_bit(0)
75
  { }
76
77
};
78
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
79
class buffpek {		/* Struktur om sorteringsbuffrarna */
80
public:
1241.9.45 by Monty Taylor
Added a header for qsort_cmp.
81
  off_t file_pos;			/* Where we are in the sort file */
1711.6.1 by Brian Aker
Style on structure cleanup
82
  unsigned char *base;			/* key pointers */
83
  unsigned char *key;			/* key pointers */
1 by brian
clean slate
84
  ha_rows count;			/* Number of rows in table */
1241.9.46 by Monty Taylor
Removed some more evil.
85
  size_t mem_count;			/* numbers of keys in memory */
86
  size_t max_keys;			/* Max keys in buffert */
1711.6.1 by Brian Aker
Style on structure cleanup
87
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
88
  buffpek() :
1711.6.1 by Brian Aker
Style on structure cleanup
89
    file_pos(0),
90
    base(0),
91
    key(0),
92
    count(0),
93
    mem_count(0),
94
    max_keys(0)
95
  { }
96
97
};
1 by brian
clean slate
98
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
99
class BUFFPEK_COMPARE_CONTEXT
1 by brian
clean slate
100
{
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
101
public:
1 by brian
clean slate
102
  qsort_cmp2 key_compare;
103
  void *key_compare_arg;
104
};
105
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
106
class sort_param {
107
public:
482 by Brian Aker
Remove uint.
108
  uint32_t rec_length;          /* Length of sorted records */
109
  uint32_t sort_length;			/* Length of sorted columns */
110
  uint32_t ref_length;			/* Length of record ref. */
111
  uint32_t addon_length;        /* Length of added packed fields */
112
  uint32_t res_length;          /* Length of records in final sorted file/buffer */
113
  uint32_t keys;				/* Max keys / buffer */
1 by brian
clean slate
114
  ha_rows max_rows,examined_rows;
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
115
  Table *sort_form;			/* For quicker make_sortkey */
1711.6.1 by Brian Aker
Style on structure cleanup
116
  SortField *local_sortorder;
117
  SortField *end;
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
118
  sort_addon_field *addon_field; /* Descriptors for companion fields */
481 by Brian Aker
Remove all of uchar.
119
  unsigned char *unique_buff;
1 by brian
clean slate
120
  bool not_killable;
121
  char* tmp_buffer;
122
  /* The fields below are used only by Unique class */
123
  qsort2_cmp compare;
124
  BUFFPEK_COMPARE_CONTEXT cmp_context;
1578.4.8 by Brian Aker
Modify merge-buffer to use std::vector in one location (just curious to see
125
};
126
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
127
typedef class sort_param SORTPARAM;
1 by brian
clean slate
128
129
481 by Brian Aker
Remove all of uchar.
130
int merge_many_buff(SORTPARAM *param, unsigned char *sort_buffer,
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
131
                    buffpek *buffpek,
1711.6.1 by Brian Aker
Style on structure cleanup
132
                    uint32_t *maxbuffer, internal::IO_CACHE *t_file);
133
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
134
uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek *buffpek,
1711.6.1 by Brian Aker
Style on structure cleanup
135
                        uint32_t sort_length);
136
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
137
int merge_buffers(SORTPARAM *param,internal::IO_CACHE *from_file,
1711.6.1 by Brian Aker
Style on structure cleanup
138
                  internal::IO_CACHE *to_file, unsigned char *sort_buffer,
1826.1.1 by tdavies
Bug:621861 Changed C structs to C++ class in the following files: filesort.cc, filesort_info.h, sql_sort.h, table.h. removed the '_st' from the name of some of the classes. For more detail of changes made read the merge proposal notes.
139
                  buffpek *lastbuff,
140
                  buffpek *Fb,
141
                  buffpek *Tb,int flag);
471 by Monty Taylor
Added header protections.
142
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
143
} /* namespace drizzled */
144
1122.2.10 by Monty Taylor
Fixed all of the include guards.
145
#endif /* DRIZZLED_SQL_SORT_H */