mdedetrich commented on code in PR #2409:
URL: https://github.com/apache/pekko/pull/2409#discussion_r2472235237
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Compression.scala:
##########
@@ -85,4 +87,28 @@ object Compression {
*/
def inflate(maxBytesPerChunk: Int, nowrap: Boolean): Flow[ByteString,
ByteString, NotUsed] =
Flow[ByteString].via(new DeflateDecompressor(maxBytesPerChunk,
nowrap)).named("inflate")
+
+ /**
+ * @since 2.0.0
+ */
+ def zstd: Flow[ByteString, ByteString, NotUsed] =
zstd(Zstd.defaultCompressionLevel())
+
+ /**
+ * Same as [[zstd]] with a custom level and an optional dictionary.
+ * @param level The compression level, must be greater or equal to
[[Zstd.minCompressionLevel]] and less than or equal
+ * to [[Zstd.maxCompressionLevel]]
+ * @param dictionary An optional dictionary that can be used for compression
+ * @since 2.0.0
+ */
+ def zstd(level: Int, dictionary: Option[ZstdDictCompress] = None):
Flow[ByteString, ByteString, NotUsed] = {
+ require(level <= Zstd.maxCompressionLevel() && level >=
Zstd.minCompressionLevel())
+ CompressionUtils.compressorFlow(() => new ZstdCompressor(level,
dictionary))
+ }
+
+ /**
+ * @since 2.0.0
+ */
+ def zstdDecompress(maxBytesPerChunk: Int = MaxBytesPerChunkDefault):
Flow[ByteString, ByteString, NotUsed] =
+ Flow[ByteString].via(new
ZstdDecompressor(maxBytesPerChunk)).named("zstdDecompress")
Review Comment:
Why, its sitting in the same spot that all other compression flows like
deflate or gzip do? If we decide to put this in another artifact then sure, but
that is another debate.
Either we treat zstd as a standard widely adopted industry compression
algorithm (which it is) in which this PR has it in the appropriate place or we
put it in another artifact and if so we should have the discussion then.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]