From fed34b8df2b19ba996ef810f44d5666437c90fb7 Mon Sep 17 00:00:00 2001 From: Piotr Szarmanski Date: Fri, 25 Aug 2023 19:09:50 +0200 Subject: Add the parallel encoder. --- src/backend.lisp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/backend.lisp') diff --git a/src/backend.lisp b/src/backend.lisp index d2b81b2..8571e66 100644 --- a/src/backend.lisp +++ b/src/backend.lisp @@ -22,6 +22,9 @@ (defclass decoding-backend () ((fetch-function :type function))) +(defclass p/encoding-backend () + ()) + (defgeneric fetch-data (read-capability backend &key &allow-other-keys) (:documentation "Using the BACKEND, return a stream that decodes the provided READ-CAPABILITY @@ -58,3 +61,21 @@ size less than 16kib. It should be set either to 1024b or 32kib.")) 1kib) output-function :secret secret))) + +(defgeneric p/store-data (input backend &key secret block-size threads) + (:documentation "Like store-data but parallel. lparallel:*kernel* has to be bound before +calling.")) + +(defmethod p/store-data (input (backend p/encoding-backend) + &key (secret null-secret) (block-size 32kib) &allow-other-keys) + (with-slots (output-function) backend + (p/eris-encode input + (if (> (etypecase input + (pathname (file-size input)) + (file-stream (file-length input)) + (vector (length input)) + (t block-size)) + 16384) + 32kib + 1kib) + output-function :secret secret))) -- cgit v1.2.3