~drizzle-trunk/drizzle/development

1548.4.99 by Zimin
fix copyright style problem
1
/*
2
  Copyright (C) 2010 Zimin
3
4
  This program is free software; you can redistribute it and/or
5
  modify it under the terms of the GNU General Public License
6
  as published by the Free Software Foundation; either version 2
7
  of the License, or (at your option) any later version.
8
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
*/
1548.4.1 by Zimin
merge from fs-plugin
18
1548.4.120 by Zimin
modify macros to be in line with the change of the filesystem directory name
19
#ifndef PLUGIN_FILESYSTEM_ENGINE_FILESYSTEM_ENGINE_H
20
#define PLUGIN_FILESYSTEM_ENGINE_FILESYSTEM_ENGINE_H
1548.4.1 by Zimin
merge from fs-plugin
21
22
#include <drizzled/cursor.h>
23
#include <drizzled/thr_lock.h>
24
1548.4.118 by Zimin
wrap transparentfile in scoped_ptr
25
#include <boost/scoped_ptr.hpp>
26
1548.4.1 by Zimin
merge from fs-plugin
27
#include <sys/types.h>
28
#include <sys/stat.h>
29
#include <fstream>
30
1548.4.26 by Zimin
basic select is ok again using transparent_file
31
#include "transparent_file.h"
1548.4.104 by ziminq
formatinfo refactored
32
#include "formatinfo.h"
1548.4.113 by Zimin
remove table lock, add FilesystemLock to this storage engine
33
#include "filesystemlock.h"
1548.4.26 by Zimin
basic select is ok again using transparent_file
34
1548.4.17 by Zimin
rename FilesystemShare to FilesystemTableShare
35
class FilesystemTableShare
1548.4.1 by Zimin
merge from fs-plugin
36
{
1548.4.17 by Zimin
rename FilesystemShare to FilesystemTableShare
37
  FilesystemTableShare();
38
  FilesystemTableShare(const FilesystemTableShare &);
39
  FilesystemTableShare& operator=(const FilesystemTableShare &);
1548.4.1 by Zimin
merge from fs-plugin
40
public:
1548.4.17 by Zimin
rename FilesystemShare to FilesystemTableShare
41
  explicit FilesystemTableShare(const std::string name);
42
  ~FilesystemTableShare();
1548.4.1 by Zimin
merge from fs-plugin
43
44
  uint32_t use_count;
45
  const std::string table_name;
1548.4.32 by Zimin
add tina_set like chains to manage the delete.
46
  bool update_file_opened;
1548.4.72 by Zimin
fix two session trying to update at the same time.
47
  bool needs_reopen;
1548.4.1 by Zimin
merge from fs-plugin
48
  pthread_mutex_t mutex;
1548.4.104 by ziminq
formatinfo refactored
49
  FormatInfo format;
1548.4.108 by Zimin
add support for reading '/proc/cpuinfo', it's a enhanced support for reading /proc/meminfo. it has multiple sections.
50
  std::vector< std::map<std::string, std::string> > vm;
1548.4.113 by Zimin
remove table lock, add FilesystemLock to this storage engine
51
  FilesystemLock filesystem_lock;
1548.4.1 by Zimin
merge from fs-plugin
52
};
53
1548.4.16 by Zimin
rename ha_filesystem to FilesystemCursor, more drizzle style.
54
class FilesystemCursor : public drizzled::Cursor
1548.4.1 by Zimin
merge from fs-plugin
55
{
1548.4.17 by Zimin
rename FilesystemShare to FilesystemTableShare
56
  FilesystemTableShare *share;       /* Shared lock info */
1548.4.118 by Zimin
wrap transparentfile in scoped_ptr
57
  boost::scoped_ptr<TransparentFile> file_buff;
1548.4.32 by Zimin
add tina_set like chains to manage the delete.
58
  int file_desc;
59
  std::string update_file_name;
60
  int update_file_desc;
1548.4.108 by Zimin
add support for reading '/proc/cpuinfo', it's a enhanced support for reading /proc/meminfo. it has multiple sections.
61
  size_t tag_depth;
1548.4.26 by Zimin
basic select is ok again using transparent_file
62
  off_t current_position;
1548.4.30 by Zimin
add slots to support doDeleteRecord()
63
  off_t next_position;
1548.4.113 by Zimin
remove table lock, add FilesystemLock to this storage engine
64
  bool thread_locked;
65
  uint32_t sql_command_type; /* Type of SQL command to process */
1548.4.30 by Zimin
add slots to support doDeleteRecord()
66
  /* each slot means an interval in a file which will be deleted later */
67
  std::vector< std::pair<off_t, off_t> > slots;
1548.4.1 by Zimin
merge from fs-plugin
68
69
public:
1869.1.4 by Brian Aker
TableShare is no longer in the house (i.e. we no longer directly have a copy
70
  FilesystemCursor(drizzled::plugin::StorageEngine &engine, drizzled::Table &table_arg);
1548.4.16 by Zimin
rename ha_filesystem to FilesystemCursor, more drizzle style.
71
  ~FilesystemCursor()
1548.4.1 by Zimin
merge from fs-plugin
72
  {
73
  }
74
75
  /** @brief
76
    The name that will be used for display purposes.
77
   */
78
  const char *table_type(void) const { return "FILESYSTEM"; }
79
80
  /*
81
     Called in test_quick_select to determine if indexes should be used.
82
   */
83
  virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
84
85
  /* The next method will never be called */
86
  virtual bool fast_key_read() { return 1;}
87
  drizzled::ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
88
1548.4.77 by Zimin
change ::open according to trunk
89
  int doOpen(const drizzled::TableIdentifier &, int, uint32_t);
1548.4.1 by Zimin
merge from fs-plugin
90
  int close(void);
91
  int doStartTableScan(bool scan=1);
92
  int rnd_next(unsigned char *);
93
  int rnd_pos(unsigned char * , unsigned char *);
94
  void position(const unsigned char *);
95
  int info(uint);
96
  int doEndTableScan();
1548.4.5 by Zimin
add insert support
97
  int doInsertRecord(unsigned char * buf);
1548.4.9 by Zimin
add stubs for update and delete
98
  int doUpdateRecord(const unsigned char *, unsigned char *);
99
  int doDeleteRecord(const unsigned char *);
1548.4.1 by Zimin
merge from fs-plugin
100
101
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
102
                                  uint64_t nb_desired_values,
103
                                  uint64_t *first_value,
1891.2.1 by Monty Taylor
Fixed things to make things compile with clang
104
                                  uint64_t *nb_reserved_values) { (void)offset; (void)increment; (void)nb_desired_values; (void)first_value; (void)nb_reserved_values; }
1548.4.17 by Zimin
rename FilesystemShare to FilesystemTableShare
105
  FilesystemTableShare *get_share(const char *table_name);
1548.4.37 by Zimin
add free_share()
106
  void free_share();
1548.4.113 by Zimin
remove table lock, add FilesystemLock to this storage engine
107
  void critical_section_enter();
108
  void critical_section_exit();
1548.4.11 by Zimin
support delete and update for filesystem storage engine
109
private:
1548.4.86 by Zimin
rename getAllFields to recordToString
110
  void recordToString(std::string& output);
1548.4.30 by Zimin
add slots to support doDeleteRecord()
111
  void addSlot();
1548.4.32 by Zimin
add tina_set like chains to manage the delete.
112
  int openUpdateFile();
1548.4.35 by Zimin
add rnd_pos and position code and some refactoring
113
  int find_current_row(unsigned char *buf);
1548.4.1 by Zimin
merge from fs-plugin
114
};
115
1548.4.120 by Zimin
modify macros to be in line with the change of the filesystem directory name
116
#endif /* PLUGIN_FILESYSTEM_ENGINE_FILESYSTEM_ENGINE_H */