~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/archive_engine.h

  • Committer: Monty Taylor
  • Date: 2008-08-05 19:01:20 UTC
  • mto: (266.1.1 codestyle)
  • mto: This revision was merged to the branch mainline in revision 266.
  • Revision ID: monty@inaugust.com-20080805190120-tsuziqz2mfqcw7pe
Removed libmysyslt.la, made mysys a noinst_ and made everything use it. It's
not a standalone lib, there's no reason to pretend otherwise.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
16
 
 
17
 
#include "drizzled/field.h"
18
 
#include "drizzled/field/blob.h"
19
 
#include "drizzled/field/timestamp.h"
20
 
#include "plugin/myisam/myisam.h"
21
 
#include "drizzled/table.h"
22
 
#include "drizzled/session.h"
23
 
#include <drizzled/thr_lock.h>
24
 
#include <drizzled/my_hash.h>
25
 
#include <drizzled/cursor.h>
26
 
 
27
 
#include <fcntl.h>
28
 
#include <inttypes.h>
29
 
#include <string>
30
 
#include <sys/stat.h>
31
 
#include <unistd.h>
32
 
#include <zlib.h>
33
 
 
34
 
#include <boost/unordered_map.hpp>
35
 
#include "drizzled/util/string.h"
36
 
 
37
 
#include "azio.h"
38
 
#include "plugin/archive/ha_archive.h"
39
 
 
40
 
 
41
 
 
42
 
#include <cstdio>
43
 
#include <string>
44
 
#include <map>
45
 
 
46
 
#ifndef PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
47
 
#define PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
48
 
 
49
 
/* The file extension */
50
 
#define ARZ ".arz"               // The data file
51
 
#define ARN ".ARN"               // Files used during an optimize call
52
 
 
53
 
/*
54
 
  We just implement one additional file extension.
55
 
*/
56
 
static const char *ha_archive_exts[] = {
57
 
  ARZ,
58
 
  NULL
59
 
};
60
 
 
61
 
 
62
 
class ArchiveEngine : public drizzled::plugin::StorageEngine
63
 
{
64
 
  typedef boost::unordered_map<std::string, ArchiveShare *, drizzled::util::insensitive_hash, drizzled::util::insensitive_equal_to> ArchiveMap;
65
 
  ArchiveMap archive_open_tables;
66
 
 
67
 
  /* Variables for archive share methods */
68
 
  pthread_mutex_t _mutex;
69
 
 
70
 
public:
71
 
  ArchiveEngine() :
72
 
    drizzled::plugin::StorageEngine("ARCHIVE",
73
 
                                    drizzled::HTON_STATS_RECORDS_IS_EXACT |
74
 
                                    drizzled::HTON_HAS_RECORDS),
75
 
    archive_open_tables()
76
 
  {
77
 
    pthread_mutex_init(&_mutex, NULL);
78
 
    table_definition_ext= ARZ;
79
 
  }
80
 
  ~ArchiveEngine()
81
 
  {
82
 
    pthread_mutex_destroy(&_mutex);
83
 
  }
84
 
 
85
 
  pthread_mutex_t &mutex()
86
 
  {
87
 
    return _mutex;
88
 
  }
89
 
 
90
 
  virtual drizzled::Cursor *create(drizzled::TableShare &table)
91
 
  {
92
 
    return new ha_archive(*this, table);
93
 
  }
94
 
 
95
 
  const char **bas_ext() const {
96
 
    return ha_archive_exts;
97
 
  }
98
 
 
99
 
  int doCreateTable(drizzled::Session &session,
100
 
                    drizzled::Table &table_arg,
101
 
                    const drizzled::TableIdentifier &identifier,
102
 
                    drizzled::message::Table& proto);
103
 
 
104
 
  int doGetTableDefinition(drizzled::Session& session,
105
 
                           const drizzled::TableIdentifier &identifier,
106
 
                           drizzled::message::Table &table_message);
107
 
 
108
 
  int doDropTable(drizzled::Session&, const drizzled::TableIdentifier &identifier);
109
 
 
110
 
  ArchiveShare *findOpenTable(const std::string table_name);
111
 
  void addOpenTable(const std::string &table_name, ArchiveShare *);
112
 
  void deleteOpenTable(const std::string &table_name);
113
 
 
114
 
  uint32_t max_supported_keys()          const { return 1; }
115
 
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
116
 
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
117
 
 
118
 
  uint32_t index_flags(enum  drizzled::ha_key_alg) const
119
 
  {
120
 
    return HA_ONLY_WHOLE_INDEX;
121
 
  }
122
 
 
123
 
  bool doDoesTableExist(drizzled::Session&, const drizzled::TableIdentifier &identifier);
124
 
  int doRenameTable(drizzled::Session&, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
125
 
 
126
 
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
127
 
                             const drizzled::SchemaIdentifier &schema_identifier,
128
 
                             drizzled::TableIdentifiers &set_of_identifiers);
129
 
};
130
 
 
131
 
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */