Drizzled Public API Documentation

join_cache.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
22 namespace drizzled {
23 
28 class CacheField {
29  /*
30  Where source data is located (i.e. this points to somewhere in
31  tableX->getInsertRecord())
32  */
33 public:
34  unsigned char *str;
35  uint32_t length; /* Length of data at *str, in bytes */
36  uint32_t blob_length; /* Valid IFF blob_field != 0 */
37  Field_blob *blob_field;
38  bool strip; /* true <=> Strip endspaces ?? */
39  Table *get_rowid; /* _ != NULL <=> */
40 
41  CacheField():
42  str(NULL),
43  length(0),
44  blob_length(0),
45  blob_field(NULL),
46  strip(false),
47  get_rowid(NULL)
48  {}
49 
50 };
51 
52 class JoinCache
53 {
54 public:
55  unsigned char *buff;
56  unsigned char *pos; /* Start of free space in the buffer */
57  unsigned char *end;
58  uint32_t records; /* # of row cominations currently stored in the cache */
59  uint32_t record_nr;
60  uint32_t ptr_record;
61  /*
62  Number of fields (i.e. cache_field objects). Those correspond to table
63  columns, and there are also special fields for
64  - table's column null bits
65  - table's null-complementation byte
66  - [new] table's rowid.
67  */
68  uint32_t fields;
69  uint32_t length;
70  uint32_t blobs;
71  CacheField *field;
72  CacheField **blob_ptr;
73  optimizer::SqlSelect *select;
74 
75  JoinCache():
76  buff(NULL),
77  pos(NULL),
78  end(NULL),
79  records(0),
80  record_nr(0),
81  ptr_record(0),
82  fields(0),
83  length(0),
84  blobs(0),
85  field(NULL),
86  blob_ptr(NULL),
87  select(NULL)
88  {}
89 
90  void reset_cache_read();
91  void reset_cache_write();
92  bool store_record_in_cache();
93 };
94 
95 int join_init_cache(Session *session, JoinTable *tables, uint32_t table_count);
96 
97 } /* namespace drizzled */
98