You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gerritjvv edited this page Jan 2, 2012
·
2 revisions
Usage Examples
Group By and Aggregate
SELECT a, b, COUNT(traffic), SUM(hits) from tbl GROUP BY a,b
Can be transformed into the API calls:
Create an Aggregate store. A, B can be passed through without transformation. This assumes that the data will be read with columns in order of : a,b,traffic,hits.
HashMapAggregateStore store = new HashMapAggregateStore(
new PassThroughTransform(0),
new PassThroughTransform(1),
new COUNT(2),
new SUM(3));
Create a GroupBy object The key Parser takes in cells index 0 and index 1. Which corresponds to A, B.
GroupBy groupBy = new GroupBy(new GroupBy.KeyParser() {
@Override
public String makeKey(Cell[] cells) {
return new StringBuilder().append(cells[0]).append(cells[1]).toString();
}
}, store);