From d4853f52323153f4ae989f93358ca1e7996089aa Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Wed, 18 Jul 2018 15:29:55 -0700 Subject: [PATCH] Change how trees are saved so that they are compressed. --- src/main/java/ca/joeltherrien/randomforest/DataLoader.java | 2 +- .../java/ca/joeltherrien/randomforest/tree/ForestTrainer.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/ca/joeltherrien/randomforest/DataLoader.java b/src/main/java/ca/joeltherrien/randomforest/DataLoader.java index 09d5e96..0d999cb 100644 --- a/src/main/java/ca/joeltherrien/randomforest/DataLoader.java +++ b/src/main/java/ca/joeltherrien/randomforest/DataLoader.java @@ -66,7 +66,7 @@ public class DataLoader { final List> treeList = new ArrayList<>(treeFileList.size()); for(final File treeFile : treeFileList){ - final ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(treeFile)); + final ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(new FileInputStream(treeFile))); final Tree tree = (Tree) inputStream.readObject(); diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java index fcdd111..7896519 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java @@ -18,6 +18,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.zip.GZIPOutputStream; @Builder @AllArgsConstructor(access=AccessLevel.PRIVATE) @@ -163,7 +164,7 @@ public class ForestTrainer { public void saveTree(final Tree tree, String name) throws IOException { final String filename = saveTreeLocation + "/" + name; - final ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(filename)); + final ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(filename))); outputStream.writeObject(tree);