Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Scripted Data Set Performance issue
skananth
Hi, <br />
<br />
I am trying to use a scripted data source with JSON as my data source. I am having the following lines in the open section of my data source script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage(Packages.java.util.logging);
Logger.getAnonymousLogger().info("Data file:" + dataFile);
Logger.getAnonymousLogger().info("First time");
var jsonStr = fileToStr(dataFile);
var jsonObj = jsonParse(jsonStr);
var devtestParam;
Logger.getAnonymousLogger().info("Dev param:" + devtestParam);
devParam = jsonObj["CapacityPlanningData"]["Parameters"];
Logger.getAnonymousLogger().info("Report Name: " + devParam["ReportName"]);
Logger.getAnonymousLogger().info("First time");
devData = jsonObj["CapacityPlanningData"]["Data"];
Logger.getAnonymousLogger().info("Data Sets: " + devData.length);
</pre>
<br />
I have a lot of data sets and I am trying to fetch the data for different input parameters. I find that these lines are being logged multiple times which means every time I am trying to fetch a data set, it is opening the file on disk, trying to parse it and then return the data set. I want to modify this and ensure that the devData and the devParam are populated only when it does not contain any value or rather only the first time the data source is opened. <br />
<br />
Could some one suggest how do I go about doing this?<br />
<br />
Thanks,<br />
skananth.
Find more posts tagged with
Comments
johnw
If this is the open statement, what does the fetch statement look like. can you post your report design?
skananth
This is the open statement from the data source and not the data set. I am trying to initialize a few variables in there after parsing my input data source on opening it. I have a lot of data sets and later on whenever I try to do a fetch based on these input parameters, it is trying to re-fetch these variable values by connecting to the JSON source.
CBR
If you only want the code to be executed once you might place it in the beforeFactory event of the report and to leave the open event handler empty for your datasource
skananth
<blockquote class='ipsBlockquote' data-author="'cbrell'" data-cid="84452" data-time="1319280017" data-date="22 October 2011 - 03:40 AM"><p>
If you only want the code to be executed once you might place it in the beforeFactory event of the report and to leave the open event handler empty for your datasource<br /></p></blockquote>
Yes, that worked fine. Thanks a lot! However, it didn't let me leave the data source open handler empty. So, what I had to do was call the parser and set some global variables in the beforeFactory even handler and use the persistent global variable in the open handler. <br />
<br />
Thanks for the help!
CBR
You are welcome.
Why did you use a global persistent variable?
Variables are global by nature in BIRT (i just leave out the "var" in front of the variable name to mark them as global).
If you are using reportContext.setGlobalVariable(...) you add the variable to the reportContext. The only difference between that method and the global variables in Rhino Script is that you can access the variable in your Java Code (Java Event Handler or BIRT integration code).
The method setGlobalPersistentVariable is pretty much comparable to the setGlobalVariable. The difference here is that the value of a variable is serialized and added to a rptdocument file when using the two phases to generate the report (run to generate the rptdocument and render to render the rptdocument to a specific output format).
the setGlobalPersistentVariable may cause larger rptdocuments (in dependence of what you store using these variables). The advantage is that you can share a variable between both phases. If your reports are only generated using the single phase model (run&render) the setGlobalPersistentVariable does the same as the setGlobalVariable method.