Drizzled Public API Documentation

filesort.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
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; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 /* 
00022   This is a "work in progress". The concept needs to be replicated throughout
00023   the code, but we will start with baby steps for the moment. To not incur
00024   cost until we are complete, for the moment it will do no allocation.
00025 
00026   This is mainly here so that it can be used in the SE interface for
00027   the time being.
00028 
00029   This will replace Table_ident.
00030   */
00031 
00032 #pragma once
00033 
00034 namespace drizzled {
00035 
00036 class Session;
00037 class Table;
00038 class SortField;
00039 
00040 namespace optimizer {
00041 class SqlSelect;
00042 }
00043 
00044 class SortParam;
00045 
00046 class FileSort {
00047   Session &_session;
00048 
00049   uint32_t sortlength(SortField *sortorder, uint32_t s_length, bool *multi_byte_charset);
00050   sort_addon_field *get_addon_fields(Field **ptabfield, uint32_t sortlength, uint32_t *plength);
00051   ha_rows find_all_keys(SortParam *param, 
00052                         optimizer::SqlSelect *select,
00053                         unsigned char **sort_keys,
00054                         internal::IO_CACHE *buffpek_pointers,
00055                         internal::IO_CACHE *tempfile, internal::IO_CACHE *indexfile);
00056 
00057   int merge_buffers(SortParam *param,internal::IO_CACHE *from_file,
00058                     internal::IO_CACHE *to_file, unsigned char *sort_buffer,
00059                     buffpek *lastbuff,
00060                     buffpek *Fb,
00061                     buffpek *Tb,int flag);
00062 
00063   int merge_index(SortParam *param,
00064                   unsigned char *sort_buffer,
00065                   buffpek *buffpek,
00066                   uint32_t maxbuffer,
00067                   internal::IO_CACHE *tempfile,
00068                   internal::IO_CACHE *outfile);
00069 
00070   int merge_many_buff(SortParam *param, unsigned char *sort_buffer,
00071                       buffpek *buffpek,
00072                       uint32_t *maxbuffer, internal::IO_CACHE *t_file);
00073 
00074   uint32_t read_to_buffer(internal::IO_CACHE *fromfile, buffpek *buffpek,
00075                           uint32_t sort_length);
00076 
00077 
00078 
00079 public:
00080 
00081   FileSort(Session &arg);
00082 
00083   Session &getSession()
00084   {
00085     return _session;
00086   }
00087 
00088   ha_rows run(Table *table, SortField *sortorder, uint32_t s_length,
00089               optimizer::SqlSelect *select, ha_rows max_rows,
00090               bool sort_positions, ha_rows &examined_rows);
00091 
00092 };
00093 
00094 } /* namespace drizzled */
00095