~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_sort.h

  • Committer: Brian Aker
  • Date: 2010-10-09 17:14:15 UTC
  • mfrom: (1827.1.3 trunk-drizzle)
  • Revision ID: brian@tangent.org-20101009171415-tw1rjj8s3k2mrqps
Merge of tdavies (align numbers in trunk).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#define DRIZZLED_SQL_SORT_H
22
22
 
23
23
#include <unistd.h>
24
 
 
25
24
#include "drizzled/base.h"
26
25
#include "drizzled/qsort_cmp.h"
27
26
 
44
43
#define MERGEBUFF2              15
45
44
 
46
45
/*
47
 
   The structure sort_addon_field_st describes a fixed layout
 
46
   The structure sort_addon_field describes a fixed layout
48
47
   for field values appended to sorted values in records to be sorted
49
48
   in the sort buffer.
50
49
   Only fixed layout is supported now.
59
58
   the callback function 'unpack_addon_fields'.
60
59
*/
61
60
 
62
 
struct sort_addon_field_st {  /* Sort addon packed field */
 
61
class sort_addon_field {  /* Sort addon packed field */
 
62
public:
63
63
  Field *field;          /* Original field */
64
64
  uint32_t   offset;         /* Offset from the last sorted field */
65
65
  uint32_t   null_offset;    /* Offset to to null bit from the last sorted field */
66
66
  uint32_t   length;         /* Length in the sort buffer */
67
67
  uint8_t  null_bit;       /* Null bit mask for the field */
68
68
 
69
 
  sort_addon_field_st() :
 
69
  sort_addon_field() :
70
70
    field(NULL),
71
71
    offset(0),
72
72
    null_offset(0),
76
76
 
77
77
};
78
78
 
79
 
struct buffpek_st {             /* Struktur om sorteringsbuffrarna */
 
79
class buffpek {         /* Struktur om sorteringsbuffrarna */
 
80
public:
80
81
  off_t file_pos;                       /* Where we are in the sort file */
81
82
  unsigned char *base;                  /* key pointers */
82
83
  unsigned char *key;                   /* key pointers */
84
85
  size_t mem_count;                     /* numbers of keys in memory */
85
86
  size_t max_keys;                      /* Max keys in buffert */
86
87
 
87
 
  buffpek_st() :
 
88
  buffpek() :
88
89
    file_pos(0),
89
90
    base(0),
90
91
    key(0),
95
96
 
96
97
};
97
98
 
98
 
struct BUFFPEK_COMPARE_CONTEXT
 
99
class BUFFPEK_COMPARE_CONTEXT
99
100
{
 
101
public:
100
102
  qsort_cmp2 key_compare;
101
103
  void *key_compare_arg;
102
104
};
103
105
 
104
 
struct st_sort_param {
 
106
class sort_param {
 
107
public:
105
108
  uint32_t rec_length;          /* Length of sorted records */
106
109
  uint32_t sort_length;                 /* Length of sorted columns */
107
110
  uint32_t ref_length;                  /* Length of record ref. */
112
115
  Table *sort_form;                     /* For quicker make_sortkey */
113
116
  SortField *local_sortorder;
114
117
  SortField *end;
115
 
  sort_addon_field_st *addon_field; /* Descriptors for companion fields */
 
118
  sort_addon_field *addon_field; /* Descriptors for companion fields */
116
119
  unsigned char *unique_buff;
117
120
  bool not_killable;
118
121
  char* tmp_buffer;
121
124
  BUFFPEK_COMPARE_CONTEXT cmp_context;
122
125
};
123
126
 
124
 
typedef struct st_sort_param SORTPARAM;
 
127
typedef class sort_param SORTPARAM;
125
128
 
126
129
 
127
130
int merge_many_buff(SORTPARAM *param, unsigned char *sort_buffer,
128
 
                    buffpek_st *buffpek,
 
131
                    buffpek *buffpek,
129
132
                    uint32_t *maxbuffer, internal::IO_CACHE *t_file);
130
133
 
131
 
uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek_st *buffpek,
 
134
uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek *buffpek,
132
135
                        uint32_t sort_length);
133
136
 
134
137
int merge_buffers(SORTPARAM *param,internal::IO_CACHE *from_file,
135
138
                  internal::IO_CACHE *to_file, unsigned char *sort_buffer,
136
 
                  buffpek_st *lastbuff,
137
 
                  buffpek_st *Fb,
138
 
                  buffpek_st *Tb,int flag);
 
139
                  buffpek *lastbuff,
 
140
                  buffpek *Fb,
 
141
                  buffpek *Tb,int flag);
139
142
 
140
143
} /* namespace drizzled */
141
144