Search in sources :

Example 1 with ZstdOutputStreamNoFinalizer

use of com.github.luben.zstd.ZstdOutputStreamNoFinalizer in project presto by prestodb.

the class PrestoSparkUtils method serializeZstdCompressed.

public static <T> byte[] serializeZstdCompressed(Codec<T> codec, T instance) {
    try (ByteArrayOutputStream output = new ByteArrayOutputStream();
        ZstdOutputStreamNoFinalizer zstdOutput = new ZstdOutputStreamNoFinalizer(output)) {
        codec.writeBytes(zstdOutput, instance);
        zstdOutput.close();
        output.close();
        return output.toByteArray();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : ZstdOutputStreamNoFinalizer(com.github.luben.zstd.ZstdOutputStreamNoFinalizer) UncheckedIOException(java.io.UncheckedIOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 2 with ZstdOutputStreamNoFinalizer

use of com.github.luben.zstd.ZstdOutputStreamNoFinalizer in project presto by prestodb.

the class HiveUtil method serializeZstdCompressed.

public static <T> byte[] serializeZstdCompressed(Codec<T> codec, T instance) {
    try (ByteArrayOutputStream output = new ByteArrayOutputStream();
        ZstdOutputStreamNoFinalizer zstdOutput = new ZstdOutputStreamNoFinalizer(output)) {
        codec.writeBytes(zstdOutput, instance);
        zstdOutput.close();
        output.close();
        return output.toByteArray();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : ZstdOutputStreamNoFinalizer(com.github.luben.zstd.ZstdOutputStreamNoFinalizer) UncheckedIOException(java.io.UncheckedIOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Aggregations

ZstdOutputStreamNoFinalizer (com.github.luben.zstd.ZstdOutputStreamNoFinalizer)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2