forked from opensearch-project/custom-codecs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQatLz499Codec.java
94 lines (81 loc) · 2.86 KB
/
QatLz499Codec.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.index.codec.customcodecs;
import org.apache.logging.log4j.Logger;
import org.opensearch.common.settings.Setting;
import org.opensearch.index.codec.CodecAliases;
import org.opensearch.index.codec.CodecSettings;
import org.opensearch.index.engine.EngineConfig;
import org.opensearch.index.mapper.MapperService;
import java.util.Set;
import java.util.function.Supplier;
import com.intel.qat.QatZipper;
/**
* QatLz499Codec provides an LZ4 compressor using the <a
* href="https://github.com/intel/qat-java">qat-java</a> library.
*/
public class QatLz499Codec extends Lucene99QatCodec implements CodecSettings, CodecAliases {
/** Creates a new QatLz499Codec instance with the default compression level. */
public QatLz499Codec() {
this(DEFAULT_COMPRESSION_LEVEL);
}
/**
* Creates a new QatLz499Codec instance.
*
* @param compressionLevel The compression level.
*/
public QatLz499Codec(int compressionLevel) {
super(Mode.QAT_LZ4, compressionLevel);
}
/**
* Creates a new QatLz499Codec instance with the default compression level.
*
* @param compressionLevel The compression level.
* @param supplier supplier for QAT acceleration mode.
*/
public QatLz499Codec(int compressionLevel, Supplier<QatZipper.Mode> supplier) {
super(Mode.QAT_LZ4, compressionLevel, supplier);
}
/**
* Creates a new QatLz499Codec instance.
*
* @param mapperService The mapper service.
* @param logger The logger.
* @param compressionLevel The compression level.
*/
public QatLz499Codec(MapperService mapperService, Logger logger, int compressionLevel) {
super(Mode.QAT_LZ4, compressionLevel, mapperService, logger);
}
/**
* Creates a new QatLz499Codec instance.
*
* @param mapperService The mapper service.
* @param logger The logger.
* @param compressionLevel The compression level.
* @param supplier supplier for QAT acceleration mode.
*/
public QatLz499Codec(MapperService mapperService, Logger logger, int compressionLevel, Supplier<QatZipper.Mode> supplier) {
super(Mode.QAT_LZ4, compressionLevel, mapperService, logger, supplier);
}
/** The name for this codec. */
@Override
public String toString() {
return getClass().getSimpleName();
}
@Override
public boolean supports(Setting<?> setting) {
return setting.equals(EngineConfig.INDEX_CODEC_COMPRESSION_LEVEL_SETTING);
}
@Override
public Set<String> aliases() {
if (!QatZipperFactory.isQatAvailable()) {
return Set.of();
}
return Mode.QAT_LZ4.getAliases();
}
}