core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
/**
   * Method will read the members of particular dimension block and create
   * a row instance for further processing of the filters
   *
   * @param blockChunkHolder
   * @param row
   * @param index
   * @throws IOException
   */
Method will read the members of particular dimension block and create
a row instance for further processing of the filters


Method will read the members of particular dimension block and create a row instance for further processing of the filters
private void createRow(BlocksChunkHolder blockChunkHolder, RowIntf row, int pageIndex, int index)
      throws IOException {
    Object[] record = new Object[dimColEvaluatorInfoList.size() + msrColEvalutorInfoList.size()];
    String memberString;
    for (int i = 0; i < dimColEvaluatorInfoList.size(); i++) {
      DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = dimColEvaluatorInfoList.get(i);
      if (!isDimensionPresentInCurrentBlock[i]) {
        record[dimColumnEvaluatorInfo.getRowIndex()] =
            getDimensionDefaultValue(dimColumnEvaluatorInfo);
        continue;
      }
      if (!dimColumnEvaluatorInfo.getDimension().getDataType().isComplexType()) {
        if (!dimColumnEvaluatorInfo.isDimensionExistsInCurrentSilce()) {
          record[dimColumnEvaluatorInfo.getRowIndex()] =
              dimColumnEvaluatorInfo.getDimension().getDefaultValue();
        }
        DimensionColumnDataChunk columnDataChunk =
            blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]]
                .convertToDimColDataChunk(pageIndex);
        if (!dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DICTIONARY)
            && columnDataChunk instanceof VariableLengthDimensionDataChunk) {
          VariableLengthDimensionDataChunk dimensionColumnDataChunk =
              (VariableLengthDimensionDataChunk) columnDataChunk;
          byte[] memberBytes = dimensionColumnDataChunk.getChunkData(index);
          if (null != memberBytes) {
            if (Arrays.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY, memberBytes)) {
              memberBytes = null;
            } else if (memberBytes.length == 0) {
              memberBytes = null;
            }
            record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil
                .getDataBasedOnDataTypeForNoDictionaryColumn(memberBytes,
                    dimColumnEvaluatorInfo.getDimension().getDataType());
          }
        } else {
          int dictionaryValue = readSurrogatesFromColumnBlock(blockChunkHolder, index, pageIndex,
              dimColumnEvaluatorInfo, dimensionBlocksIndex[i]);
          if (dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DICTIONARY)
              && !dimColumnEvaluatorInfo.getDimension().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
            memberString =
                getFilterActualValueFromDictionaryValue(dimColumnEvaluatorInfo, dictionaryValue);
            record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil
                .getDataBasedOnDataType(memberString,
                    dimColumnEvaluatorInfo.getDimension().getDataType());
          } else if (dimColumnEvaluatorInfo.getDimension()
              .hasEncoding(Encoding.DIRECT_DICTIONARY)) {
            Object member = getFilterActualValueFromDirectDictionaryValue(dimColumnEvaluatorInfo,
                dictionaryValue);
            record[dimColumnEvaluatorInfo.getRowIndex()] = member;
          }
        }
      } else {
        try {
          GenericQueryType complexType = complexDimensionInfoMap.get(dimensionBlocksIndex[i]);
          ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
          DataOutputStream dataOutputStream = new DataOutputStream(byteStream);
          complexType.parseBlocksAndReturnComplexColumnByteArray(
              blockChunkHolder.getDimensionRawDataChunk(), index, pageIndex, dataOutputStream);
          record[dimColumnEvaluatorInfo.getRowIndex()] = complexType
              .getDataBasedOnDataTypeFromSurrogates(ByteBuffer.wrap(byteStream.toByteArray()));
          byteStream.close();
        } catch (IOException e) {
          LOGGER.info(e.getMessage());
        }
      }
    }
    DataType msrType;
    for (int i = 0; i < msrColEvalutorInfoList.size(); i++) {
      MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = msrColEvalutorInfoList.get(i);
      DataType dataType = msrColumnEvalutorInfo.getType();
      if (dataType == DataTypes.BOOLEAN) {
        msrType = DataTypes.BOOLEAN;
      } else if (dataType == DataTypes.SHORT) {
        msrType = DataTypes.SHORT;
      } else if (dataType == DataTypes.INT) {
        msrType = DataTypes.INT;
      } else if (dataType == DataTypes.LONG) {
        msrType = DataTypes.LONG;
      } else if (DataTypes.isDecimal(dataType)) {
        msrType = DataTypes.createDefaultDecimalType();
      } else {
        msrType = DataTypes.DOUBLE;
      }
      if (!isMeasurePresentInCurrentBlock[i]) {
        byte[] defaultValue = msrColumnEvalutorInfo.getCarbonColumn().getDefaultValue();
        record[msrColumnEvalutorInfo.getRowIndex()] = RestructureUtil
            .getMeasureDefaultValue(msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema(),
                defaultValue);
        continue;
      }
      Object msrValue;
      ColumnPage columnPage =
          blockChunkHolder.getMeasureRawDataChunk()[measureBlocksIndex[0]]
              .convertToColumnPage(pageIndex);
      if (msrType == DataTypes.BOOLEAN) {
        msrValue = columnPage.getBoolean(index);
      } else if (msrType == DataTypes.SHORT) {
        msrValue = (short) columnPage.getLong(index);
      } else if (msrType == DataTypes.INT) {
        msrValue = (int) columnPage.getLong(index);
      } else if (msrType == DataTypes.LONG) {
        msrValue = columnPage.getLong(index);
      } else if (DataTypes.isDecimal(msrType)) {
        BigDecimal bigDecimalValue = columnPage.getDecimal(index);
        if (null != bigDecimalValue
            && msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale()
            > bigDecimalValue.scale()) {
          bigDecimalValue = bigDecimalValue
              .setScale(msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale(),
                  RoundingMode.HALF_UP);
        }
        msrValue = bigDecimalValue;
      } else {
        msrValue = columnPage.getDouble(index);
      }
      record[msrColumnEvalutorInfo.getRowIndex()] =
          columnPage.getNullBits().get(index) ? null : msrValue;
    }
    row.setValues(record);
  }
private void createRow ( BlocksChunkHolder blockChunkHolder , RowIntf row , int pageIndex , int index ) throws IOException { Object [ ] record = new Object [ dimColEvaluatorInfoList . size ( ) + msrColEvalutorInfoList . size ( ) ] ; String memberString ; for ( int i = 0 ; i < dimColEvaluatorInfoList . size ( ) ; i ++ ) { DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = dimColEvaluatorInfoList . get ( i ) ; if ( ! isDimensionPresentInCurrentBlock [ i ] ) { record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = getDimensionDefaultValue ( dimColumnEvaluatorInfo ) ; continue ; } if ( ! dimColumnEvaluatorInfo . getDimension ( ) . getDataType ( ) . isComplexType ( ) ) { if ( ! dimColumnEvaluatorInfo . isDimensionExistsInCurrentSilce ( ) ) { record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = dimColumnEvaluatorInfo . getDimension ( ) . getDefaultValue ( ) ; } DimensionColumnDataChunk columnDataChunk = blockChunkHolder . getDimensionRawDataChunk ( ) [ dimensionBlocksIndex [ i ] ] . convertToDimColDataChunk ( pageIndex ) ; if ( ! dimColumnEvaluatorInfo . getDimension ( ) . hasEncoding ( Encoding . DICTIONARY ) && columnDataChunk instanceof VariableLengthDimensionDataChunk ) { VariableLengthDimensionDataChunk dimensionColumnDataChunk = ( VariableLengthDimensionDataChunk ) columnDataChunk ; byte [ ] memberBytes = dimensionColumnDataChunk . getChunkData ( index ) ; if ( null != memberBytes ) { if ( Arrays . equals ( CarbonCommonConstants . MEMBER_DEFAULT_VAL_ARRAY , memberBytes ) ) { memberBytes = null ; } else if ( memberBytes . length == 0 ) { memberBytes = null ; } record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = DataTypeUtil . getDataBasedOnDataTypeForNoDictionaryColumn ( memberBytes , dimColumnEvaluatorInfo . getDimension ( ) . getDataType ( ) ) ; } } else { int dictionaryValue = readSurrogatesFromColumnBlock ( blockChunkHolder , index , pageIndex , dimColumnEvaluatorInfo , dimensionBlocksIndex [ i ] ) ; if ( dimColumnEvaluatorInfo . getDimension ( ) . hasEncoding ( Encoding . DICTIONARY ) && ! dimColumnEvaluatorInfo . getDimension ( ) . hasEncoding ( Encoding . DIRECT_DICTIONARY ) ) { memberString = getFilterActualValueFromDictionaryValue ( dimColumnEvaluatorInfo , dictionaryValue ) ; record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = DataTypeUtil . getDataBasedOnDataType ( memberString , dimColumnEvaluatorInfo . getDimension ( ) . getDataType ( ) ) ; } else if ( dimColumnEvaluatorInfo . getDimension ( ) . hasEncoding ( Encoding . DIRECT_DICTIONARY ) ) { Object member = getFilterActualValueFromDirectDictionaryValue ( dimColumnEvaluatorInfo , dictionaryValue ) ; record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = member ; } } } else { try { GenericQueryType complexType = complexDimensionInfoMap . get ( dimensionBlocksIndex [ i ] ) ; ByteArrayOutputStream byteStream = new ByteArrayOutputStream ( ) ; DataOutputStream dataOutputStream = new DataOutputStream ( byteStream ) ; complexType . parseBlocksAndReturnComplexColumnByteArray ( blockChunkHolder . getDimensionRawDataChunk ( ) , index , pageIndex , dataOutputStream ) ; record [ dimColumnEvaluatorInfo . getRowIndex ( ) ] = complexType . getDataBasedOnDataTypeFromSurrogates ( ByteBuffer . wrap ( byteStream . toByteArray ( ) ) ) ; byteStream . close ( ) ; } catch ( IOException e ) { LOGGER . info ( e . getMessage ( ) ) ; } } } DataType msrType ; for ( int i = 0 ; i < msrColEvalutorInfoList . size ( ) ; i ++ ) { MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = msrColEvalutorInfoList . get ( i ) ; DataType dataType = msrColumnEvalutorInfo . getType ( ) ; if ( dataType == DataTypes . BOOLEAN ) { msrType = DataTypes . BOOLEAN ; } else if ( dataType == DataTypes . SHORT ) { msrType = DataTypes . SHORT ; } else if ( dataType == DataTypes . INT ) { msrType = DataTypes . INT ; } else if ( dataType == DataTypes . LONG ) { msrType = DataTypes . LONG ; } else if ( DataTypes . isDecimal ( dataType ) ) { msrType = DataTypes . createDefaultDecimalType ( ) ; } else { msrType = DataTypes . DOUBLE ; } if ( ! isMeasurePresentInCurrentBlock [ i ] ) { byte [ ] defaultValue = msrColumnEvalutorInfo . getCarbonColumn ( ) . getDefaultValue ( ) ; record [ msrColumnEvalutorInfo . getRowIndex ( ) ] = RestructureUtil . getMeasureDefaultValue ( msrColumnEvalutorInfo . getCarbonColumn ( ) . getColumnSchema ( ) , defaultValue ) ; continue ; } Object msrValue ; ColumnPage columnPage = blockChunkHolder . getMeasureRawDataChunk ( ) [ measureBlocksIndex [ 0 ] ] . convertToColumnPage ( pageIndex ) ; if ( msrType == DataTypes . BOOLEAN ) { msrValue = columnPage . getBoolean ( index ) ; } else if ( msrType == DataTypes . SHORT ) { msrValue = ( short ) columnPage . getLong ( index ) ; } else if ( msrType == DataTypes . INT ) { msrValue = ( int ) columnPage . getLong ( index ) ; } else if ( msrType == DataTypes . LONG ) { msrValue = columnPage . getLong ( index ) ; } else if ( DataTypes . isDecimal ( msrType ) ) { BigDecimal bigDecimalValue = columnPage . getDecimal ( index ) ; if ( null != bigDecimalValue && msrColumnEvalutorInfo . getCarbonColumn ( ) . getColumnSchema ( ) . getScale ( ) > bigDecimalValue . scale ( ) ) { bigDecimalValue = bigDecimalValue . setScale ( msrColumnEvalutorInfo . getCarbonColumn ( ) . getColumnSchema ( ) . getScale ( ) , RoundingMode . HALF_UP ) ; } msrValue = bigDecimalValue ; } else { msrValue = columnPage . getDouble ( index ) ; } record [ msrColumnEvalutorInfo . getRowIndex ( ) ] = columnPage . getNullBits ( ) . get ( index ) ? null : msrValue ; } row . setValues ( record ) ; }
Method will read the members of particular dimension block and create
 a row instance for further processing of the filters
Method will read the members of particular dimension block and create a row instance for further processing of the filters
// if filter dimension is not present in the current add its default value // fill default value here // add default value for the measure in case filter measure is not present // in the current block measure list