0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PhantomRangeMap.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 
22 #ifndef Hypertable_RangeServer_PhantomRangeMap_h
23 #define Hypertable_RangeServer_PhantomRangeMap_h
24 
25 #include "TableInfoMap.h"
26 #include "PhantomRange.h"
27 
29 
31 
32 #include <boost/thread/condition.hpp>
33 
34 #include <map>
35 #include <memory>
36 #include <mutex>
37 #include <set>
38 #include <string>
39 
40 namespace Hypertable {
41  using namespace std;
46  public:
47  PhantomRangeMap(int plan_generation);
48  virtual ~PhantomRangeMap() { }
49 
50  void lock() { m_mutex.lock(); }
51  void unlock() { m_mutex.unlock(); }
52 
53  void reset(int plan_generation);
54 
63  void insert(const QualifiedRangeSpec &range, const RangeState &state,
64  SchemaPtr schema, const vector<int32_t> &fragments);
65 
72  void get(const QualifiedRangeSpec &range_spec, PhantomRangePtr &phantom_range);
73 
74  TableInfoMapPtr get_tableinfo_map() { return m_tableinfo_map; }
75 
76  int get_plan_generation() { return m_plan_generation; }
77 
78  bool initial() const;
79 
80  void set_loaded();
81  bool loaded() const;
82 
83  bool replayed() const;
84 
85  void set_prepared();
86  bool prepared() const;
87 
88  void set_committed();
89  bool committed() const;
90 
91  private:
92  typedef std::map<QualifiedRangeSpec, PhantomRangePtr> Map;
93 
97  Map m_map;
99  int m_state;
100  };
101 
102  typedef std::shared_ptr<PhantomRangeMap> PhantomRangeMapPtr;
103 
104 }
105 
106 #endif // Hypertable_RangeServer_PhantomRangeMap_h
static std::mutex mutex
Definition: Logger.cc:43
Provides a mapping from table name to TableInfo object.
std::shared_ptr< PhantomRangeMap > PhantomRangeMapPtr
TableInfoMapPtr get_tableinfo_map()
PageArena memory allocator for STL classes.
STL namespace.
Declarations for PhantomRange.
Declarations for TableInfoMap.
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
std::shared_ptr< TableInfoMap > TableInfoMapPtr
Shared smart pointer to TableInfoMap.
Definition: TableInfoMap.h:223
Hypertable definitions
std::map< QualifiedRangeSpec, PhantomRangePtr > Map
TableInfoMapPtr m_tableinfo_map
std::shared_ptr< PhantomRange > PhantomRangePtr
Shared smart pointer to PhantomRange.
Definition: PhantomRange.h:120
Qualified (with table identifier) range specification.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Range state.
Definition: RangeState.h:48