diff options
author | Henning Baldersheim <balder@verizonmedia.com> | 2020-03-08 16:51:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@verizonmedia.com> | 2020-03-08 16:51:08 +0000 |
commit | 5337561c2c1ebdaca4c0f84aeee6519f82117138 (patch) | |
tree | 8e4b8279c913886dca7612ebc624dcaf05e55d2a /searchlib/src/main | |
parent | 014f5b6f712b004fc1c3956db100ad9f6cbf01fc (diff) |
Since resolving instances are error phrone we need to do it once.
Diffstat (limited to 'searchlib/src/main')
-rw-r--r-- | searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/NormalSketch.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/NormalSketch.java b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/NormalSketch.java index 37d5dd345ad..d32349906ee 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/NormalSketch.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/aggregation/hll/NormalSketch.java @@ -22,6 +22,7 @@ public class NormalSketch extends Sketch<NormalSketch> { private final byte[] data; private final int bucketMask; + private static final LZ4Factory lz4Factory = LZ4Factory.safeInstance(); /** * Create a sketch with the default precision given by {@link HyperLogLog#DEFAULT_PRECISION}. @@ -100,7 +101,7 @@ public class NormalSketch extends Sketch<NormalSketch> { super.onSerialize(buf); buf.putInt(null, data.length); try { - LZ4Compressor c = LZ4Factory.safeInstance().highCompressor(); + LZ4Compressor c = lz4Factory.highCompressor(); byte[] compressedData = new byte[data.length]; int compressedSize = c.compress(data, compressedData); serializeDataArray(compressedData, compressedSize, buf); @@ -129,7 +130,7 @@ public class NormalSketch extends Sketch<NormalSketch> { if (length == compressedLength) { deserializeDataArray(data, length, buf); } else { - LZ4FastDecompressor c = LZ4Factory.safeInstance().fastDecompressor(); + LZ4FastDecompressor c = lz4Factory.fastDecompressor(); byte[] compressedData = buf.getBytes(null, compressedLength); c.decompress(compressedData, data); } |