0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableInfoMap.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; version 3 of the
9  * 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_TableInfoMap_h
28 #define Hypertable_RangeServer_TableInfoMap_h
29 
32 
33 #include <Common/StringExt.h>
34 
35 #include <map>
36 #include <memory>
37 #include <mutex>
38 #include <string>
39 
40 namespace Hypertable {
41 
44 
67  class TableInfoMap {
68  public:
69 
72 
79  TableInfoMap(HyperspaceTableCachePtr schema_cache) : m_schema_cache(schema_cache) { }
80 
82  virtual ~TableInfoMap();
83 
90  bool lookup(const String &table_id, TableInfoPtr &info);
91 
97  void get(const String &table_id, TableInfoPtr &info);
98 
121  void promote_staged_range(const TableIdentifier &table, RangePtr &range, const char *transfer_log);
122 
129  bool remove(const String &table_id, TableInfoPtr &info);
130 
134  void get_all(std::vector<TableInfoPtr> &tv);
135 
160  void get_ranges(Ranges &ranges, StringSet *remove_ok_logs=0);
161 
163  void clear();
164 
168  bool empty();
169 
177  void merge(TableInfoMap *other);
178 
192  void merge(TableInfoMap *other, vector<MetaLog::EntityPtr> &entities,
193  StringSet &transfer_logs);
194 
195  private:
196 
207  void merge_unlocked(TableInfoMap *other);
208 
210  typedef std::map<String, TableInfoPtr> InfoMap;
211 
214 
217 
219  InfoMap m_map;
220  };
221 
223  typedef std::shared_ptr<TableInfoMap> TableInfoMapPtr;
224 
226 }
227 
228 #endif // Hypertable_RangeServer_TableInfoMap_h
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
static std::mutex mutex
Definition: Logger.cc:43
InfoMap m_map
table_id-to-TableInfoPtr map
Definition: TableInfoMap.h:219
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
HyperspaceTableCachePtr m_schema_cache
Hyperspace table cache
Definition: TableInfoMap.h:216
std::mutex m_mutex
Mutex for serializing access to members
Definition: TableInfoMap.h:213
void promote_staged_range(const TableIdentifier &table, RangePtr &range, const char *transfer_log)
Adds a staged range.
void merge_unlocked(TableInfoMap *other)
Merges in another map (without locking mutex).
void get_ranges(Ranges &ranges, StringSet *remove_ok_logs=0)
Gets set of live RangeData objects and corresponding transfer logs that can be safely removed...
std::map< String, TableInfoPtr > InfoMap
table_id-to-TableInfoPtr map type
Definition: TableInfoMap.h:210
void merge(TableInfoMap *other)
Merges in another map.
virtual ~TableInfoMap()
Destructor.
Definition: TableInfoMap.cc:42
Declarations for HyperspaceTableCache.
std::shared_ptr< TableInfoMap > TableInfoMapPtr
Shared smart pointer to TableInfoMap.
Definition: TableInfoMap.h:223
Hypertable definitions
Declarations for TableInfo.
bool empty()
Determines if map is empty.
TableInfoMap(HyperspaceTableCachePtr schema_cache)
Constructor with HyperspaceTableCache.
Definition: TableInfoMap.h:79
std::shared_ptr< TableInfo > TableInfoPtr
Smart pointer to TableInfo.
Definition: TableInfo.h:312
std::shared_ptr< Range > RangePtr
Smart pointer to Range.
Definition: Range.h:404
bool lookup(const String &table_id, TableInfoPtr &info)
Returns the TableInfo object for a given table.
Definition: TableInfoMap.cc:47
std::shared_ptr< HyperspaceTableCache > HyperspaceTableCachePtr
Smart pointer to HyperspaceTableCache.
void clear()
Clears the map.
void get_all(std::vector< TableInfoPtr > &tv)
Gets all TableInfo objects in map.
TableInfoMap()
Constructor.
Definition: TableInfoMap.h:71
String extensions and helpers: sets, maps, append operators etc.
Manages live range map and set of log names that can be safely removed.
Definition: TableInfoMap.h:67
Holds vector of RangeData objects and memory arena.
Definition: TableInfo.h:72