handle ZStd streams

This commit is contained in:
James Seibel
2025-11-24 14:28:06 -06:00
parent c8c9df3a34
commit bfd6efb4a4
4 changed files with 23 additions and 6 deletions
@@ -572,7 +572,6 @@ public class FullDataSourceV2Repo extends AbstractDhRepo<Long, FullDataSourceV2D
EDhApiDataCompressionMode compressionModeEnum = EDhApiDataCompressionMode.getFromValue(compressionModeEnumValue);
// decompress the data
try
{
ByteArrayList byteArrayList = new ByteArrayList();
@@ -79,27 +79,31 @@ public class DhDataInputStream extends DataInputStream
{
super(warpStream(stream, compressionMode));
}
@SuppressWarnings("deprecation")
private static InputStream warpStream(ByteArrayInputStream stream, EDhApiDataCompressionMode compressionMode) throws IOException
{
try
{
switch (compressionMode)
{
case Z_STD:
// ZStd compression should be handled before this point
// just return the stream
case UNCOMPRESSED:
return stream;
case LZ4:
return new LZ4FrameInputStream(stream);
case Z_STD:
// ZStd compression should be handled before this point
// just return the stream
return stream;
case LZMA2:
// using an array cache significantly reduces GC pressure
ResettableArrayCache arrayCache = LZMA_RESETTABLE_ARRAY_CACHE_GETTER.get();
arrayCache.reset();
// Note: all LZMA/XZ compressors can be decompressed using this same InputStream
return new XZInputStream(stream, arrayCache);
case Z_STD_STREAM: // deprecated, only used for legacy support
return new ZstdInputStream(stream, RecyclingBufferPool.INSTANCE);
default:
throw new IllegalArgumentException("No compressor defined for [" + compressionMode + "]");
}
@@ -66,6 +66,7 @@ public class DhDataOutputStream extends DataOutputStream
this.outputByteArray = outputByteArray;
this.compressionMode = compressionMode;
}
@SuppressWarnings("deprecation")
private static OutputStream warpStream(ByteArrayOutputStream stream, EDhApiDataCompressionMode compressionMode) throws IOException
{
try
@@ -96,6 +97,9 @@ public class DhDataOutputStream extends DataOutputStream
return new XZOutputStream(stream, new LZMA2Options(3),
XZ.CHECK_CRC64, arrayCache);
case Z_STD_STREAM: // deprecated, only used for legacy support
throw new UnsupportedOperationException("Z_Std streams is deprecated and shouldn't be used for encoding. The faster block encoding format should be used instead.");
default:
throw new IllegalArgumentException("No compressor defined for ["+compressionMode+"]");
}