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 FileSort 
00037 {
00038   Session &_session;
00039 
00040   uint32_t sortlength(SortField *sortorder, uint32_t s_length, bool *multi_byte_charset);
00041   sort_addon_field *get_addon_fields(Field **ptabfield, uint32_t sortlength, uint32_t *plength);
00042   ha_rows find_all_keys(SortParam *param, 
00043                         optimizer::SqlSelect *select,
00044                         unsigned char **sort_keys,
00045                         internal::io_cache_st *buffpek_pointers,
00046                         internal::io_cache_st *tempfile, internal::io_cache_st *indexfile);
00047 
00048   int merge_buffers(SortParam *param,internal::io_cache_st *from_file,
00049                     internal::io_cache_st *to_file, unsigned char *sort_buffer,
00050                     buffpek *lastbuff,
00051                     buffpek *Fb,
00052                     buffpek *Tb,int flag);
00053 
00054   int merge_index(SortParam *param,
00055                   unsigned char *sort_buffer,
00056                   buffpek *buffpek,
00057                   uint32_t maxbuffer,
00058                   internal::io_cache_st *tempfile,
00059                   internal::io_cache_st *outfile);
00060 
00061   int merge_many_buff(SortParam *param, unsigned char *sort_buffer,
00062                       buffpek *buffpek,
00063                       uint32_t *maxbuffer, internal::io_cache_st *t_file);
00064 
00065   uint32_t read_to_buffer(internal::io_cache_st *fromfile, buffpek *buffpek,
00066                           uint32_t sort_length);
00067 
00068 
00069 
00070 public:
00071 
00072   FileSort(Session &arg);
00073 
00074   Session &getSession()
00075   {
00076     return _session;
00077   }
00078 
00079   ha_rows run(Table *table, SortField *sortorder, uint32_t s_length,
00080               optimizer::SqlSelect *select, ha_rows max_rows,
00081               bool sort_positions, ha_rows &examined_rows);
00082 
00083 };
00084 
00085 } /* namespace drizzled */
00086