Drizzled Public API Documentation

cursor.h

00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2009 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; 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 #pragma once
00022 
00023 #include <drizzled/cursor.h>
00024 
00025 #include <plugin/function_engine/function.h>
00026 #include <drizzled/base.h>
00027 
00028 class FunctionCursor: public drizzled::Cursor
00029 {
00030   drizzled::plugin::TableFunction *tool;
00031   drizzled::plugin::TableFunction::Generator *generator;
00032   size_t row_cache_position;
00033   std::vector<unsigned char> row_cache;
00034   drizzled::ha_rows estimate_of_rows;
00035   drizzled::ha_rows rows_returned;
00036 
00037   void wipeCache();
00038 
00039   std::vector <unsigned char> record_buffer; // for pack_row
00040   uint32_t max_row_length();
00041   unsigned int pack_row(const unsigned char *record);
00042 
00043 public:
00044   FunctionCursor(drizzled::plugin::StorageEngine &engine,
00045                  drizzled::Table &table_arg);
00046   ~FunctionCursor() {}
00047 
00048   int open(const char *name, int mode, uint32_t test_if_locked);
00049 
00050   int close(void);
00051 
00052   int reset()
00053   {
00054     return extra(drizzled::HA_EXTRA_RESET_STATE);
00055   }
00056 
00057   int doStartTableScan(bool scan);
00058 
00059   /* get the next row and copy it into buf */
00060   int rnd_next(unsigned char *buf);
00061 
00062   /* locate row pointed to by pos, copy it into buf */
00063   int rnd_pos(unsigned char *buf, unsigned char *pos);
00064 
00065   int doEndTableScan();
00066 
00067   int extra(enum drizzled::ha_extra_function);
00068 
00069   /* record position of a record for reordering */
00070   void position(const unsigned char *record);
00071 
00072   int info(uint32_t flag);
00073 
00077   drizzled::ha_rows estimate_rows_upper_bound()
00078   {
00079     return estimate_of_rows;
00080   }
00081 
00082   void get_auto_increment(uint64_t, uint64_t,
00083                           uint64_t,
00084                           uint64_t *,
00085                           uint64_t *)
00086   {}
00087 };
00088