0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AccessGroupSpec.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_AccessGroupSpec_h
28 #define Hypertable_Lib_AccessGroupSpec_h
29 
31 
32 #include <Common/Properties.h>
33 
34 #include <bitset>
35 #include <unordered_map>
36 #include <vector>
37 
38 namespace Hypertable {
39 
42 
51  };
52 
55  public:
56 
58  enum {
71  };
72 
77  void set_replication(int16_t replication);
78 
81  int16_t get_replication() const { return m_replication; }
82 
87  bool is_set_replication() const;
88 
93  void set_blocksize(int32_t blocksize);
94 
97  int32_t get_blocksize() const { return m_blocksize; }
98 
103  bool is_set_blocksize() const;
104 
121  void set_compressor(const std::string &compressor);
122 
125  const std::string &get_compressor() const { return m_compressor; }
126 
131  bool is_set_compressor() const;
132 
153  void set_bloom_filter(const std::string &bloomfilter);
154 
157  const std::string &get_bloom_filter() const { return m_bloomfilter; }
158 
163  bool is_set_bloom_filter() const;
164 
169  void set_in_memory(bool value);
170 
173  bool get_in_memory() const { return m_in_memory; }
174 
179  bool is_set_in_memory() const;
180 
186  void merge(const AccessGroupOptions &other);
187 
208  void parse_xml(const char *base, int len);
209 
230  const std::string render_xml(const std::string &line_prefix) const;
231 
242  const std::string render_hql() const;
243 
289  static void parse_bloom_filter(const std::string &spec, PropertiesPtr &props);
290 
295  bool operator==(const AccessGroupOptions &other) const;
296 
297  private:
298 
300  int16_t m_replication {-1};
301 
303  int32_t m_blocksize {};
304 
306  std::string m_compressor;
307 
309  std::string m_bloomfilter;
310 
312  bool m_in_memory {};
313 
315  std::bitset<MAX> m_isset;
316  };
317 
320  public:
321 
324 
328  AccessGroupSpec(const std::string &name) : m_name(name) { }
329 
333 
337  void set_name(const std::string &name);
338 
341  const std::string &get_name() const { return m_name; }
342 
345  void set_generation(int64_t generation) { m_generation = generation; }
346 
350 
361 
364  int64_t get_generation() const { return m_generation; }
365 
370  void set_option_replication(int16_t replication);
371 
374  int16_t get_option_replication() const;
375 
380  void set_option_blocksize(int32_t blocksize);
381 
384  int32_t get_option_blocksize() const;
385 
392  void set_option_compressor(const std::string &compressor);
393 
396  const std::string get_option_compressor() const;
397 
405  void set_option_bloom_filter(const std::string &bloomfilter);
406 
409  const std::string &get_option_bloom_filter() const;
410 
415  void set_option_in_memory(bool value);
416 
419  bool get_option_in_memory() const;
420 
427  void set_default_max_versions(int32_t max_versions);
428 
431  int32_t get_default_max_versions() const;
432 
438  void set_default_ttl(time_t ttl);
439 
442  time_t get_default_ttl() const;
443 
451  void set_default_time_order_desc(bool value);
452 
455  bool get_default_time_order_desc() const;
456 
465  void set_default_counter(bool value);
466 
469  bool get_default_counter() const;
470 
475  void add_column(ColumnFamilySpec *cf);
476 
484 
490  ColumnFamilySpec *remove_column(const std::string &name);
491 
496  void drop_column(const std::string &name);
497 
501  ColumnFamilySpec *get_column(const std::string &name);
502 
505  void clear_columns() { m_columns.clear(); }
506 
510  m_options.merge(options);
511  }
512 
517  m_defaults.merge(options);
518  }
519 
524  bool operator==(const AccessGroupSpec &other) const;
525 
534  void parse_xml(const char *base, int len);
535 
589  const std::string render_xml(const std::string &line_prefix,
590  bool with_ids=false) const;
591 
603  const std::string render_hql() const;
604 
608 
611  const AccessGroupOptions &options() const { return m_options; }
612 
615  const ColumnFamilyOptions &defaults() const { return m_defaults; }
616 
617  private:
618 
620  std::string m_name;
621 
623  int64_t m_generation {};
624 
627 
630 
633  };
634 
636  typedef std::vector<AccessGroupSpec *> AccessGroupSpecs;
637 
639 
640 } // namespace Hypertable
641 
642 #endif // Hypertable_Lib_AccessGroup_h
std::string m_bloomfilter
Bloom filter specification.
int32_t m_blocksize
Block size.
void set_default_max_versions(int32_t max_versions)
Sets default max versions column family option.
void set_name(const std::string &name)
Sets access group name.
int32_t get_blocksize() const
Gets blocksize option.
bool is_set_bloom_filter() const
Checks if bloom filter option is set.
void set_default_ttl(time_t ttl)
Sets default ttl column family option.
void set_bloom_filter(const std::string &bloomfilter)
Sets bloom filter option.
bool get_default_time_order_desc() const
Gets default time order desc column family option.
std::vector< AccessGroupSpec * > AccessGroupSpecs
Vector of AccessGroupSpec pointers.
const ColumnFamilyOptions & defaults() const
Returns reference to column family defaults structure.
void set_default_counter(bool value)
Sets default counter column family option.
void parse_xml(const char *base, int len)
Parses XML options specification.
void set_option_bloom_filter(const std::string &bloomfilter)
Sets bloom filter option.
ColumnFamilySpec * get_column(const std::string &name)
Gets column family specification.
void set_replication(int16_t replication)
Sets replication option.
Program options handling.
void set_option_compressor(const std::string &compressor)
Sets compressor option.
Column family specification.
static void parse_bloom_filter(const std::string &spec, PropertiesPtr &props)
Parsers a bloom filter specification and sets properties.
bool is_set_in_memory() const
Checks if in memory option is set.
int16_t m_replication
Replication.
ColumnFamilyOptions m_defaults
Column family defaults.
void clear_generation()
Clears generation.
Specification for column family options.
bool clear_generation_if_changed(AccessGroupSpec &original)
Clears generation if different than original.
void set_generation(int64_t generation)
Sets generation.
bool get_default_counter() const
Gets default counter column family option.
AccessGroupOptions m_options
Options.
Specification for access group options.
int16_t get_option_replication() const
Gets replication option.
bool is_set_replication() const
Checks if replication option is set.
const std::string render_xml(const std::string &line_prefix, bool with_ids=false) const
Renders access group specification in XML format.
AccessGroupSpec(const std::string &name)
Constructor with name initializer.
void clear_columns()
Clears columns.
const AccessGroupOptions & options() const
Returns reference to options structure.
bool operator==(const AccessGroupSpec &other) const
Equality operator.
void parse_xml(const char *base, int len)
Parses XML access group specification.
int64_t m_generation
Generation.
std::bitset< MAX > m_isset
Bit mask describing which options are set.
ColumnFamilySpec * remove_column(const std::string &name)
Removes column family specification.
int64_t get_generation() const
Gets generation.
bool get_option_in_memory() const
Gets in memory option.
const std::string & get_name() const
Gets access group name.
const std::string render_xml(const std::string &line_prefix) const
Renders options in XML format.
bool get_in_memory() const
Gets in memory option.
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
void merge_options(const AccessGroupOptions &options)
Merges options with those from another AccessGroupOptions object.
BloomFilterMode
Enumeration for bloom filter modes.
void drop_column(const std::string &name)
Drops column family.
bool is_set_compressor() const
Checks if compressor option is set.
void merge(const ColumnFamilyOptions &other)
Merges options from another ColumnFamilyOptions object.
const std::string render_hql() const
Renders options in HQL format.
Access group specification.
int32_t get_option_blocksize() const
Gets blocksize option.
int16_t get_replication() const
Gets replication option.
Hypertable definitions
void merge_defaults(const ColumnFamilyOptions &options)
Merges column family defaults with those from another AccessGroupOptions object.
ColumnFamilySpecs m_columns
Member column family specifications.
int32_t get_default_max_versions() const
Gets default max versions column family option.
bool operator==(const AccessGroupOptions &other) const
Equality operator.
time_t get_default_ttl() const
Gets default ttl column family option.
ColumnFamilySpecs & columns()
Returns reference to column specifications.
void set_option_in_memory(bool value)
Sets in memory option.
void set_blocksize(int32_t blocksize)
Sets blocksize option.
const std::string & get_option_bloom_filter() const
Gets bloom filter option.
AccessGroupSpec()
Default constructor.
void set_in_memory(bool value)
Sets in memory option.
bool is_set_blocksize() const
Checks if blocksize option is set.
std::string m_compressor
Compressor specification.
std::vector< ColumnFamilySpec * > ColumnFamilySpecs
Vector of ColumnFamilySpec pointers.
void set_compressor(const std::string &compressor)
Sets compressor option.
void set_default_time_order_desc(bool value)
Sets default time order desc column family option.
ColumnFamilySpec * replace_column(ColumnFamilySpec *new_cf)
Replaces column family specification.
void set_option_replication(int16_t replication)
Sets replication option.
void add_column(ColumnFamilySpec *cf)
Adds column family specification.
const std::string get_option_compressor() const
Gets compressor option.
const std::string & get_compressor() const
Gets compressor option.
Declarations for ColumnFamilySpec.
void merge(const AccessGroupOptions &other)
Merges options from another AccessGroupOptions object.
const std::string & get_bloom_filter() const
Gets bloom filter option.
void set_option_blocksize(int32_t blocksize)
Sets blocksize option.
const std::string render_hql() const
Renders access group specification in HQL format.