Specification for access group options. More...
#include <AccessGroupSpec.h>
Public Types | |
enum | { REPLICATION, BLOCKSIZE, COMPRESSOR, BLOOMFILTER, IN_MEMORY, MAX } |
Enumeration for isset bits. More... | |
Public Member Functions | |
void | set_replication (int16_t replication) |
Sets replication option. More... | |
int16_t | get_replication () const |
Gets replication option. More... | |
bool | is_set_replication () const |
Checks if replication option is set. More... | |
void | set_blocksize (int32_t blocksize) |
Sets blocksize option. More... | |
int32_t | get_blocksize () const |
Gets blocksize option. More... | |
bool | is_set_blocksize () const |
Checks if blocksize option is set. More... | |
void | set_compressor (const std::string &compressor) |
Sets compressor option. More... | |
const std::string & | get_compressor () const |
Gets compressor option. More... | |
bool | is_set_compressor () const |
Checks if compressor option is set. More... | |
void | set_bloom_filter (const std::string &bloomfilter) |
Sets bloom filter option. More... | |
const std::string & | get_bloom_filter () const |
Gets bloom filter option. More... | |
bool | is_set_bloom_filter () const |
Checks if bloom filter option is set. More... | |
void | set_in_memory (bool value) |
Sets in memory option. More... | |
bool | get_in_memory () const |
Gets in memory option. More... | |
bool | is_set_in_memory () const |
Checks if in memory option is set. More... | |
void | merge (const AccessGroupOptions &other) |
Merges options from another AccessGroupOptions object. More... | |
void | parse_xml (const char *base, int len) |
Parses XML options specification. More... | |
const std::string | render_xml (const std::string &line_prefix) const |
Renders options in XML format. More... | |
const std::string | render_hql () const |
Renders options in HQL format. More... | |
bool | operator== (const AccessGroupOptions &other) const |
Equality operator. More... | |
Static Public Member Functions | |
static void | parse_bloom_filter (const std::string &spec, PropertiesPtr &props) |
Parsers a bloom filter specification and sets properties. More... | |
Private Attributes | |
int16_t | m_replication {-1} |
Replication. More... | |
int32_t | m_blocksize {} |
Block size. More... | |
std::string | m_compressor |
Compressor specification. More... | |
std::string | m_bloomfilter |
Bloom filter specification. More... | |
bool | m_in_memory {} |
In memory. More... | |
std::bitset< MAX > | m_isset |
Bit mask describing which options are set. More... | |
Specification for access group options.
Definition at line 54 of file AccessGroupSpec.h.
|
inline |
|
inline |
Gets bloom filter option.
Definition at line 157 of file AccessGroupSpec.h.
|
inline |
|
inline |
|
inline |
Gets replication option.
Definition at line 81 of file AccessGroupSpec.h.
bool AccessGroupOptions::is_set_blocksize | ( | ) | const |
Checks if blocksize option is set.
This method returns the value of the BLOCKSIZE bit of m_isset.
Definition at line 150 of file AccessGroupSpec.cc.
bool AccessGroupOptions::is_set_bloom_filter | ( | ) | const |
Checks if bloom filter option is set.
This method returns the value of the BLOOMFILTER bit of m_isset.
Definition at line 170 of file AccessGroupSpec.cc.
bool AccessGroupOptions::is_set_compressor | ( | ) | const |
Checks if compressor option is set.
This method returns the value of the COMPRESSOR bit of m_isset.
Definition at line 160 of file AccessGroupSpec.cc.
bool AccessGroupOptions::is_set_in_memory | ( | ) | const |
Checks if in memory option is set.
This method returns the value of the IN_MEMORY bit of m_isset.
Definition at line 179 of file AccessGroupSpec.cc.
bool AccessGroupOptions::is_set_replication | ( | ) | const |
Checks if replication option is set.
This method returns the value of the REPLICATION bit of m_isset.
Definition at line 141 of file AccessGroupSpec.cc.
void AccessGroupOptions::merge | ( | const AccessGroupOptions & | other | ) |
Merges options from another AccessGroupOptions object.
For each option that is not set, if the corresponding option in the other
parameter is set, then the option is set to other
's value.
other | AccessGroupOptions object with which to merge |
Definition at line 183 of file AccessGroupSpec.cc.
bool AccessGroupOptions::operator== | ( | const AccessGroupOptions & | other | ) | const |
Equality operator.
other | Other object to which comparison is to be made |
other
, false otherwise. Definition at line 264 of file AccessGroupSpec.cc.
|
static |
Parsers a bloom filter specification and sets properties.
Parses the bloom filter specification given in spec
and populates props
with the corresponding properties described in the following table.
Property | Type | Default | Description |
---|---|---|---|
bloom-filter-mode | string | none | Mode (rows|rows+cols|none) |
bits-per-item | float | none | Number of bits to use per item |
num-hashes | int | none | Number of hash functions to use |
false-positive | float | 0.01 | Expected false positive probability |
max-approx-items | int | 1000 | Number of cell store items used to estimate the number of actual entries |
spec | Bloom filter specification |
props | Properties object to populate |
Definition at line 274 of file AccessGroupSpec.cc.
void AccessGroupOptions::parse_xml | ( | const char * | base, |
int | len | ||
) |
Parses XML options specification.
This method parses an XML document which holds access group options, populates the corresponding member variables. The parser accepts any element name for the outtermost element so that it can be used to parse options from any section within a schema XML document (e.g. AccessGroupDefaults or Options). The following example illustrates a valid XML opitons document.
* <Options> * <Replication>3</Replication> * <BlockSize>67108864</BlockSize> * <Compressor>zlib --best</Compressor> * <BloomFilter>rows+cols --false-positive 0.02 --bits-per-item 9 * --num-hashes 7 --max-approx-items 900</BloomFilter> * <InMemory>true</InMemory> * </Options> *
base | Pointer to character buffer holding XML document |
len | Length of XML document |
Definition at line 224 of file AccessGroupSpec.cc.
const std::string AccessGroupOptions::render_hql | ( | ) | const |
Renders options in HQL format.
Access group options can be specified in an HQL CREATE TABLE
command for access group specifications or table defaults. In both situations, the format of the options specification is the same. The following shows an example of the HQL output produced by this member function.
REPLICATION 3 BLOCKSIZE 67108864 COMPRESSOR "zlib --best" BLOOMFILTER "rows+cols --false-positive 0.02" IN_MEMORY
Definition at line 249 of file AccessGroupSpec.cc.
const std::string AccessGroupOptions::render_xml | ( | const std::string & | line_prefix | ) | const |
Renders options in XML format.
Access group options can be specified in an XML schema document within the AccessGroup -> Options
element or the Table -> AccessGroupDefaults
element. This member function generates the XML option specification elements that can be used in both places. The line_prefix
parameter can be used to get nice indenting if the object is being rendered as part of a larger object and is typically some number of space characters. The following is example output produced by this member function.
* <Replication>3</Replication> * <BlockSize>67108864</BlockSize> * <Compressor>zlib --best</Compressor> * <BloomFilter>rows+cols --false-positive 0.02 --bits-per-item 9 * --num-hashes 7 --max-approx-items 900</BloomFilter> * <InMemory>true</InMemory> *
line_prefix | std::string to prepend to each line of output |
Definition at line 229 of file AccessGroupSpec.cc.
void AccessGroupOptions::set_blocksize | ( | int32_t | blocksize | ) |
Sets blocksize option.
Sets the BLOCKSIZE bit of m_isset and sets m_blocksize to blocksize
.
blocksize | New value for blocksize option |
Definition at line 145 of file AccessGroupSpec.cc.
void AccessGroupOptions::set_bloom_filter | ( | const std::string & | bloomfilter | ) |
Sets bloom filter option.
Sets the BLOOMFILTER bit of m_isset, validates the specification given in the bloomfilter
argument, and if it is valid, sets m_bloomfilter to bloomfilter
. The following bloom filter specifications are valid:
mode: rows [options] rows+cols [options] none
options: --bits-per-item <float> --num-hashes <int> --false-positive <float> --max-approx-items <int>
bloomfilter | Bloom filter specification |
Exception | with code set to Error::SCHEMA_PARSE_ERROR if bloom filter specification is invalid |
Definition at line 164 of file AccessGroupSpec.cc.
void AccessGroupOptions::set_compressor | ( | const std::string & | compressor | ) |
Sets compressor option.
Sets the COMPRESSOR bit of m_isset, validates the specification given in the compressor
argument, and if it is valid, sets m_compressor to compressor
. The following compressor specifications are valid:
bmz [--fp-len <int>] [--offset <int>] lzo quicklz zlib [--best|--9|--normal] snappy none
compressor | Compressor specification |
Exception | with code set to Error::SCHEMA_PARSE_ERROR if compressor specification is invalid |
Definition at line 154 of file AccessGroupSpec.cc.
void AccessGroupOptions::set_in_memory | ( | bool | value | ) |
Sets in memory option.
Sets the IN_MEMORY bit of m_isset and sets m_in_memory to value
.
value | New value for in memory option |
Definition at line 174 of file AccessGroupSpec.cc.
void AccessGroupOptions::set_replication | ( | int16_t | replication | ) |
Sets replication option.
Sets the REPLICATON bit of m_isset and sets m_replication to replication
.
replication | New value for replication option |
Definition at line 136 of file AccessGroupSpec.cc.
|
private |
Block size.
Definition at line 303 of file AccessGroupSpec.h.
|
private |
Bloom filter specification.
Definition at line 309 of file AccessGroupSpec.h.
|
private |
Compressor specification.
Definition at line 306 of file AccessGroupSpec.h.
|
private |
In memory.
Definition at line 312 of file AccessGroupSpec.h.
|
private |
Bit mask describing which options are set.
Definition at line 315 of file AccessGroupSpec.h.
|
private |
Replication.
Definition at line 300 of file AccessGroupSpec.h.