~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/archive/archive_engine.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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
                                     drizzled::HTON_HAS_DATA_DICTIONARY),
 
71
     archive_open_tables()
 
72
  {
 
73
    table_definition_ext= ARZ;
 
74
  }
 
75
 
 
76
  virtual drizzled::Cursor *create(drizzled::TableShare &table,
 
77
                                   drizzled::memory::Root *mem_root)
 
78
  {
 
79
    return new (mem_root) ha_archive(*this, table);
 
80
  }
 
81
 
 
82
  const char **bas_ext() const {
 
83
    return ha_archive_exts;
 
84
  }
 
85
 
 
86
  int doCreateTable(drizzled::Session *session, const char *table_name,
 
87
                    drizzled::Table& table_arg,
 
88
                    drizzled::message::Table& proto);
 
89
 
 
90
  int doGetTableDefinition(drizzled::Session& session,
 
91
                           const char* path,
 
92
                           const char *db,
 
93
                           const char *table_name,
 
94
                           const bool is_tmp,
 
95
                           drizzled::message::Table *table_proto);
 
96
 
 
97
  void doGetTableNames(drizzled::CachedDirectory &directory, std::string& , std::set<std::string>& set_of_names);
 
98
 
 
99
  int doDropTable(drizzled::Session&, const std::string &table_path);
 
100
  ArchiveShare *findOpenTable(const std::string table_name);
 
101
  void addOpenTable(const std::string &table_name, ArchiveShare *);
 
102
  void deleteOpenTable(const std::string &table_name);
 
103
 
 
104
  uint32_t max_supported_keys()          const { return 1; }
 
105
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
 
106
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
 
107
 
 
108
  uint32_t index_flags(enum  drizzled::ha_key_alg) const
 
109
  {
 
110
    return HA_ONLY_WHOLE_INDEX;
 
111
  }
 
112
};
 
113
 
 
114
#endif /* PLUGIN_ARCHIVE_ARCHIVE_ENGINE_H */