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