0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ColumnFamilySpec.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_Lib_ColumnFamilySpec_h
28 #define Hypertable_Lib_ColumnFamilySpec_h
29 
30 #include <bitset>
31 #include <unordered_map>
32 #include <vector>
33 
34 namespace Hypertable {
35 
38 
41  public:
42 
44  enum {
48  TTL,
55  };
56 
67  bool set_max_versions(int32_t max_versions);
68 
71  int32_t get_max_versions() const { return m_max_versions; }
72 
77  bool is_set_max_versions() const;
78 
86  bool set_ttl(time_t ttl);
87 
90  time_t get_ttl() const { return m_ttl; }
91 
95  bool is_set_ttl() const;
96 
107  bool set_time_order_desc(bool value);
108 
111  bool get_time_order_desc() const { return m_time_order_desc; }
112 
117  bool is_set_time_order_desc() const;
118 
129  bool set_counter(bool value);
130 
133  bool get_counter() const { return m_counter; }
134 
139  bool is_set_counter() const;
140 
146  void merge(const ColumnFamilyOptions &other);
147 
166  void parse_xml(const char *base, int len);
167 
186  const std::string render_xml(const std::string &line_prefix) const;
187 
198  const std::string render_hql() const;
199 
204  bool operator==(const ColumnFamilyOptions &other) const;
205 
206  private:
207 
209  int32_t m_max_versions {};
210 
212  time_t m_ttl {};
213 
216 
218  bool m_counter {};
219 
221  std::bitset<MAX> m_isset;
222  };
223 
226  public:
227 
230 
234  ColumnFamilySpec(const std::string &name) : m_name(name) { }
235 
239  void set_name(const std::string &name);
240 
243  const std::string &get_name() const { return m_name; }
244 
248  void set_access_group(const std::string &ag);
249 
252  const std::string &get_access_group() const { return m_ag; }
253 
256  void set_generation(int64_t generation);
257 
260  int64_t get_generation() const { return m_generation; }
261 
264  void set_id(int32_t id);
265 
268  int32_t get_id() const { return m_id; }
269 
274  void set_value_index(bool value);
275 
278  bool get_value_index() const { return m_value_index; }
279 
284  void set_qualifier_index(bool value);
285 
288  bool get_qualifier_index() const { return m_qualifier_index; }
289 
294  void set_deleted(bool value);
295 
298  bool get_deleted() const { return m_deleted; }
299 
306  void set_option_max_versions(int32_t max_versions);
307 
310  int32_t get_option_max_versions() const {
311  return m_options.get_max_versions();
312  }
313 
318  void set_option_ttl(time_t ttl);
319 
322  time_t get_option_ttl() const { return m_options.get_ttl(); }
323 
330  void set_option_time_order_desc(bool value);
331 
336  }
337 
345  void set_option_counter(bool value);
346 
349  bool get_option_counter() const { return m_options.get_counter(); }
350 
354  void merge_options(const ColumnFamilyOptions &other);
355 
382  const std::string render_xml(const std::string &line_prefix,
383  bool with_ids=false) const;
384 
389  bool operator==(const ColumnFamilySpec &other) const;
390 
397  void parse_xml(const char *base, int len);
398 
408  const std::string render_hql() const;
409 
412  const ColumnFamilyOptions &options() const { return m_options; }
413 
414  private:
415 
417  std::string m_name;
418 
420  std::string m_ag;
421 
423  int64_t m_generation {};
424 
426  int32_t m_id {};
427 
430 
432  bool m_value_index {};
433 
436 
438  bool m_deleted {};
439  };
440 
442  typedef std::vector<ColumnFamilySpec *> ColumnFamilySpecs;
443 
445 
446 } // namespace Hypertable
447 
448 #endif // Hypertable_Lib_ColumnFamily_h
bool get_counter() const
Gets the counter option.
void set_id(int32_t id)
Sets column ID.
bool is_set_max_versions() const
Checks if max versions option is set.
const ColumnFamilyOptions & options() const
Returns reference to options structure.
bool get_time_order_desc() const
Gets time order desc option.
bool is_set_ttl() const
Checks if ttl option is set.
const std::string render_xml(const std::string &line_prefix, bool with_ids=false) const
Renders spec in XML format.
void parse_xml(const char *base, int len)
Parses XML options document.
std::string m_ag
Access group name.
ColumnFamilyOptions m_options
Options.
void set_option_max_versions(int32_t max_versions)
Sets max versions option.
void set_generation(int64_t generation)
Sets generation.
bool set_max_versions(int32_t max_versions)
Sets max versions option.
bool get_option_counter() const
Gets the counter option.
ColumnFamilySpec()
Default constructor.
bool m_value_index
Value index flag.
void set_deleted(bool value)
Sets deleted flag.
bool get_option_time_order_desc() const
Gets time order desc option.
time_t get_option_ttl() const
Gets ttl option.
const std::string render_hql() const
Renders options in HQL format.
bool get_value_index() const
Gets value index flag.
Column family specification.
int32_t m_max_versions
Max version.
void set_qualifier_index(bool value)
Sets qualifier index flag.
void set_name(const std::string &name)
Sets column family name.
const std::string render_hql() const
Renders spec in HQL format.
bool set_ttl(time_t ttl)
Sets ttl option.
Specification for column family options.
void set_option_time_order_desc(bool value)
Sets time order desc option.
bool m_qualifier_index
Qualifier index flag
bool is_set_counter() const
Checks if counter option is set.
void set_value_index(bool value)
Sets value index flag.
bool operator==(const ColumnFamilySpec &other) const
Equality operator.
void merge_options(const ColumnFamilyOptions &other)
Merges options from another ColumnFamilyOptions object.
bool get_qualifier_index() const
Gets qualifier index flag.
void parse_xml(const char *base, int len)
Parses XML options document.
const std::string & get_access_group() const
Gets access group name.
bool set_time_order_desc(bool value)
Sets time order desc option.
int32_t get_id() const
Gets column ID.
std::string m_name
Column family name
int32_t get_max_versions() const
Gets max versions option.
bool set_counter(bool value)
Sets counter option.
void set_option_counter(bool value)
Sets counter option.
bool is_set_time_order_desc() const
Checks if time_order_desc option is set.
void merge(const ColumnFamilyOptions &other)
Merges options from another ColumnFamilyOptions object.
time_t get_ttl() const
Gets ttl option.
void set_option_ttl(time_t ttl)
Sets ttl option.
Hypertable definitions
const std::string & get_name() const
Gets column family name.
int32_t get_option_max_versions() const
Gets max versions option.
std::bitset< MAX > m_isset
Bit mask describing which options are set.
void set_access_group(const std::string &ag)
Sets access group.
bool get_deleted() const
Gets deleted flag.
ColumnFamilySpec(const std::string &name)
Constructor with column family name initializer.
const std::string render_xml(const std::string &line_prefix) const
Renders options in XML format.
int64_t get_generation() const
Gets generation.
int64_t m_generation
Generation.
std::vector< ColumnFamilySpec * > ColumnFamilySpecs
Vector of ColumnFamilySpec pointers.
bool operator==(const ColumnFamilyOptions &other) const
Equality operator.
bool m_time_order_desc
Time order "desc" flag.