@@ -20,6 +20,8 @@ public class Provider<T extends AbstractNode> implements Comparable<Provider<?>>
2020
2121 private static final Logger log = LoggerFactory .getLogger (Provider .class );
2222
23+ public static boolean ENABLE_COMPRESSION = true ;
24+
2325 protected Model model ;
2426 protected Integer id ;
2527
@@ -129,13 +131,20 @@ public synchronized void suspend(SuspensionMode sm) {
129131 public void save () {
130132 if (n .modified ) {
131133 ByteArrayOutputStream baos = new ByteArrayOutputStream ();
132- try (
133- GZIPOutputStream gzipos = new GZIPOutputStream (baos );
134- DataOutputStream dos = new DataOutputStream (gzipos )) {
135-
136- n .write (dos );
137- } catch (IOException e ) {
138- throw new RuntimeException (e );
134+ if (ENABLE_COMPRESSION ) {
135+ try (
136+ GZIPOutputStream gzipos = new GZIPOutputStream (baos );
137+ DataOutputStream dos = new DataOutputStream (gzipos )) {
138+ n .write (dos );
139+ } catch (IOException e ) {
140+ throw new RuntimeException (e );
141+ }
142+ } else {
143+ try (DataOutputStream dos = new DataOutputStream (baos )) {
144+ n .write (dos );
145+ } catch (IOException e ) {
146+ throw new RuntimeException (e );
147+ }
139148 }
140149
141150 model .suspensionHook .store (id , n .getLabel (), n .getModelLabels (), n .isNeuron (), baos .toByteArray ());
@@ -155,12 +164,20 @@ private void reactivate() {
155164 }
156165
157166 ByteArrayInputStream bais = new ByteArrayInputStream (data );
158- try (
159- GZIPInputStream gzipis = new GZIPInputStream (bais );
160- DataInputStream dis = new DataInputStream (gzipis )) {
161- n = (T ) AbstractNode .read (dis , this );
162- } catch (IOException e ) {
163- throw new RuntimeException (e );
167+ if (ENABLE_COMPRESSION ) {
168+ try (
169+ GZIPInputStream gzipis = new GZIPInputStream (bais );
170+ DataInputStream dis = new DataInputStream (gzipis )) {
171+ n = (T ) AbstractNode .read (dis , this );
172+ } catch (IOException e ) {
173+ throw new RuntimeException (e );
174+ }
175+ } else {
176+ try (DataInputStream dis = new DataInputStream (bais )) {
177+ n = (T ) AbstractNode .read (dis , this );
178+ } catch (IOException e ) {
179+ throw new RuntimeException (e );
180+ }
164181 }
165182
166183 n .reactivate ();
0 commit comments