From 98be59ce9ca2cbe9bea87e715ce2a67d7d847f7f Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 30 May 2015 19:02:54 +0200 Subject: [PATCH] full solr xml exports will now be automatically compressed during export. That makes it possible to export a solr xml dump even if disc space is low. --- source/net/yacy/search/index/Fulltext.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java index 81dca80f6..eb36b4458 100644 --- a/source/net/yacy/search/index/Fulltext.java +++ b/source/net/yacy/search/index/Fulltext.java @@ -26,6 +26,7 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.net.MalformedURLException; @@ -40,6 +41,7 @@ import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; +import java.util.zip.GZIPOutputStream; import net.yacy.cora.date.GenericFormatter; import net.yacy.cora.date.ISO8601Formatter; @@ -655,7 +657,9 @@ public final class Fulltext { try { final File parentf = this.f.getParentFile(); if (parentf != null) parentf.mkdirs(); - final PrintWriter pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream(this.f))); + OutputStream os = new FileOutputStream(this.format == 3 ? new File(this.f.getAbsolutePath() + ".gz") : this.f); + if (this.format == 3) os = new GZIPOutputStream(os); + final PrintWriter pw = new PrintWriter(new BufferedOutputStream(os)); if (this.format == 1) { pw.println(""); }