Source:
public void run(ProgressMonitor pm) { try { final DataSourceFactory dsf = (Services.getService(DataManager.class)).getDataSourceFactory(); Metadata metadata = ds.getMetadata(); String fieldName = metadata.getFieldName(columnId); String tableName = ds.getName(); long rowCount = ds.getRowCount(); boolean doRowFiltering = !statisticsRowFilter.isEmpty() && statisticsRowFilter.size() < ds.getRowCount(); if(doRowFiltering) { rowCount = statisticsRowFilter.size(); tableName = makeFilteredData(dsf,fieldName); } SQLScript s = Engine.loadScript( ComputeFieldStatistics.class.getResourceAsStream("compute_stats.bsql")); LOGGER.debug("Set Table name : "+tableName); SQLStatement statement = s.getStatements()[0]; statement.setFieldParameter("fieldName", fieldName); statement.setTableParameter("tableName", tableName); statement.setDataSourceFactory(dsf); statement.prepare(); DataSet dataSet = statement.execute(); Value[] row = dataSet.getRow(0); String[] rowLabels = dataSet.getMetadata().getFieldNames(); Map<String,Value> values = new HashMap<String,Value>(); for(int col=0;col<row.length;col++) { values.put(rowLabels[col],row[col]); } StringBuilder message = new StringBuilder(); message.append(I18N.tr("\nTable {0}, statistics of the column {1}.\n",ds.getName(),fieldName)); message.append(I18N.tr("Row count : {0}\n",rowCount)); message.append(I18N.tr("Minimum : {0}\n",values.get("min"))); message.append(I18N.tr("Maximum : {0}\n",values.get("max"))); message.append(I18N.tr("Sum : {0}\n",values.get("sum"))); message.append(I18N.tr("Average : {0}\n",values.get("avg"))); message.append(I18N.tr("Standart deviation : {0}\n",values.get("std"))); LOGGER.info(message.toString()); if(doRowFiltering) { dsf.getSourceManager().remove(tableName); } statement.cleanUp(); } catch (DriverException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } catch (IOException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } }

Target:
public void run(ProgressMonitor pm) { try { final DataSourceFactory dsf = ds.getDataSourceFactory(); Metadata metadata = ds.getMetadata(); String fieldName = metadata.getFieldName(columnId); String tableName = ds.getName(); long rowCount = ds.getRowCount(); boolean doRowFiltering = !statisticsRowFilter.isEmpty() && statisticsRowFilter.size() < ds.getRowCount(); if(doRowFiltering) { rowCount = statisticsRowFilter.size(); tableName = makeFilteredData(dsf,fieldName); } SQLScript s = Engine.loadScript( ComputeFieldStatistics.class.getResourceAsStream("compute_stats.bsql")); LOGGER.debug("Set Table name : "+tableName); SQLStatement statement = s.getStatements()[0]; statement.setFieldParameter("fieldName", fieldName); statement.setTableParameter("tableName", tableName); statement.setDataSourceFactory(dsf); statement.prepare(); DataSet dataSet = statement.execute(); Value[] row = dataSet.getRow(0); String[] rowLabels = dataSet.getMetadata().getFieldNames(); Map<String,Value> values = new HashMap<String,Value>(); for(int col=0;col<row.length;col++) { values.put(rowLabels[col],row[col]); } StringBuilder message = new StringBuilder(); message.append(I18N.tr("\nTable {0}, statistics of the column {1}.\n",ds.getName(),fieldName)); message.append(I18N.tr("Row count : {0}\n",rowCount)); message.append(I18N.tr("Minimum : {0}\n",values.get("min"))); message.append(I18N.tr("Maximum : {0}\n",values.get("max"))); message.append(I18N.tr("Sum : {0}\n",values.get("sum"))); message.append(I18N.tr("Average : {0}\n",values.get("avg"))); message.append(I18N.tr("Standard deviation : {0}\n",values.get("std"))); LOGGER.info(message.toString()); if(doRowFiltering) { dsf.getSourceManager().remove(tableName); } statement.cleanUp(); } catch (DriverException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } catch (IOException ex) { LOGGER.error(ex.getLocalizedMessage(),ex); } }