clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1532291 - /clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
Date Tue, 15 Oct 2013 11:36:07 GMT
Author: reto
Date: Tue Oct 15 11:36:07 2013
New Revision: 1532291

URL: http://svn.apache.org/r1532291
Log:
CLEREZZA-832: exapnding to temporary file instead of byte array

Modified:
    clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java

Modified: clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java?rev=1532291&r1=1532290&r2=1532291&view=diff
==============================================================================
--- clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
(original)
+++ clerezza/trunk/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Restorer.java
Tue Oct 15 11:36:07 2013
@@ -21,8 +21,12 @@ package org.apache.clerezza.rdf.web.core
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -80,14 +84,27 @@ public class Restorer {
             if (entry.isDirectory()) {
                 folder = entryName;
             } else {
+                File tempFile = File.createTempFile("graph", "data");
+                OutputStream fos = new FileOutputStream(tempFile);
+                
+                int count;
+                byte buffer[] = new byte[2048];
+                while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
+                    fos.write(buffer, 0, count);
+                }
+                fos.close();
+                InputStream serializedGraph = new FileInputStream(tempFile);
+                /*
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
                 int count;
                 byte buffer[] = new byte[2048];
                 while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
                     baos.write(buffer, 0, count);
                 }
+                baos.close();
                 ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
                         baos.toByteArray());
+                */
                 if (entryName.equals("triplecollections.nt")) {
                     metaGraph = parser.parse(serializedGraph,
                             SupportedFormat.N_TRIPLE, null);
@@ -96,8 +113,7 @@ public class Restorer {
                             SupportedFormat.N_TRIPLE, null);
                     extractedTc.put(entryName, deserializedGraph);
                 }
-                baos.flush();
-                baos.close();
+                serializedGraph.close();
             }
         }
         if (metaGraph == null) {



Mime
View raw message