~drizzle-trunk/drizzle/development

1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
15
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
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
1685.2.8 by Brian Aker
Fix possible issue with case.
33
#include <boost/unordered_map.hpp>
34
#include "drizzled/util/string.h"
35
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
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
{
1685.2.8 by Brian Aker
Fix possible issue with case.
63
  typedef boost::unordered_map<std::string, ArchiveShare *, drizzled::util::insensitive_hash, drizzled::util::insensitive_equal_to> ArchiveMap;
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
64
  ArchiveMap archive_open_tables;
65
1685.2.7 by Brian Aker
Encapsulate global lock.
66
  /* Variables for archive share methods */
67
  pthread_mutex_t _mutex;
68
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
69
public:
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
70
  ArchiveEngine() :
71
    drizzled::plugin::StorageEngine("ARCHIVE",
72
                                    drizzled::HTON_STATS_RECORDS_IS_EXACT |
1414 by Brian Aker
Remove dead type.
73
                                    drizzled::HTON_HAS_RECORDS),
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
74
    archive_open_tables()
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
75
  {
1685.2.7 by Brian Aker
Encapsulate global lock.
76
    pthread_mutex_init(&_mutex, NULL);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
77
    table_definition_ext= ARZ;
78
  }
1685.2.7 by Brian Aker
Encapsulate global lock.
79
  ~ArchiveEngine()
80
  {
81
    pthread_mutex_destroy(&_mutex);
82
  }
83
84
  pthread_mutex_t &mutex()
85
  {
86
    return _mutex;
87
  }
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
88
1869.1.4 by Brian Aker
TableShare is no longer in the house (i.e. we no longer directly have a copy
89
  virtual drizzled::Cursor *create(drizzled::Table &table)
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
90
  {
1680.6.1 by Brian Aker
Remove call for using special new for a cursor.
91
    return new ha_archive(*this, table);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
92
  }
93
94
  const char **bas_ext() const {
95
    return ha_archive_exts;
96
  }
97
1413 by Brian Aker
doCreateTable() was still taking a pointer instead of a session reference.
98
  int doCreateTable(drizzled::Session &session,
99
                    drizzled::Table &table_arg,
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
100
                    const drizzled::identifier::Table &identifier,
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
101
                    drizzled::message::Table& proto);
102
103
  int doGetTableDefinition(drizzled::Session& session,
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
104
                           const drizzled::identifier::Table &identifier,
1354.1.1 by Brian Aker
Modify ptr to reference.
105
                           drizzled::message::Table &table_message);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
106
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
107
  int doDropTable(drizzled::Session&, const drizzled::identifier::Table &identifier);
1358.1.2 by Brian Aker
Long pass through the system to use more of TableIdentifiers.
108
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
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
  }
1358.1.1 by Brian Aker
Fixes regression in performance from Exists patch.
121
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
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);
1429.1.3 by Brian Aker
Merge in work for fetching a list of table identifiers.
124
125
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
2087.4.1 by Brian Aker
Merge in schema identifier.
126
                             const drizzled::identifier::Schema &schema_identifier,
2087.4.2 by Brian Aker
Modify TableIdentifier to fit with the rest of the identifiers.
127
                             drizzled::identifier::Table::vector &set_of_identifiers);
1286.1.4 by Brian Aker
Style change in Archive. Split a few files out.
128
};
129
130
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */