Skip to content

Commit 67acb45

Browse files
made compression optional
1 parent 542c136 commit 67acb45

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>network.aika</groupId>
66
<artifactId>aika</artifactId>
77
<packaging>jar</packaging>
8-
<version>1.4.14</version>
8+
<version>1.4.15</version>
99
<name>aika</name>
1010
<url>https://aika.network</url>
1111
<description>An Artificial Intelligence for Knowledge Acquisition</description>
@@ -30,7 +30,7 @@
3030
<url>https://github.com/aika-algorithm/aika</url>
3131
<connection>scm:git:git://github.com/aika-algorithm/aika.git</connection>
3232
<developerConnection>scm:git:[email protected]:aika-algorithm/aika.git</developerConnection>
33-
<tag>aika-1.4.13</tag>
33+
<tag>aika-1.4.15</tag>
3434
</scm>
3535

3636

src/main/java/network/aika/Provider.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)