Search in sources :

Example 6 with DoubleArrayColumnView

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);
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) DoubleArrayColumnView(org.activityinfo.model.query.DoubleArrayColumnView) DoubleArrayColumnView(org.activityinfo.model.query.DoubleArrayColumnView)

Example 7 with DoubleArrayColumnView

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));
}
Also used : DoubleArrayColumnView(org.activityinfo.model.query.DoubleArrayColumnView)

Aggregations

DoubleArrayColumnView (org.activityinfo.model.query.DoubleArrayColumnView)7 ColumnView (org.activityinfo.model.query.ColumnView)6 FormulaSyntaxException (org.activityinfo.model.formula.diagnostic.FormulaSyntaxException)1 ConstantColumnView (org.activityinfo.model.query.ConstantColumnView)1 Test (org.junit.Test)1