~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_sort.h

  • Committer: Patrick Crews
  • Date: 2010-08-17 17:42:29 UTC
  • mfrom: (1711.1.24 build)
  • Revision ID: gleebix@gmail.com-20100817174229-e28p5025ndgkkxif
Rollup patch - optimizer fixes, mutex removal, client cleanup, translations update

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
typedef struct st_io_cache IO_CACHE;
34
34
}
35
35
 
36
 
typedef struct st_sort_field SORT_FIELD;
37
36
class Field;
38
37
class Table;
 
38
class SortField;
39
39
 
40
40
 
41
41
/* Defines used by filesort and uniques */
44
44
#define MERGEBUFF2              15
45
45
 
46
46
/*
47
 
   The structure SORT_ADDON_FIELD describes a fixed layout
 
47
   The structure sort_addon_field_st describes a fixed layout
48
48
   for field values appended to sorted values in records to be sorted
49
49
   in the sort buffer.
50
50
   Only fixed layout is supported now.
59
59
   the callback function 'unpack_addon_fields'.
60
60
*/
61
61
 
62
 
typedef struct st_sort_addon_field {  /* Sort addon packed field */
 
62
struct sort_addon_field_st {  /* Sort addon packed field */
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
 
} SORT_ADDON_FIELD;
69
 
 
70
 
typedef struct st_buffpek {             /* Struktur om sorteringsbuffrarna */
 
68
 
 
69
  sort_addon_field_st() :
 
70
    field(NULL),
 
71
    offset(0),
 
72
    null_offset(0),
 
73
    length(0),
 
74
    null_bit(0)
 
75
  { }
 
76
 
 
77
};
 
78
 
 
79
struct buffpek_st {             /* Struktur om sorteringsbuffrarna */
71
80
  off_t file_pos;                       /* Where we are in the sort file */
72
 
  unsigned char *base,*key;                     /* key pointers */
 
81
  unsigned char *base;                  /* key pointers */
 
82
  unsigned char *key;                   /* key pointers */
73
83
  ha_rows count;                        /* Number of rows in table */
74
84
  size_t mem_count;                     /* numbers of keys in memory */
75
85
  size_t max_keys;                      /* Max keys in buffert */
76
 
} BUFFPEK;
 
86
 
 
87
  buffpek_st() :
 
88
    file_pos(0),
 
89
    base(0),
 
90
    key(0),
 
91
    count(0),
 
92
    mem_count(0),
 
93
    max_keys(0)
 
94
  { }
 
95
 
 
96
};
77
97
 
78
98
struct BUFFPEK_COMPARE_CONTEXT
79
99
{
90
110
  uint32_t keys;                                /* Max keys / buffer */
91
111
  ha_rows max_rows,examined_rows;
92
112
  Table *sort_form;                     /* For quicker make_sortkey */
93
 
  SORT_FIELD *local_sortorder;
94
 
  SORT_FIELD *end;
95
 
  SORT_ADDON_FIELD *addon_field; /* Descriptors for companion fields */
 
113
  SortField *local_sortorder;
 
114
  SortField *end;
 
115
  sort_addon_field_st *addon_field; /* Descriptors for companion fields */
96
116
  unsigned char *unique_buff;
97
117
  bool not_killable;
98
118
  char* tmp_buffer;
105
125
 
106
126
 
107
127
int merge_many_buff(SORTPARAM *param, unsigned char *sort_buffer,
108
 
                    BUFFPEK *buffpek,
109
 
                    uint32_t *maxbuffer, internal::IO_CACHE *t_file);
110
 
uint32_t read_to_buffer(internal::IO_CACHE *fromfile,BUFFPEK *buffpek,
111
 
                    uint32_t sort_length);
 
128
                    buffpek_st *buffpek,
 
129
                    uint32_t *maxbuffer, internal::IO_CACHE *t_file);
 
130
 
 
131
uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek_st *buffpek,
 
132
                        uint32_t sort_length);
 
133
 
112
134
int merge_buffers(SORTPARAM *param,internal::IO_CACHE *from_file,
113
 
                  internal::IO_CACHE *to_file, unsigned char *sort_buffer,
114
 
                  BUFFPEK *lastbuff,BUFFPEK *Fb,
115
 
                  BUFFPEK *Tb,int flag);
 
135
                  internal::IO_CACHE *to_file, unsigned char *sort_buffer,
 
136
                  buffpek_st *lastbuff,
 
137
                  buffpek_st *Fb,
 
138
                  buffpek_st *Tb,int flag);
116
139
 
117
140
} /* namespace drizzled */
118
141