项目作者: nwtgck

项目描述 :
Zstandard compression for Akka Stream
高级语言: Scala
项目地址: git://github.com/nwtgck/akka-stream-zstd.git
创建时间: 2018-07-24T05:27:44Z
项目社区:https://github.com/nwtgck/akka-stream-zstd

开源协议:MIT License

下载


akka-stream-zstd

Build Status Coverage Status

Zstandard for Akka Stream

Installation

Add the following lines to your build.sbt.

  1. // Add dependency of `akka-stream-zstd.git` on GitHub
  2. dependsOn(RootProject(uri("https://github.com/nwtgck/akka-stream-zstd.git#v0.1.5")))

Example of compression

Here is an example to compress and store into a file

  1. source
  2. // Compress
  3. .via(ZstdFlow.compress())
  4. // Store to file
  5. .runWith(FileIO.toPath(filePath))

Full example

Example of decompression

Here is an example to decompress from a stored file and convert into a String.

  1. FileIO.fromPath(filePath)
  2. // Decompress
  3. .via(ZstdFlow.decompress())
  4. // Concatenate into one ByteString
  5. .runWith(Sink.fold(ByteString.empty)(_ ++ _))
  6. // Convert ByteString to String
  7. .map(_.utf8String)

Full example

Example repository

Here is a full example.