AbstractDataSource implements DataSource, Serializable { public DataSource getColumnStatistics(String key) { Class[] columnTypes = new Class[getColumnCount()]; Arrays.fill(columnTypes, Double.class); DataTable statisticsTable = new DataTable(columnTypes); List<Double> colStatistics = new ArrayList<>(columnTypes.length); for (int colIndex = 0; colIndex < getColumnCount(); colIndex++) { Column col = getColumn(colIndex); colStatistics.add(col.getStatistics(key)); } if (!colStatistics.isEmpty()) { statisticsTable.add(colStatistics); } return statisticsTable; } AbstractDataSource();  AbstractDataSource(String name, Class<? extends Comparable<?>>... types);  AbstractDataSource(Class<? extends Comparable<?>>... types);  AbstractDataSource(Column... remainingColumns); Statistics getStatistics(); DataSource getColumnStatistics(String key); DataSource getRowStatistics(String key); void addDataListener(DataListener dataListener); void removeDataListener(DataListener dataListener); Iterator<Comparable<?>> iterator(); @Override Column<?> getColumn(int col); @Override String getName(); @Override Record getRecord(int row); int getColumnCount(); Class<? extends Comparable<?>>[] getColumnTypes(); boolean isColumnNumeric(int columnIndex); Row getRow(int row);  }
@Test public void testColumnStatisticsForMultiColumnDataSourceContainsSingleRow() { int columnCount = 5; source = new StubAbstractDataSource(columnCount, 0); DataSource columnStatistics = source.getColumnStatistics(Statistics.N); assertThat(columnStatistics.getRowCount(), is(1)); }
@Test public void testColumnStatisticsForEmptyDataSourceContainsNoRow() { DataSource columnStatistics = source.getColumnStatistics(Statistics.N); assertThat(columnStatistics.getRowCount(), is(0)); }