integration/spark2/src/main/java/org/apache/carbondata/spark/vectorreader/VectorizedCarbonRecordReader.java
/**
   * Returns the ColumnarBatch object that will be used for all rows returned by this reader.
   * This object is reused. Calling this enables the vectorized reader. This should be called
   * before any calls to nextKeyValue/nextBatch.
   */
Returns the ColumnarBatch object that will be used for all rows returned by this reader.
This object is reused. Calling this enables the vectorized reader. This should be called
before any calls to nextKeyValue/nextBatch.
Returns the ColumnarBatch object that will be used for all rows returned by this reader . This object is reused . Calling this enables the vectorized reader . This should be called before any calls to nextKeyValue / nextBatch .
private void initBatch(MemoryMode memMode) {
    List<QueryDimension> queryDimension = queryModel.getQueryDimension();
    List<QueryMeasure> queryMeasures = queryModel.getQueryMeasures();
    StructField[] fields = new StructField[queryDimension.size() + queryMeasures.size()];
    for (int i = 0; i < queryDimension.size(); i++) {
      QueryDimension dim = queryDimension.get(i);
      if (dim.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
        DirectDictionaryGenerator generator = DirectDictionaryKeyGeneratorFactory
            .getDirectDictionaryGenerator(dim.getDimension().getDataType());
        fields[dim.getQueryOrder()] = new StructField(dim.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(generator.getReturnType()), true, null);
      } else if (!dim.getDimension().hasEncoding(Encoding.DICTIONARY)) {
        fields[dim.getQueryOrder()] = new StructField(dim.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(dim.getDimension().getDataType()), true,
            null);
      } else if (dim.getDimension().isComplex()) {
        fields[dim.getQueryOrder()] = new StructField(dim.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(dim.getDimension().getDataType()), true,
            null);
      } else {
        fields[dim.getQueryOrder()] = new StructField(dim.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(DataTypes.INT), true, null);
      }
    }
    for (int i = 0; i < queryMeasures.size(); i++) {
      QueryMeasure msr = queryMeasures.get(i);
      DataType dataType = msr.getMeasure().getDataType();
      if (dataType == DataTypes.BOOLEAN || dataType == DataTypes.SHORT ||
          dataType == DataTypes.INT || dataType == DataTypes.LONG) {
        fields[msr.getQueryOrder()] = new StructField(msr.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(msr.getMeasure().getDataType()), true,
            null);
      } else if (DataTypes.isDecimal(dataType)) {
        fields[msr.getQueryOrder()] = new StructField(msr.getColumnName(),
            new DecimalType(msr.getMeasure().getPrecision(), msr.getMeasure().getScale()), true,
            null);
      } else {
        fields[msr.getQueryOrder()] = new StructField(msr.getColumnName(),
            CarbonScalaUtil.convertCarbonToSparkDataType(DataTypes.DOUBLE), true, null);
      }
    }
    columnarBatch = ColumnarBatch.allocate(new StructType(fields), memMode);
    CarbonColumnVector[] vectors = new CarbonColumnVector[fields.length];
    boolean[] filteredRows = new boolean[columnarBatch.capacity()];
    for (int i = 0; i < fields.length; i++) {
      vectors[i] = new ColumnarVectorWrapper(columnarBatch.column(i), filteredRows);
    }
    carbonColumnarBatch = new CarbonColumnarBatch(vectors, columnarBatch.capacity(), filteredRows);
  }
private void initBatch ( MemoryMode memMode ) { List < QueryDimension > queryDimension = queryModel . getQueryDimension ( ) ; List < QueryMeasure > queryMeasures = queryModel . getQueryMeasures ( ) ; StructField [ ] fields = new StructField [ queryDimension . size ( ) + queryMeasures . size ( ) ] ; for ( int i = 0 ; i < queryDimension . size ( ) ; i ++ ) { QueryDimension dim = queryDimension . get ( i ) ; if ( dim . getDimension ( ) . hasEncoding ( Encoding . DIRECT_DICTIONARY ) ) { DirectDictionaryGenerator generator = DirectDictionaryKeyGeneratorFactory . getDirectDictionaryGenerator ( dim . getDimension ( ) . getDataType ( ) ) ; fields [ dim . getQueryOrder ( ) ] = new StructField ( dim . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( generator . getReturnType ( ) ) , true , null ) ; } else if ( ! dim . getDimension ( ) . hasEncoding ( Encoding . DICTIONARY ) ) { fields [ dim . getQueryOrder ( ) ] = new StructField ( dim . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( dim . getDimension ( ) . getDataType ( ) ) , true , null ) ; } else if ( dim . getDimension ( ) . isComplex ( ) ) { fields [ dim . getQueryOrder ( ) ] = new StructField ( dim . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( dim . getDimension ( ) . getDataType ( ) ) , true , null ) ; } else { fields [ dim . getQueryOrder ( ) ] = new StructField ( dim . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( DataTypes . INT ) , true , null ) ; } } for ( int i = 0 ; i < queryMeasures . size ( ) ; i ++ ) { QueryMeasure msr = queryMeasures . get ( i ) ; DataType dataType = msr . getMeasure ( ) . getDataType ( ) ; if ( dataType == DataTypes . BOOLEAN || dataType == DataTypes . SHORT || dataType == DataTypes . INT || dataType == DataTypes . LONG ) { fields [ msr . getQueryOrder ( ) ] = new StructField ( msr . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( msr . getMeasure ( ) . getDataType ( ) ) , true , null ) ; } else if ( DataTypes . isDecimal ( dataType ) ) { fields [ msr . getQueryOrder ( ) ] = new StructField ( msr . getColumnName ( ) , new DecimalType ( msr . getMeasure ( ) . getPrecision ( ) , msr . getMeasure ( ) . getScale ( ) ) , true , null ) ; } else { fields [ msr . getQueryOrder ( ) ] = new StructField ( msr . getColumnName ( ) , CarbonScalaUtil . convertCarbonToSparkDataType ( DataTypes . DOUBLE ) , true , null ) ; } } columnarBatch = ColumnarBatch . allocate ( new StructType ( fields ) , memMode ) ; CarbonColumnVector [ ] vectors = new CarbonColumnVector [ fields . length ] ; boolean [ ] filteredRows = new boolean [ columnarBatch . capacity ( ) ] ; for ( int i = 0 ; i < fields . length ; i ++ ) { vectors [ i ] = new ColumnarVectorWrapper ( columnarBatch . column ( i ) , filteredRows ) ; } carbonColumnarBatch = new CarbonColumnarBatch ( vectors , columnarBatch . capacity ( ) , filteredRows ) ; }
Returns the ColumnarBatch object that will be used for all rows returned by this reader.
Returns the ColumnarBatch object that will be used for all rows returned by this reader .