Drizzled Public API Documentation

sql_sort.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <unistd.h>
00023 #include <drizzled/base.h>
00024 #include <drizzled/common_fwd.h>
00025 #include <drizzled/qsort_cmp.h>
00026 
00027 namespace drizzled {
00028 
00029 /*
00030    The structure sort_addon_field describes a fixed layout
00031    for field values appended to sorted values in records to be sorted
00032    in the sort buffer.
00033    Only fixed layout is supported now.
00034    Null bit maps for the appended values is placed before the values
00035    themselves. Offsets are from the last sorted field, that is from the
00036    record referefence, which is still last component of sorted records.
00037    It is preserved for backward compatiblility.
00038    The structure is used tp store values of the additional fields
00039    in the sort buffer. It is used also when these values are read
00040    from a temporary file/buffer. As the reading procedures are beyond the
00041    scope of the 'filesort' code the values have to be retrieved via
00042    the callback function 'unpack_addon_fields'.
00043 */
00044 
00045 class sort_addon_field {  /* Sort addon packed field */
00046 public:
00047   Field *field;          /* Original field */
00048   uint32_t   offset;         /* Offset from the last sorted field */
00049   uint32_t   null_offset;    /* Offset to to null bit from the last sorted field */
00050   uint32_t   length;         /* Length in the sort buffer */
00051   uint8_t  null_bit;       /* Null bit mask for the field */
00052 
00053   sort_addon_field() :
00054     field(NULL),
00055     offset(0),
00056     null_offset(0),
00057     length(0),
00058     null_bit(0)
00059   { }
00060 
00061 };
00062 
00063 class buffpek {   /* Struktur om sorteringsbuffrarna */
00064 public:
00065   off_t file_pos;     /* Where we are in the sort file */
00066   unsigned char *base;      /* key pointers */
00067   unsigned char *key;     /* key pointers */
00068   ha_rows count;      /* Number of rows in table */
00069   size_t mem_count;     /* numbers of keys in memory */
00070   size_t max_keys;      /* Max keys in buffert */
00071 
00072   buffpek() :
00073     file_pos(0),
00074     base(0),
00075     key(0),
00076     count(0),
00077     mem_count(0),
00078     max_keys(0)
00079   { }
00080 
00081 };
00082 
00083 } /* namespace drizzled */
00084