https://issues.apache.org/bugzilla/show_bug.cgi?id=51961

             Bug #: 51961
           Summary: [Patch] SXSSF : Compress the temporary xml file
           Product: POI
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SXSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


The SXSSF temp  xml file is grows to a very large size. e.g. for a 20 MB 
csv data the size of the temp xml file become few GB large. In order to 
reduce this I have created a path and tested it. 

Request for the review and application of the same to the. 
I have changed the extension of the temp file from xml to gz, which is 
another cleanliness factor



>From 3e95b1880a04657ec93e5626720b1d40b5487ee4 Mon Sep 17 00:00:00 2001
From: Santosh <[email protected]>
Date: Tue, 4 Oct 2011 12:11:23 +0530
Subject: [PATCH] Compress the temporary xml file

---
 .../org/apache/poi/xssf/streaming/SXSSFSheet.java  |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java 
b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
index 8c1b998..567c9e8 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
@@ -22,6 +22,8 @@ import java.util.Iterator;
 import java.util.TreeMap;
 import java.util.Map;

+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellReference;

@@ -1284,9 +1286,9 @@ public class SXSSFSheet implements Sheet, Cloneable

         public SheetDataWriter() throws IOException 
         {
-            _fd = File.createTempFile("poi-sxxsf-sheet", ".xml");
+            _fd = File.createTempFile("poi-sxxsf-sheet-xml", ".gz");
             _fd.deleteOnExit();
-            _out = new BufferedWriter(new FileWriter(_fd));
+            _out = new OutputStreamWriter(new GZIPOutputStream (new 
FileOutputStream(_fd)));
         }
         public int getNumberOfFlushedRows()
         {
@@ -1308,7 +1310,8 @@ public class SXSSFSheet implements Sheet, Cloneable
         {
             _out.flush();
             _out.close();
-            return new FileInputStream(_fd);
+
+            return new GZIPInputStream ( new FileInputStream(_fd));
         }

         /**
-- 
1.7.6.msysgit.0

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to