use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitionsTest method cfDefWithDifferingGcGraceSecondsValuesShouldNotMatch.
@Test
public void cfDefWithDifferingGcGraceSecondsValuesShouldNotMatch() {
CfDef clientSideTable = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), CassandraConstants.DEFAULT_GC_GRACE_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
CfDef clusterSideTable = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
assertFalse("ColumnDefinitions with different gc_grace_seconds should not match", ColumnFamilyDefinitions.isMatchingCf(clientSideTable, clusterSideTable));
}
use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitionsTest method nonDefaultFeaturesCorrectlyCompared.
@Test
public void nonDefaultFeaturesCorrectlyCompared() {
CfDef cf1 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, TABLE_METADATA_WITH_MANY_NON_DEFAULT_FEATURES);
CfDef cf2 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, TABLE_METADATA_WITH_MANY_NON_DEFAULT_FEATURES);
assertTrue("identical CFs should equal each other", ColumnFamilyDefinitions.isMatchingCf(cf1, cf2));
}
use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitionsTest method identicalCfsAreEqual.
@Test
public void identicalCfsAreEqual() {
CfDef cf1 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
CfDef cf2 = ColumnFamilyDefinitions.getCfDef("test_keyspace", TableReference.fromString("test_table"), FOUR_DAYS_IN_SECONDS, AtlasDbConstants.GENERIC_TABLE_METADATA);
assertTrue("identical CFs should equal each other", ColumnFamilyDefinitions.isMatchingCf(cf1, cf2));
}
use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitions method getStandardCfDef.
/**
* Provides a basic column family definition. This is a subset of #getCfDef, and does not
* include compression options, but also does not require raw metadata to be passed in.
*
* Warning to developers: you must update CKVS.isMatchingCf if you update this method
*/
static CfDef getStandardCfDef(String keyspace, String internalTableName) {
CfDef cf = new CfDef(keyspace, internalTableName);
cf.setComparator_type("CompositeType(BytesType,LongType)");
cf.setCompaction_strategy(CassandraConstants.LEVELED_COMPACTION_STRATEGY);
cf.setCompression_options(Maps.<String, String>newHashMap());
cf.setGc_grace_seconds(CassandraConstants.DEFAULT_GC_GRACE_SECONDS);
// explicitly set fields to default values
cf.setCaching("KEYS_ONLY");
cf.setDclocal_read_repair_chance(0.1);
cf.setTriggers(new ArrayList<TriggerDef>());
cf.setCells_per_row_to_cache("0");
cf.setMin_index_interval(128);
cf.setMax_index_interval(2048);
cf.setComment("");
cf.setColumn_metadata(new ArrayList<ColumnDef>());
cf.setMin_compaction_threshold(4);
cf.setMax_compaction_threshold(32);
cf.setKey_validation_class("org.apache.cassandra.db.marshal.BytesType");
cf.setCompaction_strategy_options(new HashMap<String, String>());
cf.setDefault_validation_class("org.apache.cassandra.db.marshal.BytesType");
return cf;
}
use of org.apache.cassandra.thrift.CfDef in project atlasdb by palantir.
the class ColumnFamilyDefinitions method getCfDef.
/**
* Provides a default column family definition given raw metadata, which is generally obtained from the _metadata
* table.
*
* Warning to developers: you must update CKVS.isMatchingCf if you update this method
*/
@SuppressWarnings("CyclomaticComplexity")
static CfDef getCfDef(String keyspace, TableReference tableRef, int gcGraceSeconds, byte[] rawMetadata) {
Map<String, String> compressionOptions = Maps.newHashMap();
CfDef cf = getStandardCfDef(keyspace, AbstractKeyValueService.internalTableName(tableRef));
boolean negativeLookups = false;
double falsePositiveChance = CassandraConstants.DEFAULT_LEVELED_COMPACTION_BLOOM_FILTER_FP_CHANCE;
int explicitCompressionBlockSizeKb = 0;
boolean appendHeavyAndReadLight = false;
TableMetadataPersistence.CachePriority cachePriority = TableMetadataPersistence.CachePriority.WARM;
if (!CassandraKeyValueServices.isEmptyOrInvalidMetadata(rawMetadata)) {
TableMetadata tableMetadata = TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(rawMetadata);
negativeLookups = tableMetadata.hasNegativeLookups();
explicitCompressionBlockSizeKb = tableMetadata.getExplicitCompressionBlockSizeKB();
appendHeavyAndReadLight = tableMetadata.isAppendHeavyAndReadLight();
cachePriority = tableMetadata.getCachePriority();
}
if (explicitCompressionBlockSizeKb != 0) {
compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_TYPE_KEY, CassandraConstants.DEFAULT_COMPRESSION_TYPE);
compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_CHUNK_LENGTH_KEY, Integer.toString(explicitCompressionBlockSizeKb));
} else {
// We don't really need compression here nor anticipate it will garner us any gains
// (which is why we're doing such a small chunk size), but this is how we can get "free" CRC checking.
compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_TYPE_KEY, CassandraConstants.DEFAULT_COMPRESSION_TYPE);
compressionOptions.put(CassandraConstants.CFDEF_COMPRESSION_CHUNK_LENGTH_KEY, Integer.toString(AtlasDbConstants.MINIMUM_COMPRESSION_BLOCK_SIZE_KB));
}
if (negativeLookups) {
falsePositiveChance = CassandraConstants.NEGATIVE_LOOKUPS_BLOOM_FILTER_FP_CHANCE;
}
if (appendHeavyAndReadLight) {
cf.setCompaction_strategy(CassandraConstants.SIZE_TIERED_COMPACTION_STRATEGY);
// clear out the now nonsensical "keep it at 80MB per sstable" option from LCS
cf.setCompaction_strategy_optionsIsSet(false);
if (!negativeLookups) {
falsePositiveChance = CassandraConstants.DEFAULT_SIZE_TIERED_COMPACTION_BLOOM_FILTER_FP_CHANCE;
} else {
falsePositiveChance = CassandraConstants.NEGATIVE_LOOKUPS_SIZE_TIERED_BLOOM_FILTER_FP_CHANCE;
}
}
switch(cachePriority) {
case COLDEST:
break;
case COLD:
break;
case WARM:
break;
case HOT:
break;
case HOTTEST:
cf.setPopulate_io_cache_on_flushIsSet(true);
break;
default:
throw new PalantirRuntimeException("Unknown cache priority: " + cachePriority);
}
cf.setGc_grace_seconds(gcGraceSeconds);
cf.setBloom_filter_fp_chance(falsePositiveChance);
cf.setCompression_options(compressionOptions);
return cf;
}
Aggregations