Search in sources :

Example 1 with DateVector

use of org.apache.drill.exec.vector.DateVector in project drill by apache.

the class StatisticsMergeBatch method buildOutgoingRecordBatch.

/**
 * Prepare the outgoing container. Populates the outgoing record batch data.
 * Please look at the comments above the class definition which describes the
 * incoming/outgoing batch schema
 */
private IterOutcome buildOutgoingRecordBatch() {
    for (VectorWrapper<?> vw : container) {
        String outputStatName = vw.getField().getName();
        // Populate the `schema` and `computed` fields
        if (outputStatName.equals(Statistic.SCHEMA)) {
            BigIntVector vv = (BigIntVector) vw.getValueVector();
            vv.allocateNewSafe();
            vv.getMutator().setSafe(0, schema);
        } else if (outputStatName.equals(Statistic.COMPUTED)) {
            GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
            DateVector vv = (DateVector) vw.getValueVector();
            vv.allocateNewSafe();
            vv.getMutator().setSafe(0, cal.getTimeInMillis());
        } else {
            // Populate the rest of the merged statistics. Each statistic is a map which
            // contains <COL_NAME, STATS_VALUE> pairs
            MapVector vv = (MapVector) vw.getValueVector();
            for (MergedStatistic outputStat : mergedStatisticList) {
                if (outputStatName.equals(outputStat.getName())) {
                    outputStat.setOutput(vv);
                    vv.getMutator().setValueCount(columnsList.size());
                    break;
                }
            }
        }
    }
    // Populate the number of records (1) inside the outgoing batch.
    container.setValueCount(1);
    return IterOutcome.OK;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) DateVector(org.apache.drill.exec.vector.DateVector) BigIntVector(org.apache.drill.exec.vector.BigIntVector) MapVector(org.apache.drill.exec.vector.complex.MapVector)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)1 BigIntVector (org.apache.drill.exec.vector.BigIntVector)1 DateVector (org.apache.drill.exec.vector.DateVector)1 MapVector (org.apache.drill.exec.vector.complex.MapVector)1