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