Drizzled Public API Documentation

join_cache.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 namespace drizzled
00023 {
00024 
00025 class Field_blob;
00026 typedef JoinTable JoinTable;
00027 
00032 class CacheField {
00033   /*
00034     Where source data is located (i.e. this points to somewhere in
00035     tableX->getInsertRecord())
00036   */
00037 public:
00038   unsigned char *str;
00039   uint32_t length; /* Length of data at *str, in bytes */
00040   uint32_t blob_length; /* Valid IFF blob_field != 0 */
00041   Field_blob *blob_field;
00042   bool strip; /* true <=> Strip endspaces ?? */
00043   Table *get_rowid; /* _ != NULL <=> */
00044 
00045   CacheField():
00046     str(NULL),
00047     length(0),
00048     blob_length(0),
00049     blob_field(NULL),
00050     strip(false),
00051     get_rowid(NULL)
00052   {}
00053 
00054 };
00055 
00056 class JoinCache
00057 {
00058 public:
00059   unsigned char *buff;
00060   unsigned char *pos;    /* Start of free space in the buffer */
00061   unsigned char *end;
00062   uint32_t records;  /* # of row cominations currently stored in the cache */
00063   uint32_t record_nr;
00064   uint32_t ptr_record;
00065   /*
00066     Number of fields (i.e. cache_field objects). Those correspond to table
00067     columns, and there are also special fields for
00068      - table's column null bits
00069      - table's null-complementation byte
00070      - [new] table's rowid.
00071   */
00072   uint32_t fields;
00073   uint32_t length;
00074   uint32_t blobs;
00075   CacheField *field;
00076   CacheField **blob_ptr;
00077   optimizer::SqlSelect *select;
00078 
00079   JoinCache():
00080     buff(NULL),
00081     pos(NULL),
00082     end(NULL),
00083     records(0),
00084     record_nr(0),
00085     ptr_record(0),
00086     fields(0),
00087     length(0),
00088     blobs(0),
00089     field(NULL),
00090     blob_ptr(NULL),
00091     select(NULL)
00092   {}
00093 
00094   void reset_cache_read();
00095   void reset_cache_write();
00096   bool store_record_in_cache();
00097 };
00098 
00099 int join_init_cache(Session *session, JoinTable *tables, uint32_t table_count);
00100 
00101 } /* namespace drizzled */
00102