cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sushmaad <...@git.apache.org>
Subject [GitHub] cassandra pull request #292: provide ZSTD compression support to cassandra (...
Date Wed, 12 Dec 2018 06:00:46 GMT
Github user sushmaad commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/292#discussion_r240890567
  
    --- Diff: src/java/org/apache/cassandra/io/compress/ZSTDCompressor.java ---
    @@ -0,0 +1,138 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.cassandra.io.compress;
    +
    +import java.io.IOException;
    +import java.nio.ByteBuffer;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import com.google.common.annotations.VisibleForTesting;
    +import com.github.luben.zstd.Zstd;
    +
    +public class ZSTDCompressor implements ICompressor
    +{
    +    public static final int FAST_COMPRESSION = 1; // fastest compression time
    +    public static final int DEFAULT_LEVEL = 3;
    +    public static final int BEST_COMPRESSION = 22;// very good compression ratio
    +    private static final ZSTDCompressor instance = new ZSTDCompressor();
    +    private static final String COMPRESSION_LEVEL_OPTION_NAME = "compression_level";
    +    @VisibleForTesting
    +    protected static final int compressionLevel = DEFAULT_LEVEL;
    +
    +    public static ZSTDCompressor create(Map<String, String> compressionOptions)
    +    {
    +        validateCompressionLevel(parseCompressionLevelOption(compressionOptions));
    +        return instance;
    +    }
    +
    +    private static void validateCompressionLevel(int compressionLevel)
    +    {
    +        if (compressionLevel < FAST_COMPRESSION || compressionLevel > BEST_COMPRESSION)
    --- End diff --
    
    Zstd accepts integer levels from negative infinity up to 22. Levels 1 to 22 are normal
levels, ranging from fastest at level 1 to highest compression ratio at level 22. 0 selects
the default compression level (which is level 3). Negative levels are a new addition, and
are even faster than level 1, getting faster the more negative you go. 
    Definitely negative compression levels can be supported here.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message