Jump to content
We've recently updated our Privacy Statement, available here ×

Performance problem on filling


pedro.riky

Recommended Posts

Hi all

i have a performance problem on filling.

I use a JRXmlDataSource and i have data type like this:

 

  <dettaglio>
            <cod-pubblicazione>6322</cod-pubblicazione>
            <cped>8000824</cped>
            <titolo>Band. cucina moderna</titolo>
            <copertina>90914</copertina>
            <prezzo-lordo>1,00 </prezzo-lordo>
            <copie>462</copie>
            <peso-copie>191,73 </peso-copie>
            <sconto-editore>23,90 </sconto-editore>
            <prezzo-netto>1,60 </prezzo-netto>
            <totale>739,20 </totale>
        </dettaglio>

 

 

i have 192 detail like this and the fill operation tke 5 Minutes to fill it!!

What did i do wrong?

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

I had a similar problem. The parser I was using to parse the xml documents (I guess it was dom4j) was very slow and it was always taking a few minutes to gerenate the report. After some discussion, we decided to change the parser and use XStream to parse the xml document. With the new parser the improvement was really imporant. Reports that were taking more than 5 minutes for the gerenration were finished in less than 10 secods. I remommend you to use a better parser and XStream is a good, easy and fast option

Link to comment
Share on other sites

  • 2 months later...

 Hi am i late?

i use 

 


 
				document = JRXmlUtils.parse(arrayInputStream);
				parameter.put(
					JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT,
					document);
				jasperPrintMan = JasperFillManager.fillReport(xsl, parameter);

I follow the code and i see thath is JasperFillManager that take few minutes to fill.

how can i change the xml parser?

 

Link to comment
Share on other sites

 Thanks for the answer.

My code is :

//blobMan is my byte[] xml data

ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(blobMan);
				Document document = JRXmlUtils.parse(arrayInputStream);
				parameter.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT,document);

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
	ByteArrayInputStream bin = 	JasperCompileManager.compileReportToStream(inputStream,byteArrayOutputStream);
 

jasperPrintMan = JasperFillManager.fillReport(bin.toByteArray(), parameter);

The xml data is :

<macero>

<dettagli>
        <dettaglio>
            <causale>903</causale>
            <desc-causale>Resa macero certificata</desc-causale>
            <zona>1</zona>
            <desc-zona/>
            <cod-pubblicazione>522</cod-pubblicazione>
            <cped>1120434</cped>
            <titolo>A (ANNA)</titolo>
            <copertina>10003</copertina>
            <prezzo-lordo>1,00 </prezzo-lordo>
            <copie>2</copie>
            <peso-copie>0,52 </peso-copie>
            <sconto-editore>24,10 </sconto-editore>
            <prezzo-netto>0,761300 </prezzo-netto>
            <totale>1,522600 </totale>
        </dettaglio>
</dettagli>
</macero>

The detail are about 400-500.

 

I use xpath query   <queryString language="xPath"><![CDATA[macero/dettagli/dettaglio]]></queryString>

 

 

for the detail section i extract data by using dom document like this :

 

    <![CDATA[ $V{dataSource}.getText($V{dataSource}.subDocument().getElementsByTagName("cod-pubblicazione").item(0).getFirstChild())]]>

 

 

but for grouping i have to declare a field and i think that call xpath processing and make the filling operation slowly.

Any idea?

 
 

 

 

 

Link to comment
Share on other sites

I use Xpath as well because my datasource is an xml file. Below is the way I compile and generate the pdf having an xml file and a jrxml template.

Basically, I do the following:

  1. Create a JRXmlDataSource with my xml file and an Xpath expression, in your case could be something like "macero/dettagli/dettaglio".
  2. Compile the template (jrxml file)
  3. Fill the report with the compiled template and the data source (in this case the HashMap is empty because all the data I need to add is in the xml file)
  4. Export the JasperPrint object to a pdf file

I have defined several fields and variables and doesn't take too much time.

Try doing it this way. It should take less time than the 5 minutes you mentioned in the first post.

Hope this helps.

Regards,

Aitor


 

Code:
  /* Get the data source (xml file) */      File f = new File (xmlFile);      JRXmlDataSource JprXmlDsr = new JRXmlDataSource (f, "DataList/Line");        /* Compile the template */      JasperReport Rep = JasperCompileManager.compileReport (JrxmlFile);        /* Create the JasperPrint object with the template and the data */      JasperPrint  Prn = JasperFillManager.fillReport (Rep, new HashMap (), JprXmlDsr);        /* Export the report to pdf format */      JasperExportManager.exportReportToPdfFile (Prn, PdfName);
Link to comment
Share on other sites

 I found my problem is because i have declared some fields like this :

 

<field name="num-zone" class="java.lang.String">

        <fieldDescription><![CDATA[//..//num-zone]]></fieldDescription>

    </field> 

 

i think that xpath take few second to find the ..//..//   path,is there any way to go around this problem?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...