Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Report row count
Report row count [message #516000] Mon, 22 February 2010 12:51 Go to next message
Mut Antu is currently offline Mut AntuFriend
Messages: 6
Registered: February 2010
Junior Member
Hello,
Before generating programmatically a report, I need to know the row count for the report and avoid generating it if I have too many rows. This row count checking must be resonable fast.
Portions of my code:

IReportEngine engine;
...
IReportRunnable design = engine.openReportDesign(stream);
IRunTask runTask = engine.createRunTask(design);
/* Parameters */
if (parameters != null)
{
for (String clef : parameters.keySet())
{
runTask.setParameterValue(clef, parameters.get(clef));
}
}
runTask.run("***path to the doc****");

IReportDocument doc = engine.openReportDocument(rptDocument);
IRenderTask renderTask = engine.createRenderTask(doc);
IRenderOption option = new RenderOption();
option.setOutputFileName(outputFile);
option.setOutputFormat(format);

renderTask.setRenderOption(option);
renderTask.render();

What is the best way to do row count checking in this case?
Thanks
Re: Report row count [message #516057 is a reply to message #516000] Mon, 22 February 2010 10:52 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Do you want the report to not run or not render when you have to many
rows? By the time BIRT knows how many rows are returned your db will
already be hit. You can set the max number of rows to return if you
want to. Also if you do not mind generating it you could always check
the table data after the run and just not render it.

Jason

Mut Antu wrote:
> Hello,
> Before generating programmatically a report, I need to know the row
> count for the report and avoid generating it if I have too many rows.
> This row count checking must be resonable fast.
> Portions of my code:
>
> IReportEngine engine;
> ..
> IReportRunnable design = engine.openReportDesign(stream);
> IRunTask runTask = engine.createRunTask(design);
> /* Parameters */
> if (parameters != null)
> {
> for (String clef : parameters.keySet())
> {
> runTask.setParameterValue(clef, parameters.get(clef));
> }
> }
> runTask.run("***path to the doc****");
>
> IReportDocument doc = engine.openReportDocument(rptDocument);
> IRenderTask renderTask = engine.createRenderTask(doc);
> IRenderOption option = new RenderOption();
> option.setOutputFileName(outputFile);
> option.setOutputFormat(format);
>
> renderTask.setRenderOption(option);
> renderTask.render();
>
> What is the best way to do row count checking in this case?
> Thanks
>
Re: Report row count [message #516203 is a reply to message #516057] Tue, 23 February 2010 08:19 Go to previous messageGo to next message
Mut Antu is currently offline Mut AntuFriend
Messages: 6
Registered: February 2010
Junior Member
Jason Weathersby wrote on Mon, 22 February 2010 05:52
Do you want the report to not run or not render when you have to many
rows? By the time BIRT knows how many rows are returned your db will
already be hit. You can set the max number of rows to return if you
want to. Also if you do not mind generating it you could always check
the table data after the run and just not render it.

Jason
>


For now I found two methods:
- use a progress monitor in the run to count for FETCH_ROWS event
- let the run go without monitor and use a data extraction task to count the data
I will do some tests on each one to see which are faster.

If I set the max number of rows, there is a way to see if this number is reached or not after a run?
Thanks
Re: Report row count [message #516340 is a reply to message #516203] Tue, 23 February 2010 16:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I do not think so. Let us know what you find in your testing.

Jason

Mut Antu wrote:
> Jason Weathersby wrote on Mon, 22 February 2010 05:52
>> Do you want the report to not run or not render when you have to many
>> rows? By the time BIRT knows how many rows are returned your db will
>> already be hit. You can set the max number of rows to return if you
>> want to. Also if you do not mind generating it you could always check
>> the table data after the run and just not render it.
>>
>> Jason
>> >
>
>
> For now I found two methods:
> - use a progress monitor in the run to count for FETCH_ROWS event
> - let the run go without monitor and use a data extraction task to
> count the data
> I will do some tests on each one to see which are faster.
>
> If I set the max number of rows, there is a way to see if this number is
> reached or not after a run?
> Thanks
Re: Report row count [message #516342 is a reply to message #516340] Tue, 23 February 2010 16:04 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

BTW I did not think to use the progress monitor. Your best approach may
be to use it with a cancel task if the limit is reached.

Jason

Jason Weathersby wrote:
> I do not think so. Let us know what you find in your testing.
>
> Jason
>
> Mut Antu wrote:
>> Jason Weathersby wrote on Mon, 22 February 2010 05:52
>>> Do you want the report to not run or not render when you have to many
>>> rows? By the time BIRT knows how many rows are returned your db will
>>> already be hit. You can set the max number of rows to return if you
>>> want to. Also if you do not mind generating it you could always
>>> check the table data after the run and just not render it.
>>>
>>> Jason
>>> >
>>
>>
>> For now I found two methods:
>> - use a progress monitor in the run to count for FETCH_ROWS event
>> - let the run go without monitor and use a data extraction task to
>> count the data
>> I will do some tests on each one to see which are faster.
>>
>> If I set the max number of rows, there is a way to see if this number
>> is reached or not after a run?
>> Thanks
Re: Report row count [message #516517 is a reply to message #516342] Wed, 24 February 2010 10:30 Go to previous message
Mut Antu is currently offline Mut AntuFriend
Messages: 6
Registered: February 2010
Junior Member
Jason Weathersby wrote on Tue, 23 February 2010 11:04
BTW I did not think to use the progress monitor. Your best approach may
be to use it with a cancel task if the limit is reached.

Jason



I made some tests with Birt 2.5.1, distant intranet Mysql database and a report with 5000 lines and 3 columns.

The run task took like 4 seconds, the simple html render task took 6 seconds.
The data extraction task to do row counting was like 100 ms.

I will use a progress monitor and cancel the task when limit is reached, indeed is the best solution.

I have another (little) problem with task canceling, I will open another topic.
Thanks again.
Previous Topic:Possible to export crosstab data?
Next Topic:Pie chart SWT problems
Goto Forum:
  


Current Time: Thu Apr 25 21:51:29 GMT 2024

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top