001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.io.compress.zstd; 019 020import org.apache.hadoop.conf.Configuration; 021import org.apache.hadoop.fs.CommonConfigurationKeys; 022import org.apache.hadoop.hbase.HBaseConfiguration; 023import org.apache.hadoop.hbase.io.compress.CompressionTestBase; 024import org.apache.hadoop.hbase.testclassification.SmallTests; 025import org.junit.jupiter.api.Tag; 026import org.junit.jupiter.api.Test; 027 028@Tag(SmallTests.TAG) 029public class TestZstdCodec extends CompressionTestBase { 030 031 @Test 032 public void testZstdCodecSmall() throws Exception { 033 codecSmallTest(new ZstdCodec()); 034 } 035 036 @Test 037 public void testZstdCodecLarge() throws Exception { 038 codecLargeTest(new ZstdCodec(), 1.1); // poor compressability 039 codecLargeTest(new ZstdCodec(), 2); 040 codecLargeTest(new ZstdCodec(), 10); // very high compressability 041 } 042 043 @Test 044 public void testZstdCodecVeryLarge() throws Exception { 045 Configuration conf = HBaseConfiguration.create(); 046 // ZStandard levels range from 1 to 22. 047 // Level 22 might take up to a minute to complete. 3 is the Hadoop default, and will be fast. 048 conf.setInt(CommonConfigurationKeys.IO_COMPRESSION_CODEC_ZSTD_LEVEL_KEY, 3); 049 ZstdCodec codec = new ZstdCodec(); 050 codec.setConf(conf); 051 codecVeryLargeTest(codec, 3); // like text 052 } 053}