本文整理汇总了Java中org.apache.cassandra.io.compress.CompressionParameters类的典型用法代码示例。如果您正苦于以下问题:Java CompressionParameters类的具体用法?Java CompressionParameters怎么用?Java CompressionParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompressionParameters类属于org.apache.cassandra.io.compress包,在下文中一共展示了CompressionParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreateTableStatement
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
}
示例2: CreateTableStatement
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
public CreateTableStatement(CFName name, CFPropDefs properties, boolean ifNotExists)
{
super(name);
this.properties = properties;
this.ifNotExists = ifNotExists;
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);
}
}
示例3: applyToCFMetadata
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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()));
cfm.replicateOnWrite(getBoolean(KW_REPLICATEONWRITE, cfm.getReplicateOnWrite()));
cfm.minCompactionThreshold(toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold()));
cfm.maxCompactionThreshold(toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold()));
cfm.caching(CFMetaData.Caching.fromString(getString(KW_CACHING, cfm.getCaching().toString())));
cfm.populateIoCacheOnFlush(getBoolean(KW_POPULATE_IO_CACHE_ON_FLUSH, cfm.populateIoCacheOnFlush()));
if (compactionStrategyClass != null)
{
cfm.compactionStrategyClass(compactionStrategyClass);
cfm.compactionStrategyOptions(new HashMap<String, String>(getCompactionOptions()));
}
cfm.bloomFilterFpChance(getDouble(KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance()));
if (!getCompressionOptions().isEmpty())
cfm.compressionParameters(CompressionParameters.create(getCompressionOptions()));
}
示例4: CreateColumnFamilyStatement
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
public CreateColumnFamilyStatement(CFName name, CFPropDefs properties)
{
super(name);
this.properties = properties;
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);
}
}
示例5: writeHeader
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
}
示例6: applyToCFMetadata
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
示例7: getOutputCompressionParamaters
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
}
示例8: setCompressionParameters
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
public void setCompressionParameters(Map<String,String> opts)
{
try
{
metadata.compressionParameters = CompressionParameters.create(opts);
}
catch (ConfigurationException e)
{
throw new IllegalArgumentException(e.getMessage());
}
}
示例9: applyImplicitDefaults
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
/** 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));
}
}
示例10: serialize
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
示例11: deserialize
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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);
}
示例12: serializedSize
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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;
}
示例13: SSTableSimpleUnsortedWriter
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
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));
}
示例14: open
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
public static CompressedSequentialWriter open(String dataFilePath,
String offsetsPath,
CompressionParameters parameters,
MetadataCollector sstableMetadataCollector)
{
return new CompressedSequentialWriter(new File(dataFilePath), offsetsPath, parameters, sstableMetadataCollector);
}
示例15: useCompression
import org.apache.cassandra.io.compress.CompressionParameters; //导入依赖的package包/类
private static void useCompression(List<KSMetaData> schema)
{
for (KSMetaData ksm : schema)
{
for (CFMetaData cfm : ksm.cfMetaData().values())
{
cfm.compressionParameters(new CompressionParameters(SnappyCompressor.instance));
}
}
}