Search in sources :

Example 6 with CarbonColumnVector

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

the class AbstractScannedResult method fillColumnarImplicitBatch.

/**
   * Fill the column data to vector
   */
public void fillColumnarImplicitBatch(ColumnVectorInfo[] vectorInfo) {
    int column = 0;
    for (int i = 0; i < vectorInfo.length; i++) {
        ColumnVectorInfo columnVectorInfo = vectorInfo[column];
        CarbonColumnVector vector = columnVectorInfo.vector;
        int offset = columnVectorInfo.offset;
        int vectorOffset = columnVectorInfo.vectorOffset;
        int len = offset + columnVectorInfo.size;
        for (int j = offset; j < len; j++) {
            // Considering only String case now as we support only
            String data = getBlockletId();
            if (CarbonCommonConstants.CARBON_IMPLICIT_COLUMN_TUPLEID.equals(columnVectorInfo.dimension.getColumnName())) {
                data = data + CarbonCommonConstants.FILE_SEPARATOR + (rowMapping == null ? j : rowMapping[pageCounter][j]);
            }
            vector.putBytes(vectorOffset++, offset, data.length(), data.getBytes());
        }
    }
}
Also used : ColumnVectorInfo(org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo) CarbonColumnVector(org.apache.carbondata.core.scan.result.vector.CarbonColumnVector)

Example 7 with CarbonColumnVector

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

the class AbstractScannedResult method fillColumnarComplexBatch.

public void fillColumnarComplexBatch(ColumnVectorInfo[] vectorInfos) {
    for (int i = 0; i < vectorInfos.length; i++) {
        int offset = vectorInfos[i].offset;
        int len = offset + vectorInfos[i].size;
        int vectorOffset = vectorInfos[i].vectorOffset;
        CarbonColumnVector vector = vectorInfos[i].vector;
        for (int j = offset; j < len; j++) {
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
            DataOutputStream dataOutput = new DataOutputStream(byteStream);
            try {
                vectorInfos[i].genericQueryType.parseBlocksAndReturnComplexColumnByteArray(rawColumnChunks, rowMapping == null ? j : rowMapping[pageCounter][j], pageCounter, dataOutput);
                Object data = vectorInfos[i].genericQueryType.getDataBasedOnDataTypeFromSurrogates(ByteBuffer.wrap(byteStream.toByteArray()));
                vector.putObject(vectorOffset++, data);
            } catch (IOException e) {
                LOGGER.error(e);
            } finally {
                CarbonUtil.closeStreams(dataOutput);
                CarbonUtil.closeStreams(byteStream);
            }
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) CarbonColumnVector(org.apache.carbondata.core.scan.result.vector.CarbonColumnVector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 8 with CarbonColumnVector

use of org.apache.carbondata.core.scan.result.vector.CarbonColumnVector 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

CarbonColumnVector (org.apache.carbondata.core.scan.result.vector.CarbonColumnVector)8 ColumnVectorInfo (org.apache.carbondata.core.scan.result.vector.ColumnVectorInfo)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 DirectDictionaryGenerator (org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator)1 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)1 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)1 QueryMeasure (org.apache.carbondata.core.scan.model.QueryMeasure)1 CarbonColumnarBatch (org.apache.carbondata.core.scan.result.vector.CarbonColumnarBatch)1 DecimalType (org.apache.spark.sql.types.DecimalType)1 StructField (org.apache.spark.sql.types.StructField)1 StructType (org.apache.spark.sql.types.StructType)1