Search in sources :

Example 11 with ColumnVectorInfo

use of org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo in project carbondata by apache.

the class RestructureBasedVectorResultCollector method fillDataForNonExistingMeasures.

/**
   * This method will fill the default values of non existing measures in the current block
   */
private void fillDataForNonExistingMeasures() {
    for (int i = 0; i < tableBlockExecutionInfos.getActualQueryMeasures().length; i++) {
        if (!measureInfo.getMeasureExists()[i]) {
            int queryOrder = tableBlockExecutionInfos.getActualQueryMeasures()[i].getQueryOrder();
            CarbonMeasure measure = tableBlockExecutionInfos.getActualQueryMeasures()[i].getMeasure();
            ColumnVectorInfo columnVectorInfo = allColumnInfo[queryOrder];
            CarbonColumnVector vector = columnVectorInfo.vector;
            Object defaultValue = measureDefaultValues[i];
            if (null == defaultValue) {
                vector.putNulls(columnVectorInfo.vectorOffset, columnVectorInfo.size);
            } else {
                switch(measureInfo.getMeasureDataTypes()[i]) {
                    case SHORT:
                        vector.putShorts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (short) defaultValue);
                        break;
                    case INT:
                        vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
                        break;
                    case LONG:
                        vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size, (long) defaultValue);
                        break;
                    case DECIMAL:
                        vector.putDecimals(columnVectorInfo.vectorOffset, columnVectorInfo.size, (Decimal) defaultValue, measure.getPrecision());
                        break;
                    default:
                        vector.putDoubles(columnVectorInfo.vectorOffset, columnVectorInfo.size, (double) defaultValue);
                }
            }
        }
    }
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) ColumnVectorInfo(org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo) CarbonColumnVector(org.apache.carbondata.core.scan.result.vector.CarbonColumnVector)

Aggregations

ColumnVectorInfo (org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo)11 CarbonColumnVector (org.apache.carbondata.core.scan.result.vector.CarbonColumnVector)6 ArrayList (java.util.ArrayList)1 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)1