0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
IndexUpdater.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Hypertable_RangeServer_IndexUpdater_h
28 #define Hypertable_RangeServer_IndexUpdater_h
29 
31 #include <Hypertable/Lib/Schema.h>
32 #include <Hypertable/Lib/Table.h>
34 
35 #include <Common/String.h>
36 
37 #include <map>
38 #include <memory>
39 #include <mutex>
40 
41 namespace Hypertable {
42 
45 
47  class IndexUpdater {
48  friend class IndexUpdaterFactory;
49 
50  public:
51 
54  IndexUpdater(SchemaPtr &primary_schema, TablePtr index_table,
55  TablePtr qualifier_index_table);
56 
59  if (m_index_mutator)
60  delete m_index_mutator;
63  delete m_cb;
64  }
65 
67  void purge(const Key &key, const ByteString &value);
68 
70  void add(const Key &key, const ByteString &value);
71 
72  private:
73 
76 
79 
82  bool m_index_map[256];
84  };
85 
87  typedef std::shared_ptr<IndexUpdater> IndexUpdaterPtr;
88 
91  public:
93  static IndexUpdaterPtr create(const String &table_id, SchemaPtr &schema,
94  bool has_index, bool has_qualifier_index);
95 
97  static void close();
98 
100  static void clear_cache();
101 
102  private:
103  // Loads a table.
104  static TablePtr load_table(const String &table_name);
105 
106  typedef std::map<String, TablePtr> TableMap;
107 
110  static TableMap ms_qualifier_index_cache;
111  static TableMap ms_index_cache;
112  };
113 
115 
116 }
117 
118 #endif // Hypertable_RangeServer_IndexUpdater_h
static std::mutex mutex
Definition: Logger.cc:43
void purge(const Key &key, const ByteString &value)
Purges a key from index tables.
Definition: IndexUpdater.cc:77
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
std::shared_ptr< IndexUpdater > IndexUpdaterPtr
Smart pointer to IndexUpdater.
Definition: IndexUpdater.h:87
static void clear_cache()
Clears both value and qualifier caches.
static TableMap ms_qualifier_index_cache
Definition: IndexUpdater.h:110
static void close()
Cleanup function; called before leaving main()
Declarations for Schema.
std::map< String, TablePtr > TableMap
Definition: IndexUpdater.h:106
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
Provides the ability to mutate a table in the form of adding and deleting rows and cells...
TableMutatorAsync * m_qualifier_index_mutator
Mutator for qualifier index table.
Definition: IndexUpdater.h:78
static TablePtr load_table(const String &table_name)
Helper class for updating index tables.
Definition: IndexUpdater.h:47
TableMutatorAsync * m_index_mutator
Mutator for value index table.
Definition: IndexUpdater.h:75
static NameIdMapperPtr ms_namemap
Definition: IndexUpdater.h:109
Hypertable definitions
bool m_qualifier_index_map[256]
Definition: IndexUpdater.h:83
Provides access to internal components of opaque key.
Definition: Key.h:40
~IndexUpdater()
Destructor.
Definition: IndexUpdater.h:58
Factory class for creating IndexUpdater objects.
Definition: IndexUpdater.h:90
A String class based on std::string.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
static IndexUpdaterPtr create(const String &table_id, SchemaPtr &schema, bool has_index, bool has_qualifier_index)
Factory function.
ResultCallback * m_cb
Async mutator callback object.
Definition: IndexUpdater.h:81
IndexUpdater(SchemaPtr &primary_schema, TablePtr index_table, TablePtr qualifier_index_table)
Constructor.
Definition: IndexUpdater.cc:56
Represents an open table.
std::shared_ptr< NameIdMapper > NameIdMapperPtr
Smart pointer to NameIdMapper.
Definition: NameIdMapper.h:121
void add(const Key &key, const ByteString &value)
Adds a key to index tables.
std::shared_ptr< Table > TablePtr
Definition: Table.h:53