use of org.activityinfo.model.query.DoubleArrayColumnView in project activityinfo by bedatadriven.
the class JoinedSubFormColumnViewSlot method join.
private ColumnView join() {
// The nested column may contain multiple rows
// for each row on the left
ColumnView subColumn = nestedColumn.get();
int numSubRows = subColumn.numRows();
// In order to produce a column with one summarized entry per
// output row, we need to assign "groupIds" going from
// parentId -> master row index via the primary key
int[] masterRowId = new int[numSubRows];
double[] subColumnValues = new double[numSubRows];
SubFormJoin join = Iterables.getOnlyElement(links);
PrimaryKeyMap parentLookup = join.getMasterPrimaryKey().get();
ColumnView parentColumn = join.getParentColumn().get();
for (int i = 0; i < numSubRows; ++i) {
// Get the parent id of this row
String parentId = parentColumn.getString(i);
masterRowId[i] = parentLookup.getRowIndex(parentId);
// Store the value
subColumnValues[i] = subColumn.getDouble(i);
}
int numMasterRows = parentLookup.numRows();
// Sort the data values by master row index
double[] result = Aggregation.sortAndAggregate(statistic, masterRowId, subColumnValues, numSubRows, numMasterRows);
return new DoubleArrayColumnView(result);
}
use of org.activityinfo.model.query.DoubleArrayColumnView in project activityinfo by bedatadriven.
the class SimpleDoubleColumnBuilder method done.
@Override
public void done() {
double[] array = new double[values.size()];
for (int i = 0; i != array.length; ++i) {
array[i] = values.get(i);
}
result.set(new DoubleArrayColumnView(array));
}
Aggregations