~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/archive_engine.h

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

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 "azio.h"
 
35
#include "plugin/archive/ha_archive.h"
 
36
 
 
37
 
 
38
 
 
39
#include <cstdio>
 
40
#include <string>
 
41
#include <map>
 
42
 
 
43
#ifndef PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
 
44
#define PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H
 
45
 
 
46
/* The file extension */
 
47
#define ARZ ".arz"               // The data file
 
48
#define ARN ".ARN"               // Files used during an optimize call
 
49
 
 
50
/*
 
51
  We just implement one additional file extension.
 
52
*/
 
53
static const char *ha_archive_exts[] = {
 
54
  ARZ,
 
55
  NULL
 
56
};
 
57
 
 
58
 
 
59
class ArchiveEngine : public drizzled::plugin::StorageEngine
 
60
{
 
61
  typedef std::map<std::string, ArchiveShare*> ArchiveMap;
 
62
  ArchiveMap archive_open_tables;
 
63
 
 
64
public:
 
65
  ArchiveEngine() :
 
66
    drizzled::plugin::StorageEngine("ARCHIVE",
 
67
                                    drizzled::HTON_FILE_BASED |
 
68
                                    drizzled::HTON_STATS_RECORDS_IS_EXACT |
 
69
                                    drizzled::HTON_HAS_RECORDS),
 
70
    archive_open_tables()
 
71
  {
 
72
    table_definition_ext= ARZ;
 
73
  }
 
74
 
 
75
  virtual drizzled::Cursor *create(drizzled::TableShare &table,
 
76
                                   drizzled::memory::Root *mem_root)
 
77
  {
 
78
    return new (mem_root) ha_archive(*this, table);
 
79
  }
 
80
 
 
81
  const char **bas_ext() const {
 
82
    return ha_archive_exts;
 
83
  }
 
84
 
 
85
  int doCreateTable(drizzled::Session &session,
 
86
                    drizzled::Table &table_arg,
 
87
                    drizzled::TableIdentifier &identifier,
 
88
                    drizzled::message::Table& proto);
 
89
 
 
90
  int doGetTableDefinition(drizzled::Session& session,
 
91
                           drizzled::TableIdentifier &identifier,
 
92
                           drizzled::message::Table &table_message);
 
93
 
 
94
  void doGetTableNames(drizzled::CachedDirectory &directory, drizzled::SchemaIdentifier&, std::set<std::string>& set_of_names);
 
95
 
 
96
  int doDropTable(drizzled::Session&, drizzled::TableIdentifier &identifier);
 
97
 
 
98
  ArchiveShare *findOpenTable(const std::string table_name);
 
99
  void addOpenTable(const std::string &table_name, ArchiveShare *);
 
100
  void deleteOpenTable(const std::string &table_name);
 
101
 
 
102
  uint32_t max_supported_keys()          const { return 1; }
 
103
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
 
104
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
 
105
 
 
106
  uint32_t index_flags(enum  drizzled::ha_key_alg) const
 
107
  {
 
108
    return HA_ONLY_WHOLE_INDEX;
 
109
  }
 
110
 
 
111
  bool doDoesTableExist(drizzled::Session&, drizzled::TableIdentifier &identifier);
 
112
  int doRenameTable(drizzled::Session&, drizzled::TableIdentifier &from, drizzled::TableIdentifier &to);
 
113
 
 
114
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
 
115
                             drizzled::SchemaIdentifier &schema_identifier,
 
116
                             drizzled::TableIdentifiers &set_of_identifiers);
 
117
};
 
118
 
 
119
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */