0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MaintenanceFlag.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 
29 #ifndef HYPERTABLE_MAINTENANCEFLAG_H
30 #define HYPERTABLE_MAINTENANCEFLAG_H
31 
32 #include <unordered_map>
33 
34 namespace Hypertable {
35 
44  namespace MaintenanceFlag {
45 
47  enum {
48  SPLIT = 0x00000100,
49  COMPACT = 0x00000200,
50  COMPACT_MINOR = 0x00000201,
51  COMPACT_MAJOR = 0x00000202,
52  COMPACT_MERGING = 0x00000204,
53  COMPACT_GC = 0x00000208,
54  COMPACT_MOVE = 0x00000210,
55  MEMORY_PURGE = 0x00000400,
57  MEMORY_PURGE_CELLSTORE = 0x00000402,
58  RELINQUISH = 0x00000800,
59  RECOMPUTE_MERGE_RUN = 0x00010000
61  };
62 
68  inline bool relinquish(int flags) {
69  return (flags & RELINQUISH) == RELINQUISH;
70  }
71 
77  inline bool split(int flags) {
78  return (flags & SPLIT) == SPLIT;
79  }
80 
86  inline bool compaction(int flags) {
87  return (flags & COMPACT) == COMPACT;
88  }
89 
95  inline bool minor_compaction(int flags) {
96  return (flags & COMPACT_MINOR) == COMPACT_MINOR;
97  }
98 
104  inline bool merging_compaction(int flags) {
105  return (flags & COMPACT_MERGING) == COMPACT_MERGING;
106  }
107 
113  inline bool major_compaction(int flags) {
114  return (flags & COMPACT_MAJOR) == COMPACT_MAJOR;
115  }
116 
122  inline bool gc_compaction(int flags) {
123  return (flags & COMPACT_GC) == COMPACT_GC;
124  }
125 
131  inline bool move_compaction(int flags) {
132  return (flags & COMPACT_MOVE) == COMPACT_MOVE;
133  }
134 
140  inline bool purge_shadow_cache(int flags) {
142  }
143 
149  inline bool purge_cellstore(int flags) {
151  }
152 
158  inline bool recompute_merge_run(int flags) {
159  return (flags & RECOMPUTE_MERGE_RUN) == RECOMPUTE_MERGE_RUN;
160  }
161 
163  class Hash {
164  public:
165  size_t operator () (const void *obj) const {
166  return (size_t)obj;
167  }
168  };
169 
171  struct Equal {
172  bool operator()(const void *obj1, const void *obj2) const {
173  return obj1 == obj2;
174  }
175  };
176 
177 
187  class Map : public std::unordered_map<const void *, int, Hash, Equal> {
188  public:
193  int flags(const void *key) {
194  iterator iter = this->find(key);
195  if (iter != this->end())
196  return (*iter).second;
197  return 0;
198  }
204  bool compaction(const void *key) {
205  iterator iter = this->find(key);
206  if (iter != this->end())
207  return ((*iter).second & COMPACT) == COMPACT;
208  return false;
209  }
215  bool minor_compaction(const void *key) {
216  iterator iter = this->find(key);
217  if (iter != this->end())
218  return ((*iter).second & COMPACT_MINOR) == COMPACT_MINOR;
219  return false;
220  }
226  bool memory_purge(const void *key) {
227  iterator iter = this->find(key);
228  if (iter != this->end())
229  return ((*iter).second & MEMORY_PURGE) == MEMORY_PURGE;
230  return false;
231  }
232  };
233  }
234 
236 }
237 
238 #endif // HYPERTABLE_MAINTENANCEFLAG_H
Equality function for pointers.
Recompute CellStore merge run to test if merging compaction needed.
bool purge_cellstore(int flags)
Tests the PURGE_CELLSTORE bit of flags
size_t operator()(const void *obj) const
bool purge_shadow_cache(int flags)
Tests the PURGE_SHADOW_CACHE bit of flags
Maps object pointers to bit fields.
bool recompute_merge_run(int flags)
Tests the RECOMPUTE_MERGE_RUN bit of flags
bool compaction(const void *key)
Test if compaction needs to be perfomed on object.
bool minor_compaction(const void *key)
Test if minor compaction needs to be perfomed on object.
int flags(const void *key)
Returns bit field for a give pointer.
bool move_compaction(int flags)
Tests the COMPACT_MOVE bit of flags
Hypertable definitions
bool compaction(int flags)
Tests the COMPACT bit of flags
bool split(int flags)
Tests the SPLIT bit of flags
bool operator()(const void *obj1, const void *obj2) const
bool relinquish(int flags)
Tests the RELINQUISH bit of flags
bool major_compaction(int flags)
Tests the COMPACT_MAJOR bit of flags
Hash function class for pointers.
bool gc_compaction(int flags)
Tests the COMPACT_GC bit of flags
bool merging_compaction(int flags)
Tests the COMPACT_MERGING bit of flags
bool minor_compaction(int flags)
Tests the COMPACT_MINOR bit of flags
bool memory_purge(const void *key)
Test if memory purge needs to be perfomed on object.