-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Read an large file (saved in several blobs) sequentially
PostPosted: Thu Jan 30, 2014 9:19 am 
Newbie

Joined: Thu Oct 13, 2011 10:32 am
Posts: 3
I need to process big Excel files. My problem is heap space especially with XLS format. I need to retrieve the file from the database in chuncks.

So far I have the file in the database in chunks of 40kb. I have an Import table (storing general information related to the import, for instance start and end time, data type etc.) and an ImportData table (containing the chunks of data as blobs). I have a one to many relation between Import and ImportData:

Code:
<hibernate-mapping>   
<class name="com.company.import.pojos.Import table="IMPORT_TABLE">
    <id name="id" type="integer">
      <column name="ID" />
      <generator class="some.id.generator.IdGenerator"></generator>
    </id>

    <property name="startTime" type="timestamp">
      <column name="START" />
    </property>

    <property name="endTime" type="timestamp">
      <column name="END" />
    </property>

    <property lazy="false" name="datatzpe" type="com.company.import.enums.ImportDataType">
      <column name="DATATYPE" />
    </property>

    <bag name="importDataList" table="IMPORT_DATA" lazy="true" cascade="all" inverse="false">
      <key column="IMPORT_TABLE_ID"/>
      <one-to-many class="com.company.import.pojos.ImportData"/>
    </bag>

  </class>
</hibernate-mapping>


<hibernate-mapping>   <class name="com.company.import.pojos.ImportData" table="IMPORT_DATA">

    <id name="id" type="integer">
      <column name="ID" />
      <generator class="some.id.generator.IdGenerator"></generator>
    </id>

    <property name="importTableID" type="integer">
      <column name="IMPORT_TABLE_ID" />
    </property>

    <property name="data" type="binary">
      <column name="DATA" />
    </property>

    <property name="order" type="integer">
      <column name="ORDER" />
    </property>   </class>
</hibernate-mapping>


I use Hibernate (4.2.3.Final), but even lazy loading in not an option because then I will have the whole list of ImportData objects in memory which is why I get an OutOfMemoryError and I want to avoid that.

Providing more memory is not an option (the application runs on a container that runs other applications as well, and several users might process files at the same time so the heaps space problem will eventually happen), therefore I am looking for a way to always read the next chunk of data and provide it to the stream that is given to the Aspose API.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.