MCPcopy Index your code
hub / github.com/apache/orc / ZstdCodec

Class ZstdCodec

java/core/src/java/org/apache/orc/impl/ZstdCodec.java:29–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27import java.nio.ByteBuffer;
28
29public class ZstdCodec implements CompressionCodec, DirectDecompressionCodec {
30 private ZstdOptions zstdOptions = null;
31 private ZstdCompressCtx zstdCompressCtx = null;
32
33 public ZstdCodec(int level, int windowLog, int strategy) {
34 this.zstdOptions = new ZstdOptions(level, windowLog, strategy);
35 }
36
37 public ZstdCodec() {
38 this(3, 0, 0);
39 }
40
41 public ZstdOptions getZstdOptions() {
42 return zstdOptions;
43 }
44
45 // Thread local buffer
46 private static final ThreadLocal<byte[]> threadBuffer =
47 ThreadLocal.withInitial(() -> null);
48
49 protected static byte[] getBuffer(int size) {
50 byte[] result = threadBuffer.get();
51 if (result == null || result.length < size || result.length > size * 2) {
52 result = new byte[size];
53 threadBuffer.set(result);
54 }
55 return result;
56 }
57
58 static class ZstdOptions implements Options {
59 private int level;
60 private int windowLog;
61 private int strategy;
62
63 ZstdOptions(int level, int windowLog, int strategy) {
64 this.level = level;
65 this.windowLog = windowLog;
66 this.strategy = strategy;
67 }
68
69 @Override
70 public ZstdOptions copy() {
71 return new ZstdOptions(level, windowLog, strategy);
72 }
73
74 @Override
75 public Options setSpeed(SpeedModifier newValue) {
76 return this;
77 }
78
79 /**
80 * Sets the Zstandard long mode maximum back-reference distance, expressed
81 * as a power of 2.
82 * <p>
83 * The value must be between ZSTD_WINDOWLOG_MIN (10) and ZSTD_WINDOWLOG_MAX
84 * (30 and 31 on 32/64-bit architectures, respectively).
85 * <p>
86 * A value of 0 is a special value indicating to use the default

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected