You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/01/24 15:30:19 UTC

git commit: work around a bug in CompressorStreamFactory (COMPRESS-259)

Updated Branches:
  refs/heads/develop 74900e0eb -> 2eaf46f9c


work around a bug in CompressorStreamFactory (COMPRESS-259)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2eaf46f9
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2eaf46f9
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2eaf46f9

Branch: refs/heads/develop
Commit: 2eaf46f9c9872eaea9c93a2374b2bdefe79b3a95
Parents: 74900e0
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Jan 24 15:30:14 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Jan 24 15:30:14 2014 +0100

----------------------------------------------------------------------
 .../apache/marmotta/loader/core/MarmottaLoader.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/2eaf46f9/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
index dd9af5a..4ea5f5c 100644
--- a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
+++ b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
@@ -6,7 +6,9 @@ import com.google.common.collect.Sets;
 import org.apache.commons.cli.*;
 import org.apache.commons.compress.compressors.CompressorException;
 import org.apache.commons.compress.compressors.CompressorStreamFactory;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.compressors.bzip2.BZip2Utils;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipUtils;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.MapConfiguration;
@@ -151,6 +153,9 @@ public class MarmottaLoader {
     public void loadFile(File file, LoaderHandler handler, RDFFormat format, String compression) throws RDFParseException, IOException {
         log.info("loading file {} ...", file);
 
+        CompressorStreamFactory cf = new CompressorStreamFactory();
+        cf.setDecompressConcatenated(true);
+
         // detect the file compression
         String detectedCompression = detectCompression(file);
         if(compression == null) {
@@ -187,9 +192,16 @@ public class MarmottaLoader {
         InputStream fin = new BufferedInputStream(new FileInputStream(file));
         try {
             if(compression != null) {
-                in = new CompressorStreamFactory().createCompressorInputStream(compression, fin);
+                if (CompressorStreamFactory.GZIP.equalsIgnoreCase(compression)) {
+                    in = new GzipCompressorInputStream(fin,true);
+                } else if (CompressorStreamFactory.BZIP2.equalsIgnoreCase(compression)) {
+                    in = new BZip2CompressorInputStream(fin, true);
+                } else {
+                    // does not honour decompressConcatenated
+                    in = cf.createCompressorInputStream(compression, fin);
+                }
             } else {
-                in = new CompressorStreamFactory().createCompressorInputStream(fin);
+                in = cf.createCompressorInputStream(fin);
             }
         } catch (CompressorException ex) {
             log.info("no compression detected, using plain input stream");