org.apache.cassandra.io.compress.CompressionParameters Java Examples
The following examples show how to use
org.apache.cassandra.io.compress.CompressionParameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompressionMetadata.java From hadoop-sstable with Apache License 2.0 | 6 votes |
public void writeHeader(CompressionParameters parameters) { try { writeUTF(parameters.sstableCompressor.getClass().getSimpleName()); writeInt(parameters.otherOptions.size()); for (Map.Entry<String, String> entry : parameters.otherOptions.entrySet()) { writeUTF(entry.getKey()); writeUTF(entry.getValue()); } // store the length of the chunk writeInt(parameters.chunkLength()); // store position and reserve a place for uncompressed data length and chunks count dataLengthOffset = getFilePointer(); writeLong(-1); writeInt(-1); } catch (IOException e) { throw new FSWriteError(e, filePath); } }
Example #2
Source File: CreateTableStatement.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public CreateTableStatement(CFName name, CFPropDefs properties, boolean ifNotExists, Set<ColumnIdentifier> staticColumns) { super(name); this.properties = properties; this.ifNotExists = ifNotExists; this.staticColumns = staticColumns; try { if (!this.properties.hasProperty(CFPropDefs.KW_COMPRESSION) && CFMetaData.DEFAULT_COMPRESSOR != null) this.properties.addProperty(CFPropDefs.KW_COMPRESSION, new HashMap<String, String>() {{ put(CompressionParameters.SSTABLE_COMPRESSION, CFMetaData.DEFAULT_COMPRESSOR); }}); } catch (SyntaxException e) { throw new AssertionError(e); } }
Example #3
Source File: CompressionMetadata.java From aegisthus with Apache License 2.0 | 5 votes |
public CompressionMetadata(InputStream compressionInput, long compressedLength, boolean doNonEndCalculations) throws IOException { try (DataInputStream stream = new DataInputStream(compressionInput)) { String compressorName = stream.readUTF(); int optionCount = stream.readInt(); Map<String, String> options = Maps.newHashMap(); for (int i = 0; i < optionCount; ++i) { String key = stream.readUTF(); String value = stream.readUTF(); if (doNonEndCalculations) { options.put(key, value); } } int chunkLength = stream.readInt(); if (doNonEndCalculations) { try { parameters = new CompressionParameters(compressorName, chunkLength, options); } catch (ConfigurationException e) { throw new RuntimeException("Cannot create CompressionParameters for stored parameters", e); } } setDataLength(stream.readLong()); if (doNonEndCalculations) { chunkLengths = readChunkLengths(stream, compressedLength); } current = 0; } }
Example #4
Source File: CFPropDefs.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void applyToCFMetadata(CFMetaData cfm) throws ConfigurationException, SyntaxException { if (hasProperty(KW_COMMENT)) cfm.comment(getString(KW_COMMENT, "")); cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance())); cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair())); cfm.gcGraceSeconds(getInt(KW_GCGRACESECONDS, cfm.getGcGraceSeconds())); int minCompactionThreshold = toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold()); int maxCompactionThreshold = toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold()); if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); cfm.minCompactionThreshold(minCompactionThreshold); cfm.maxCompactionThreshold(maxCompactionThreshold); cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString()))); cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod())); cfm.minIndexInterval(getInt(KW_MIN_INDEX_INTERVAL, cfm.getMinIndexInterval())); cfm.maxIndexInterval(getInt(KW_MAX_INDEX_INTERVAL, cfm.getMaxIndexInterval())); if (compactionStrategyClass != null) { cfm.compactionStrategyClass(compactionStrategyClass); cfm.compactionStrategyOptions(new HashMap<>(getCompactionOptions())); } cfm.bloomFilterFpChance(getDouble(KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance())); if (!getCompressionOptions().isEmpty()) cfm.compressionParameters(CompressionParameters.create(getCompressionOptions())); CachingOptions cachingOptions = getCachingOptions(); if (cachingOptions != null) cfm.caching(cachingOptions); }
Example #5
Source File: ConfigHelper.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static CompressionParameters getOutputCompressionParamaters(Configuration conf) { if (getOutputCompressionClass(conf) == null) return new CompressionParameters(null); Map<String, String> options = new HashMap<String, String>(); options.put(CompressionParameters.SSTABLE_COMPRESSION, getOutputCompressionClass(conf)); options.put(CompressionParameters.CHUNK_LENGTH_KB, getOutputCompressionChunkLength(conf)); try { return CompressionParameters.create(options); } catch (ConfigurationException e) { throw new RuntimeException(e); } }
Example #6
Source File: ColumnFamilyStore.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void setCompressionParameters(Map<String,String> opts) { try { metadata.compressionParameters = CompressionParameters.create(opts); } catch (ConfigurationException e) { throw new IllegalArgumentException(e.getMessage()); } }
Example #7
Source File: SchemaLoader.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private static void useCompression(List<KSMetaData> schema) { for (KSMetaData ksm : schema) { for (CFMetaData cfm : ksm.cfMetaData().values()) { cfm.compressionParameters(new CompressionParameters(SnappyCompressor.instance)); } } }
Example #8
Source File: SequentialWriter.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static CompressedSequentialWriter open(String dataFilePath, String offsetsPath, CompressionParameters parameters, MetadataCollector sstableMetadataCollector) { return new CompressedSequentialWriter(new File(dataFilePath), offsetsPath, parameters, sstableMetadataCollector); }
Example #9
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** applies implicit defaults to cf definition. useful in updates */ private static void applyImplicitDefaults(org.apache.cassandra.thrift.CfDef cf_def) { if (!cf_def.isSetComment()) cf_def.setComment(""); if (!cf_def.isSetMin_compaction_threshold()) cf_def.setMin_compaction_threshold(CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD); if (!cf_def.isSetMax_compaction_threshold()) cf_def.setMax_compaction_threshold(CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD); if (cf_def.compaction_strategy == null) cf_def.compaction_strategy = DEFAULT_COMPACTION_STRATEGY_CLASS.getSimpleName(); if (cf_def.compaction_strategy_options == null) cf_def.compaction_strategy_options = Collections.emptyMap(); if (!cf_def.isSetCompression_options()) { cf_def.setCompression_options(new HashMap<String, String>() {{ if (DEFAULT_COMPRESSOR != null) put(CompressionParameters.SSTABLE_COMPRESSION, DEFAULT_COMPRESSOR); }}); } if (!cf_def.isSetDefault_time_to_live()) cf_def.setDefault_time_to_live(CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE); if (!cf_def.isSetDclocal_read_repair_chance()) cf_def.setDclocal_read_repair_chance(CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE); // if index_interval was set, use that for the min_index_interval default if (!cf_def.isSetMin_index_interval()) { if (cf_def.isSetIndex_interval()) cf_def.setMin_index_interval(cf_def.getIndex_interval()); else cf_def.setMin_index_interval(CFMetaData.DEFAULT_MIN_INDEX_INTERVAL); } if (!cf_def.isSetMax_index_interval()) { // ensure the max is at least as large as the min cf_def.setMax_index_interval(Math.max(cf_def.min_index_interval, CFMetaData.DEFAULT_MAX_INDEX_INTERVAL)); } }
Example #10
Source File: SSTableSimpleUnsortedWriter.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public SSTableSimpleUnsortedWriter(File directory, IPartitioner partitioner, String keyspace, String columnFamily, AbstractType<?> comparator, AbstractType<?> subComparator, int bufferSizeInMB) { this(directory, partitioner, keyspace, columnFamily, comparator, subComparator, bufferSizeInMB, new CompressionParameters(null)); }
Example #11
Source File: CompressionInfo.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public long serializedSize(CompressionInfo info, int version) { if (info == null) return TypeSizes.NATIVE.sizeof(-1); // chunks int chunkCount = info.chunks.length; long size = TypeSizes.NATIVE.sizeof(chunkCount); for (int i = 0; i < chunkCount; i++) size += CompressionMetadata.Chunk.serializer.serializedSize(info.chunks[i], version); // compression params size += CompressionParameters.serializer.serializedSize(info.parameters, version); return size; }
Example #12
Source File: CompressionInfo.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void serialize(CompressionInfo info, DataOutputPlus out, int version) throws IOException { if (info == null) { out.writeInt(-1); return; } int chunkCount = info.chunks.length; out.writeInt(chunkCount); for (int i = 0; i < chunkCount; i++) CompressionMetadata.Chunk.serializer.serialize(info.chunks[i], out, version); // compression params CompressionParameters.serializer.serialize(info.parameters, out, version); }
Example #13
Source File: CompressionInfo.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public CompressionInfo deserialize(DataInput in, int version) throws IOException { // chunks int chunkCount = in.readInt(); if (chunkCount < 0) return null; CompressionMetadata.Chunk[] chunks = new CompressionMetadata.Chunk[chunkCount]; for (int i = 0; i < chunkCount; i++) chunks[i] = CompressionMetadata.Chunk.serializer.deserialize(in, version); // compression params CompressionParameters parameters = CompressionParameters.serializer.deserialize(in, version); return new CompressionInfo(chunks, parameters); }
Example #14
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | 4 votes |
static CFMetaData fromSchemaNoTriggers(UntypedResultSet.Row result, UntypedResultSet serializedColumnDefinitions) { try { String ksName = result.getString("keyspace_name"); String cfName = result.getString("columnfamily_name"); AbstractType<?> rawComparator = TypeParser.parse(result.getString("comparator")); AbstractType<?> subComparator = result.has("subcomparator") ? TypeParser.parse(result.getString("subcomparator")) : null; ColumnFamilyType cfType = ColumnFamilyType.valueOf(result.getString("type")); AbstractType<?> fullRawComparator = makeRawAbstractType(rawComparator, subComparator); List<ColumnDefinition> columnDefs = ColumnDefinition.fromSchema(serializedColumnDefinitions, ksName, cfName, fullRawComparator, cfType == ColumnFamilyType.Super); boolean isDense = result.has("is_dense") ? result.getBoolean("is_dense") : calculateIsDense(fullRawComparator, columnDefs); CellNameType comparator = CellNames.fromAbstractType(fullRawComparator, isDense); // if we are upgrading, we use id generated from names initially UUID cfId = result.has("cf_id") ? result.getUUID("cf_id") : generateLegacyCfId(ksName, cfName); CFMetaData cfm = new CFMetaData(ksName, cfName, cfType, comparator, cfId); cfm.isDense(isDense); cfm.readRepairChance(result.getDouble("read_repair_chance")); cfm.dcLocalReadRepairChance(result.getDouble("local_read_repair_chance")); cfm.gcGraceSeconds(result.getInt("gc_grace_seconds")); cfm.defaultValidator(TypeParser.parse(result.getString("default_validator"))); cfm.keyValidator(TypeParser.parse(result.getString("key_validator"))); cfm.minCompactionThreshold(result.getInt("min_compaction_threshold")); cfm.maxCompactionThreshold(result.getInt("max_compaction_threshold")); if (result.has("comment")) cfm.comment(result.getString("comment")); if (result.has("bloom_filter_fp_chance")) cfm.bloomFilterFpChance(result.getDouble("bloom_filter_fp_chance")); if (result.has("memtable_flush_period_in_ms")) cfm.memtableFlushPeriod(result.getInt("memtable_flush_period_in_ms")); cfm.caching(CachingOptions.fromString(result.getString("caching"))); if (result.has("default_time_to_live")) cfm.defaultTimeToLive(result.getInt("default_time_to_live")); if (result.has("speculative_retry")) cfm.speculativeRetry(SpeculativeRetry.fromString(result.getString("speculative_retry"))); cfm.compactionStrategyClass(createCompactionStrategy(result.getString("compaction_strategy_class"))); cfm.compressionParameters(CompressionParameters.create(fromJsonMap(result.getString("compression_parameters")))); cfm.compactionStrategyOptions(fromJsonMap(result.getString("compaction_strategy_options"))); // migrate old index_interval values to min_index_interval, if present if (result.has("min_index_interval")) cfm.minIndexInterval(result.getInt("min_index_interval")); else if (result.has("index_interval")) cfm.minIndexInterval(result.getInt("index_interval")); if (result.has("max_index_interval")) cfm.maxIndexInterval(result.getInt("max_index_interval")); /* * The info previously hold by key_aliases, column_aliases and value_alias is now stored in columnMetadata (because 1) this * make more sense and 2) this allow to store indexing information). * However, for upgrade sake we need to still be able to read those old values. Moreover, we cannot easily * remove those old columns once "converted" to columnMetadata because that would screw up nodes that may * not have upgraded. So for now we keep the both info and in sync, even though its redundant. */ if (result.has("key_aliases")) cfm.addColumnMetadataFromAliases(aliasesFromStrings(fromJsonList(result.getString("key_aliases"))), cfm.keyValidator, ColumnDefinition.Kind.PARTITION_KEY); if (result.has("column_aliases")) cfm.addColumnMetadataFromAliases(aliasesFromStrings(fromJsonList(result.getString("column_aliases"))), cfm.comparator.asAbstractType(), ColumnDefinition.Kind.CLUSTERING_COLUMN); if (result.has("value_alias")) cfm.addColumnMetadataFromAliases(Collections.singletonList(result.getBytes("value_alias")), cfm.defaultValidator, ColumnDefinition.Kind.COMPACT_VALUE); if (result.has("dropped_columns")) cfm.droppedColumns(convertDroppedColumns(result.getMap("dropped_columns", UTF8Type.instance, LongType.instance))); for (ColumnDefinition cd : columnDefs) cfm.addOrReplaceColumnDefinition(cd); return cfm.rebuild(); } catch (SyntaxException | ConfigurationException e) { throw new RuntimeException(e); } }
Example #15
Source File: CompressedRandomAccessReaderTest.java From hadoop-sstable with Apache License 2.0 | 4 votes |
@Test public void testResetAndTruncateCompressed() throws IOException { // test reset in current buffer or previous one testResetAndTruncate(File.createTempFile("compressed", "1"), true, 10); testResetAndTruncate(File.createTempFile("compressed", "2"), true, CompressionParameters.DEFAULT_CHUNK_LENGTH); }
Example #16
Source File: CompressedRandomAccessReaderTest.java From hadoop-sstable with Apache License 2.0 | 4 votes |
@Test public void testResetAndTruncate() throws IOException { // test reset in current buffer or previous one testResetAndTruncate(File.createTempFile("normal", "1"), false, 10); testResetAndTruncate(File.createTempFile("normal", "2"), false, CompressionParameters.DEFAULT_CHUNK_LENGTH); }
Example #17
Source File: CompressionInfo.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CompressionInfo(CompressionMetadata.Chunk[] chunks, CompressionParameters parameters) { assert chunks != null && parameters != null; this.chunks = chunks; this.parameters = parameters; }
Example #18
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | 4 votes |
private static CFMetaData internalFromThrift(CfDef cf_def, Collection<ColumnDefinition> previousCQLMetadata) throws InvalidRequestException, ConfigurationException { ColumnFamilyType cfType = ColumnFamilyType.create(cf_def.column_type); if (cfType == null) throw new InvalidRequestException("Invalid column type " + cf_def.column_type); applyImplicitDefaults(cf_def); try { AbstractType<?> rawComparator = TypeParser.parse(cf_def.comparator_type); AbstractType<?> subComparator = cfType == ColumnFamilyType.Standard ? null : cf_def.subcomparator_type == null ? BytesType.instance : TypeParser.parse(cf_def.subcomparator_type); AbstractType<?> fullRawComparator = makeRawAbstractType(rawComparator, subComparator); AbstractType<?> keyValidator = cf_def.isSetKey_validation_class() ? TypeParser.parse(cf_def.key_validation_class) : null; // Convert the REGULAR definitions from the input CfDef List<ColumnDefinition> defs = ColumnDefinition.fromThrift(cf_def.keyspace, cf_def.name, rawComparator, subComparator, cf_def.column_metadata); // Add the keyAlias if there is one, since that's on CQL metadata that thrift can actually change (for // historical reasons) boolean hasKeyAlias = cf_def.isSetKey_alias() && keyValidator != null && !(keyValidator instanceof CompositeType); if (hasKeyAlias) defs.add(ColumnDefinition.partitionKeyDef(cf_def.keyspace, cf_def.name, cf_def.key_alias, keyValidator, null)); // Now add any CQL metadata that we want to copy, skipping the keyAlias if there was one for (ColumnDefinition def : previousCQLMetadata) { // isPartOfCellName basically means 'is not just a CQL metadata' if (def.isPartOfCellName()) continue; if (def.kind == ColumnDefinition.Kind.PARTITION_KEY && hasKeyAlias) continue; defs.add(def); } CellNameType comparator = CellNames.fromAbstractType(fullRawComparator, calculateIsDense(fullRawComparator, defs)); UUID cfId = Schema.instance.getId(cf_def.keyspace, cf_def.name); if (cfId == null) cfId = UUIDGen.getTimeUUID(); CFMetaData newCFMD = new CFMetaData(cf_def.keyspace, cf_def.name, cfType, comparator, cfId); newCFMD.addAllColumnDefinitions(defs); if (keyValidator != null) newCFMD.keyValidator(keyValidator); if (cf_def.isSetGc_grace_seconds()) newCFMD.gcGraceSeconds(cf_def.gc_grace_seconds); if (cf_def.isSetMin_compaction_threshold()) newCFMD.minCompactionThreshold(cf_def.min_compaction_threshold); if (cf_def.isSetMax_compaction_threshold()) newCFMD.maxCompactionThreshold(cf_def.max_compaction_threshold); if (cf_def.isSetCompaction_strategy()) newCFMD.compactionStrategyClass(createCompactionStrategy(cf_def.compaction_strategy)); if (cf_def.isSetCompaction_strategy_options()) newCFMD.compactionStrategyOptions(new HashMap<>(cf_def.compaction_strategy_options)); if (cf_def.isSetBloom_filter_fp_chance()) newCFMD.bloomFilterFpChance(cf_def.bloom_filter_fp_chance); if (cf_def.isSetMemtable_flush_period_in_ms()) newCFMD.memtableFlushPeriod(cf_def.memtable_flush_period_in_ms); if (cf_def.isSetCaching() || cf_def.isSetCells_per_row_to_cache()) newCFMD.caching(CachingOptions.fromThrift(cf_def.caching, cf_def.cells_per_row_to_cache)); if (cf_def.isSetRead_repair_chance()) newCFMD.readRepairChance(cf_def.read_repair_chance); if (cf_def.isSetDefault_time_to_live()) newCFMD.defaultTimeToLive(cf_def.default_time_to_live); if (cf_def.isSetDclocal_read_repair_chance()) newCFMD.dcLocalReadRepairChance(cf_def.dclocal_read_repair_chance); if (cf_def.isSetMin_index_interval()) newCFMD.minIndexInterval(cf_def.min_index_interval); if (cf_def.isSetMax_index_interval()) newCFMD.maxIndexInterval(cf_def.max_index_interval); if (cf_def.isSetSpeculative_retry()) newCFMD.speculativeRetry(SpeculativeRetry.fromString(cf_def.speculative_retry)); if (cf_def.isSetTriggers()) newCFMD.triggers(TriggerDefinition.fromThrift(cf_def.triggers)); return newCFMD.comment(cf_def.comment) .defaultValidator(TypeParser.parse(cf_def.default_validation_class)) .compressionParameters(CompressionParameters.create(cf_def.compression_options)) .rebuild(); } catch (SyntaxException | MarshalException e) { throw new ConfigurationException(e.getMessage()); } }
Example #19
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public CompressionParameters compressionParameters() { return compressionParameters; }
Example #20
Source File: CreateColumnFamilyStatement.java From stratio-cassandra with Apache License 2.0 | 4 votes |
/** * Returns a CFMetaData instance based on the parameters parsed from this * <code>CREATE</code> statement, or defaults where applicable. * * @param keyspace keyspace to apply this column family to * @return a CFMetaData instance corresponding to the values parsed from this statement * @throws InvalidRequestException on failure to validate parsed parameters */ public CFMetaData getCFMetaData(String keyspace, List<ByteBuffer> variables) throws InvalidRequestException { validate(variables); try { boolean isDense = columns.isEmpty(); CFMetaData newCFMD = new CFMetaData(keyspace, name, ColumnFamilyType.Standard, CellNames.fromAbstractType(cfProps.getComparator(), isDense)); if (CFMetaData.DEFAULT_COMPRESSOR != null && cfProps.compressionParameters.isEmpty()) cfProps.compressionParameters.put(CompressionParameters.SSTABLE_COMPRESSION, CFMetaData.DEFAULT_COMPRESSOR); int maxCompactionThreshold = getPropertyInt(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD, CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD); int minCompactionThreshold = getPropertyInt(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD, CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD); if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); newCFMD.isDense(isDense) .addAllColumnDefinitions(getColumns(newCFMD)) .comment(cfProps.getProperty(CFPropDefs.KW_COMMENT)) .readRepairChance(getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, CFMetaData.DEFAULT_READ_REPAIR_CHANCE)) .dcLocalReadRepairChance(getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE, CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE)) .gcGraceSeconds(getPropertyInt(CFPropDefs.KW_GCGRACESECONDS, CFMetaData.DEFAULT_GC_GRACE_SECONDS)) .defaultValidator(cfProps.getValidator()) .minCompactionThreshold(minCompactionThreshold) .maxCompactionThreshold(maxCompactionThreshold) .keyValidator(TypeParser.parse(CFPropDefs.comparators.get(getKeyType()))) .compactionStrategyClass(cfProps.compactionStrategyClass) .compactionStrategyOptions(cfProps.compactionStrategyOptions) .compressionParameters(CompressionParameters.create(cfProps.compressionParameters)) .caching(CachingOptions.fromString(getPropertyString(CFPropDefs.KW_CACHING, CFMetaData.DEFAULT_CACHING_STRATEGY.toString()))) .speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, CFMetaData.DEFAULT_SPECULATIVE_RETRY.toString()))) .bloomFilterFpChance(getPropertyDouble(CFPropDefs.KW_BF_FP_CHANCE, null)) .memtableFlushPeriod(getPropertyInt(CFPropDefs.KW_MEMTABLE_FLUSH_PERIOD, 0)) .defaultTimeToLive(getPropertyInt(CFPropDefs.KW_DEFAULT_TIME_TO_LIVE, CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE)); // CQL2 can have null keyAliases if (keyAlias != null) newCFMD.addColumnDefinition(ColumnDefinition.partitionKeyDef(newCFMD, keyAlias, newCFMD.getKeyValidator(), null)); return newCFMD.rebuild(); } catch (ConfigurationException | SyntaxException e) { throw new InvalidRequestException(e.toString()); } }
Example #21
Source File: AlterTableStatement.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public static void applyPropertiesToCFMetadata(CFMetaData cfm, CFPropDefs cfProps) throws InvalidRequestException, ConfigurationException { if (cfProps.hasProperty(CFPropDefs.KW_COMPACTION_STRATEGY_CLASS)) cfm.compactionStrategyClass(cfProps.compactionStrategyClass); if (cfProps.hasProperty(CFPropDefs.KW_COMPARATOR)) throw new InvalidRequestException("Can't change CF comparator after creation"); if (cfProps.hasProperty(CFPropDefs.KW_COMMENT)) cfm.comment(cfProps.getProperty(CFPropDefs.KW_COMMENT)); if (cfProps.hasProperty(CFPropDefs.KW_DEFAULTVALIDATION)) { try { cfm.defaultValidator(cfProps.getValidator()); } catch (RequestValidationException e) { throw new InvalidRequestException(String.format("Invalid validation type %s", cfProps.getProperty(CFPropDefs.KW_DEFAULTVALIDATION))); } } cfm.readRepairChance(cfProps.getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, cfm.getReadRepairChance())); cfm.dcLocalReadRepairChance(cfProps.getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair())); cfm.gcGraceSeconds(cfProps.getPropertyInt(CFPropDefs.KW_GCGRACESECONDS, cfm.getGcGraceSeconds())); int minCompactionThreshold = cfProps.getPropertyInt(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD, cfm.getMinCompactionThreshold()); int maxCompactionThreshold = cfProps.getPropertyInt(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD, cfm.getMaxCompactionThreshold()); if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0) throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead."); cfm.minCompactionThreshold(minCompactionThreshold); cfm.maxCompactionThreshold(maxCompactionThreshold); cfm.caching(CachingOptions.fromString(cfProps.getPropertyString(CFPropDefs.KW_CACHING, cfm.getCaching().toString()))); cfm.defaultTimeToLive(cfProps.getPropertyInt(CFPropDefs.KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive())); cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(cfProps.getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString()))); cfm.bloomFilterFpChance(cfProps.getPropertyDouble(CFPropDefs.KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance())); cfm.memtableFlushPeriod(cfProps.getPropertyInt(CFPropDefs.KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod())); if (!cfProps.compactionStrategyOptions.isEmpty()) { cfm.compactionStrategyOptions(new HashMap<String, String>()); for (Map.Entry<String, String> entry : cfProps.compactionStrategyOptions.entrySet()) cfm.compactionStrategyOptions.put(entry.getKey(), entry.getValue()); } if (!cfProps.compressionParameters.isEmpty()) { cfm.compressionParameters(CompressionParameters.create(cfProps.compressionParameters)); } }
Example #22
Source File: ConfigHelper.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public static String getOutputCompressionChunkLength(Configuration conf) { return conf.get(OUTPUT_COMPRESSION_CHUNK_LENGTH, String.valueOf(CompressionParameters.DEFAULT_CHUNK_LENGTH)); }
Example #23
Source File: CFPropDefs.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public void validate() throws ConfigurationException, SyntaxException { // Skip validation if the comapction strategy class is already set as it means we've alreayd // prepared (and redoing it would set strategyClass back to null, which we don't want) if (compactionStrategyClass != null) return; validate(keywords, obsoleteKeywords); Map<String, String> compactionOptions = getCompactionOptions(); if (!compactionOptions.isEmpty()) { String strategy = compactionOptions.get(COMPACTION_STRATEGY_CLASS_KEY); if (strategy == null) throw new ConfigurationException("Missing sub-option '" + COMPACTION_STRATEGY_CLASS_KEY + "' for the '" + KW_COMPACTION + "' option."); compactionStrategyClass = CFMetaData.createCompactionStrategy(strategy); compactionOptions.remove(COMPACTION_STRATEGY_CLASS_KEY); CFMetaData.validateCompactionOptions(compactionStrategyClass, compactionOptions); } Map<String, String> compressionOptions = getCompressionOptions(); if (!compressionOptions.isEmpty()) { String sstableCompressionClass = compressionOptions.get(CompressionParameters.SSTABLE_COMPRESSION); if (sstableCompressionClass == null) throw new ConfigurationException("Missing sub-option '" + CompressionParameters.SSTABLE_COMPRESSION + "' for the '" + KW_COMPRESSION + "' option."); Integer chunkLength = CompressionParameters.DEFAULT_CHUNK_LENGTH; if (compressionOptions.containsKey(CompressionParameters.CHUNK_LENGTH_KB)) chunkLength = CompressionParameters.parseChunkLength(compressionOptions.get(CompressionParameters.CHUNK_LENGTH_KB)); Map<String, String> remainingOptions = new HashMap<>(compressionOptions); remainingOptions.remove(CompressionParameters.SSTABLE_COMPRESSION); remainingOptions.remove(CompressionParameters.CHUNK_LENGTH_KB); CompressionParameters cp = new CompressionParameters(sstableCompressionClass, chunkLength, remainingOptions); cp.validate(); } validateMinimumInt(KW_DEFAULT_TIME_TO_LIVE, 0, CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE); Integer minIndexInterval = getInt(KW_MIN_INDEX_INTERVAL, null); Integer maxIndexInterval = getInt(KW_MAX_INDEX_INTERVAL, null); if (minIndexInterval != null && minIndexInterval < 1) throw new ConfigurationException(KW_MIN_INDEX_INTERVAL + " must be greater than 0"); if (maxIndexInterval != null && minIndexInterval != null && maxIndexInterval < minIndexInterval) throw new ConfigurationException(KW_MAX_INDEX_INTERVAL + " must be greater than " + KW_MIN_INDEX_INTERVAL); SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, SpeculativeRetry.RetryType.NONE.name())); }
Example #24
Source File: SSTableSimpleUnsortedWriter.java From stratio-cassandra with Apache License 2.0 | 3 votes |
/** * Create a new buffering writer. * @param directory the directory where to write the sstables * @param partitioner the partitioner * @param keyspace the keyspace name * @param columnFamily the column family name * @param comparator the column family comparator * @param subComparator the column family subComparator or null if not a Super column family. * @param bufferSizeInMB the data size in MB before which a sstable is written and the buffer reseted. This correspond roughly to the written * data size (i.e. the size of the create sstable). The actual size used in memory will be higher (by how much depends on the size of the * columns you add). For 1GB of heap, a 128 bufferSizeInMB is probably a reasonable choice. If you experience OOM, this value should be lowered. */ public SSTableSimpleUnsortedWriter(File directory, IPartitioner partitioner, String keyspace, String columnFamily, AbstractType<?> comparator, AbstractType<?> subComparator, int bufferSizeInMB, CompressionParameters compressParameters) { this(directory, CFMetaData.denseCFMetaData(keyspace, columnFamily, comparator, subComparator).compressionParameters(compressParameters), partitioner, bufferSizeInMB); }
Example #25
Source File: CFMetaData.java From stratio-cassandra with Apache License 2.0 | votes |
public CFMetaData compressionParameters(CompressionParameters prop) {compressionParameters = prop; return this;}