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/qsort_cmp.h>
00025 
00026 namespace drizzled
00027 {
00028 
00029 namespace internal
00030 {
00031 typedef struct st_io_cache IO_CACHE;
00032 }
00033 
00034 class Field;
00035 class Table;
00036 class SortField;
00037 
00038 /*
00039    The structure sort_addon_field describes a fixed layout
00040    for field values appended to sorted values in records to be sorted
00041    in the sort buffer.
00042    Only fixed layout is supported now.
00043    Null bit maps for the appended values is placed before the values
00044    themselves. Offsets are from the last sorted field, that is from the
00045    record referefence, which is still last component of sorted records.
00046    It is preserved for backward compatiblility.
00047    The structure is used tp store values of the additional fields
00048    in the sort buffer. It is used also when these values are read
00049    from a temporary file/buffer. As the reading procedures are beyond the
00050    scope of the 'filesort' code the values have to be retrieved via
00051    the callback function 'unpack_addon_fields'.
00052 */
00053 
00054 class sort_addon_field {  /* Sort addon packed field */
00055 public:
00056   Field *field;          /* Original field */
00057   uint32_t   offset;         /* Offset from the last sorted field */
00058   uint32_t   null_offset;    /* Offset to to null bit from the last sorted field */
00059   uint32_t   length;         /* Length in the sort buffer */
00060   uint8_t  null_bit;       /* Null bit mask for the field */
00061 
00062   sort_addon_field() :
00063     field(NULL),
00064     offset(0),
00065     null_offset(0),
00066     length(0),
00067     null_bit(0)
00068   { }
00069 
00070 };
00071 
00072 class buffpek {   /* Struktur om sorteringsbuffrarna */
00073 public:
00074   off_t file_pos;     /* Where we are in the sort file */
00075   unsigned char *base;      /* key pointers */
00076   unsigned char *key;     /* key pointers */
00077   ha_rows count;      /* Number of rows in table */
00078   size_t mem_count;     /* numbers of keys in memory */
00079   size_t max_keys;      /* Max keys in buffert */
00080 
00081   buffpek() :
00082     file_pos(0),
00083     base(0),
00084     key(0),
00085     count(0),
00086     mem_count(0),
00087     max_keys(0)
00088   { }
00089 
00090 };
00091 
00092 } /* namespace drizzled */
00093