Analysis with Groovy and AIDA
![]() |
Groovy with AIDA makes very good environment for analysis of data in SQL database. User can easily access all data, perform analysis code and plot histograms. What is needed: |
// create AIDA histogram from SQL
// ==============================
// This is pure AIDA code
// ----------------------
// Create all needed factories
af = IAnalysisFactory.create()
tree = af.createTreeFactory().create()
hf = af.createHistogramFactory(tree)
// Create your histogram here
histo = hf.createHistogram1D("histo", 50, 0, 1)
// This is pure Groovy code
// ------------------------
// Get driver to your SQL database
sqlDriver = Sql.newInstance("jdbc:mysql://localhost/Tuples",
"test",
"test",
"org.gjt.mm.mysql.Driver")
// Loop over table rows and accumulate histogram
sqlDriver.eachRow("select mycolumn from mytuple") {
histo.fill(it.mycolumn)
}
// This is pure AIDA code
// ----------------------
// Show your histogram in new window
plotter = af.createPlotterFactory().create("SQL Plot")
plotter.createRegions(1, 1, 0)
plotter.region(0).plot(histo)
plotter.show()
Note that you can use any Java library from your Groovy code (you can use ant Groovy library from your Java code too).