~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/archive_engine.h

  • Committer: Monty Taylor
  • Date: 2011-01-26 19:15:55 UTC
  • mto: This revision was merged to the branch mainline in revision 2126.
  • Revision ID: mordred@inaugust.com-20110126191555-nq5nnzyscvngsip2
Turns on -fvisibility=hidden by default. Symbols intended to be used by
plugins need to be marked with DRIZZLED_API.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
   Copyright (C) 2010 Brian Aker
 
3
 
 
4
  This program is free software; you can redistribute it and/or modify
 
5
  it under the terms of the GNU General Public License as published by
 
6
  the Free Software Foundation; version 2 of the License.
 
7
 
 
8
  This program is distributed in the hope that it will be useful,
 
9
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
  GNU General Public License for more details.
 
12
 
 
13
  You should have received a copy of the GNU General Public License
 
14
  along with this program; if not, write to the Free Software
 
15
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
16
 
 
17
#include "drizzled/field.h"
 
18
#include "drizzled/field/blob.h"
 
19
#include "plugin/myisam/myisam.h"
 
20
#include "drizzled/table.h"
 
21
#include "drizzled/session.h"
 
22
#include <drizzled/thr_lock.h>
 
23
#include <drizzled/my_hash.h>
 
24
#include <drizzled/cursor.h>
 
25
 
 
26
#include <fcntl.h>
 
27
#include <inttypes.h>
 
28
#include <string>
 
29
#include <sys/stat.h>
 
30
#include <unistd.h>
 
31
#include <zlib.h>
 
32
 
 
33
#include <boost/unordered_map.hpp>
 
34
#include "drizzled/util/string.h"
 
35
 
 
36
#include "azio.h"
 
37
#include "plugin/archive/ha_archive.h"
 
38
 
 
39
 
 
40
 
 
41
#include <cstdio>
 
42
#include <string>
 
43
#include <map>
 
44
 
 
45
#ifndef PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
 
46
#define PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
 
47
 
 
48
/* The file extension */
 
49
#define ARZ ".arz"               // The data file
 
50
#define ARN ".ARN"               // Files used during an optimize call
 
51
 
 
52
/*
 
53
  We just implement one additional file extension.
 
54
*/
 
55
static const char *ha_archive_exts[] = {
 
56
  ARZ,
 
57
  NULL
 
58
};
 
59
 
 
60
 
 
61
class ArchiveEngine : public drizzled::plugin::StorageEngine
 
62
{
 
63
  typedef boost::unordered_map<std::string, ArchiveShare *, drizzled::util::insensitive_hash, drizzled::util::insensitive_equal_to> ArchiveMap;
 
64
  ArchiveMap archive_open_tables;
 
65
 
 
66
  /* Variables for archive share methods */
 
67
  pthread_mutex_t _mutex;
 
68
 
 
69
public:
 
70
  ArchiveEngine() :
 
71
    drizzled::plugin::StorageEngine("ARCHIVE",
 
72
                                    drizzled::HTON_STATS_RECORDS_IS_EXACT |
 
73
                                    drizzled::HTON_HAS_RECORDS),
 
74
    archive_open_tables()
 
75
  {
 
76
    pthread_mutex_init(&_mutex, NULL);
 
77
    table_definition_ext= ARZ;
 
78
  }
 
79
  ~ArchiveEngine()
 
80
  {
 
81
    pthread_mutex_destroy(&_mutex);
 
82
  }
 
83
 
 
84
  pthread_mutex_t &mutex()
 
85
  {
 
86
    return _mutex;
 
87
  }
 
88
 
 
89
  virtual drizzled::Cursor *create(drizzled::Table &table)
 
90
  {
 
91
    return new ha_archive(*this, table);
 
92
  }
 
93
 
 
94
  const char **bas_ext() const {
 
95
    return ha_archive_exts;
 
96
  }
 
97
 
 
98
  int doCreateTable(drizzled::Session &session,
 
99
                    drizzled::Table &table_arg,
 
100
                    const drizzled::identifier::Table &identifier,
 
101
                    drizzled::message::Table& proto);
 
102
 
 
103
  int doGetTableDefinition(drizzled::Session& session,
 
104
                           const drizzled::identifier::Table &identifier,
 
105
                           drizzled::message::Table &table_message);
 
106
 
 
107
  int doDropTable(drizzled::Session&, const drizzled::identifier::Table &identifier);
 
108
 
 
109
  ArchiveShare *findOpenTable(const std::string table_name);
 
110
  void addOpenTable(const std::string &table_name, ArchiveShare *);
 
111
  void deleteOpenTable(const std::string &table_name);
 
112
 
 
113
  uint32_t max_supported_keys()          const { return 1; }
 
114
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
 
115
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
 
116
 
 
117
  uint32_t index_flags(enum  drizzled::ha_key_alg) const
 
118
  {
 
119
    return HA_ONLY_WHOLE_INDEX;
 
120
  }
 
121
 
 
122
  bool doDoesTableExist(drizzled::Session&, const drizzled::identifier::Table &identifier);
 
123
  int doRenameTable(drizzled::Session&, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to);
 
124
 
 
125
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
 
126
                             const drizzled::identifier::Schema &schema_identifier,
 
127
                             drizzled::identifier::Table::vector &set_of_identifiers);
 
128
};
 
129
 
 
130
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */