penpot/backend/src/uxbox/util/snappy.clj
Andrey Antukh e9b00339a5 🚧 Major refactor of backend code.
Relevant changes:

- ring -> vertx
- suricatta -> vertx-pgsql
- emails improvements
- logging
- hybrid sync/async -> full async execution model
- database layout refactor
2019-11-18 12:35:41 +01:00

39 lines
1.2 KiB
Clojure

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
(ns uxbox.util.snappy
"A lightweight abstraction layer for snappy compression library."
(:import
java.io.ByteArrayInputStream
java.io.ByteArrayOutputStream
java.io.InputStream
java.io.OutputStream
org.xerial.snappy.Snappy
org.xerial.snappy.SnappyFramedInputStream
org.xerial.snappy.SnappyFramedOutputStream))
(defn compress
"Compress data unsing snappy compression algorithm."
[^bytes data]
(Snappy/compress data))
(defn uncompress
"Uncompress data using snappy compression algorithm."
[^bytes data]
(Snappy/uncompress data))
(defn input-stream
"Create a Snappy framed input stream."
[^InputStream istream]
(SnappyFramedInputStream. istream))
(defn output-stream
"Create a Snappy framed output stream."
([ostream]
(output-stream ostream nil))
([^OutputStream ostream {:keys [block-size] :or {block-size 65536}}]
(SnappyFramedOutputStream. ostream (int block-size) 1.0)))