cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dineshjoshi <>
Subject [GitHub] cassandra pull request #292: provide ZSTD compression support to cassandra (...
Date Thu, 13 Dec 2018 00:40:05 GMT
Github user dineshjoshi commented on a diff in the pull request:
    --- Diff: src/java/org/apache/cassandra/io/compress/ ---
    @@ -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
    + *
    + *
    + *
    + * 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.
    + */
    +import java.nio.ByteBuffer;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Set;
    +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;
    --- End diff --
    From my brief reading of the JNI Bindings it seems that zstd-jni uses `ZSTD_compress`
and not `ZSTD_compressCCtx`. The latter allows you to pass in a context which would've been
more efficient. For now, I think it would be ok to simply pass in the compression level. The
only value of keeping multiple compressor objects around is to retain the `CompressionParams`.
It would be useful to have a caching factory to avoid creating multiple objects with the same
compression params.
    As far as thread safety goes, the JNI Code looks thread safe specifically compress and
decompress methods. As pointed out earlier they create and destroy the Compression Context
on each invocation which is memory unfriendly. So, although the zstd benchmarks may look great,
I am not so sure about this JNI binding.
    We should definitely add a JMH Benchmark for zstd.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message