Skip to content

Commit

Permalink
Added functions to check if optional parameters in a ColumnFamilyDefi…
Browse files Browse the repository at this point in the history
…nition are set or not.
  • Loading branch information
posulliv committed Feb 20, 2011
1 parent 5e1f2d1 commit 151c6a4
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
72 changes: 72 additions & 0 deletions libcassandra/column_family_definition.cc
Expand Up @@ -208,6 +208,12 @@ void ColumnFamilyDefinition::setRowCacheSize(double size)
}


bool ColumnFamilyDefinition::isRowCacheSizeSet() const
{
return (row_cache_size > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getRowCacheSavePeriod() const
{
return row_cache_save_period_in_seconds;
Expand All @@ -220,6 +226,12 @@ void ColumnFamilyDefinition::setRowCacheSavePeriod(int32_t save_period)
}


bool ColumnFamilyDefinition::isRowCacheSavePeriodSet() const
{
return (row_cache_save_period_in_seconds > 0 ? true : false);
}


double ColumnFamilyDefinition::getKeyCacheSize() const
{
return key_cache_size;
Expand All @@ -232,6 +244,12 @@ void ColumnFamilyDefinition::setKeyCacheSize(double size)
}


bool ColumnFamilyDefinition::isKeyCacheSizeSet() const
{
return (key_cache_size > 0 ? true : false);
}


double ColumnFamilyDefinition::getReadRepairChance() const
{
return read_repair_chance;
Expand All @@ -244,6 +262,12 @@ void ColumnFamilyDefinition::setReadRepairChance(double chance)
}


bool ColumnFamilyDefinition::isReadRepairChanceSet() const
{
return (read_repair_chance > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getGcGraceSeconds() const
{
return gc_grace_seconds;
Expand All @@ -256,6 +280,12 @@ void ColumnFamilyDefinition::setGcGraceSeconds(int32_t gc_secs)
}


bool ColumnFamilyDefinition::isGcGraceSecondsSet() const
{
return (gc_grace_seconds > 0 ? true : false);
}


string ColumnFamilyDefinition::getDefaultValidationClass() const
{
return default_validation_class;
Expand All @@ -268,6 +298,12 @@ void ColumnFamilyDefinition::setDefaultValidationClass(const string& class_name)
}


bool ColumnFamilyDefinition::isDefaultValidationClassSet() const
{
return (! default_validation_class.empty());
}


int32_t ColumnFamilyDefinition::getId() const
{
return id;
Expand All @@ -280,6 +316,12 @@ void ColumnFamilyDefinition::setId(int32_t new_id)
}


bool ColumnFamilyDefinition::isIdSet() const
{
return (id > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getMaxCompactionThreshold() const
{
return max_compaction_threshold;
Expand All @@ -292,6 +334,12 @@ void ColumnFamilyDefinition::setMaxCompactionThreshold(int32_t threshold)
}


bool ColumnFamilyDefinition::isMaxCompactionThresholdSet() const
{
return (max_compaction_threshold > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getMinCompactionThreshold() const
{
return min_compaction_threshold;
Expand All @@ -304,6 +352,12 @@ void ColumnFamilyDefinition::setMinCompactionThreshold(int32_t threshold)
}


bool ColumnFamilyDefinition::isMinCompactionThresholdSet() const
{
return (min_compaction_threshold > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getMemtableFlushAfterMins() const
{
return memtable_flush_after_mins;
Expand All @@ -316,6 +370,12 @@ void ColumnFamilyDefinition::setMemtableFlushAfterMins(int32_t flush)
}


bool ColumnFamilyDefinition::isMemtableFlushAfterMinsSet() const
{
return (memtable_flush_after_mins > 0 ? true : false);
}


double ColumnFamilyDefinition::getMemtableOperationsInMillions() const
{
return memtable_operations_in_millions;
Expand All @@ -328,6 +388,12 @@ void ColumnFamilyDefinition::setMemtableOperationsInMillions(double ops)
}


bool ColumnFamilyDefinition::isMemtableOperationsInMillionsSet() const
{
return (memtable_operations_in_millions > 0 ? true : false);
}


int32_t ColumnFamilyDefinition::getMemtableThroughputInMb() const
{
return memtable_throughput_in_mb;
Expand All @@ -339,3 +405,9 @@ void ColumnFamilyDefinition::setMemtableThroughputInMb(int32_t throughput)
memtable_throughput_in_mb= throughput;
}


bool ColumnFamilyDefinition::isMemtableThroughputInMbSet() const
{
return (memtable_throughput_in_mb > 0 ? true : false);
}

60 changes: 60 additions & 0 deletions libcassandra/column_family_definition.h
Expand Up @@ -120,83 +120,143 @@ class ColumnFamilyDefinition

void setRowCacheSize(double size);

/**
* @return true if row cache size is > 0; false otherwise
*/
bool isRowCacheSizeSet() const;

/**
* @return row cache save period in seconds
*/
int32_t getRowCacheSavePeriod() const;

void setRowCacheSavePeriod(int32_t save_period);

/**
* @return true if row cache save period is > 0; false otherwise
*/
bool isRowCacheSavePeriodSet() const;

/**
* @return key cache size
*/
double getKeyCacheSize() const;

void setKeyCacheSize(double size);

/**
* @return true if key cache size is > 0; false otherwise
*/
bool isKeyCacheSizeSet() const;

/**
* @return read repair chance
*/
double getReadRepairChance() const;

void setReadRepairChance(double chance);

/**
* @return true if read repair chance > 0; false otherwise
*/
bool isReadRepairChanceSet() const;

/**
* @return garbage collection grace seconds
*/
int32_t getGcGraceSeconds() const;

void setGcGraceSeconds(int32_t gc_secs);

/**
* @return true if gc grace seconds > 0; false otherwise
*/
bool isGcGraceSecondsSet() const;

/**
* @return default validation class
*/
std::string getDefaultValidationClass() const;

void setDefaultValidationClass(const std::string& class_name);

/**
* @return true if default validation class is set; false otherwise
*/
bool isDefaultValidationClassSet() const;

/**
* @return column family ID
*/
int32_t getId() const;

void setId(int32_t new_id);

/**
* @return true if id > 0; false otherwise
*/
bool isIdSet() const;

/**
* @return max compaction threshold
*/
int32_t getMaxCompactionThreshold() const;

void setMaxCompactionThreshold(int32_t threshold);

/**
* @return true if max compaction threshold > 0; false otherwise
*/
bool isMaxCompactionThresholdSet() const;

/**
* @return min compaction threshold
*/
int32_t getMinCompactionThreshold() const;

void setMinCompactionThreshold(int32_t threshold);

/**
* @return true if min compaction threshold > 0; false otherwise
*/
bool isMinCompactionThresholdSet() const;

/**
* @return memtable flush after mins
*/
int32_t getMemtableFlushAfterMins() const;

void setMemtableFlushAfterMins(int32_t flush);

/**
* @return true if memtable flush mins > 0; false otherwise
*/
bool isMemtableFlushAfterMinsSet() const;

/**
* @return memtable operations in millions
*/
double getMemtableOperationsInMillions() const;

void setMemtableOperationsInMillions(double ops);

/**
* @return true if memtable ops > 0; false otherwise
*/
bool isMemtableOperationsInMillionsSet() const;

/**
* @return memtable throughput in megabytes
*/
int32_t getMemtableThroughputInMb() const;

void setMemtableThroughputInMb(int32_t throughput);

/**
* @return true if memtable throughput > 0; false otherwise
*/
bool isMemtableThroughputInMbSet() const;

private:

std::string keyspace_name;
Expand Down
5 changes: 5 additions & 0 deletions libcassandra/util_functions.cc
Expand Up @@ -83,6 +83,11 @@ CfDef createCfDefObject(const ColumnFamilyDefinition& cf_def)
thrift_cf_def.comment.assign(cf_def.getComment());
thrift_cf_def.__isset.comment= true;
}
if (cf_def.isRowCacheSizeSet())
{
thrift_cf_def.row_cache_size= cf_def.getRowCacheSize();
thrift_cf_def.__isset.row_cache_size= true;
}
return thrift_cf_def;
}

Expand Down

0 comments on commit 151c6a4

Please sign in to comment.