processing/src/main/java/org/apache/carbondata/processing/loading/converter/impl/FieldEncoderFactory.java
/**
   * Creates the FieldConverter for all dimensions, for measures return null.
   *
   * @param dataField             column schema
   * @param cache                 dicionary cache.
   * @param absoluteTableIdentifier table identifier
   * @param index                 index of column in the row.
   * @param isEmptyBadRecord
   * @return
   */
Creates the FieldConverter for all dimensions, for measures return null.
@param dataField             column schema
@param cache                 dicionary cache.
@param absoluteTableIdentifier table identifier
@param index                 index of column in the row.
Creates the FieldConverter for all dimensions for measures return null . @param dataField column schema @param cache dicionary cache . @param absoluteTableIdentifier table identifier @param index index of column in the row .
public FieldConverter createFieldEncoder(DataField dataField,
      Cache<DictionaryColumnUniqueIdentifier, Dictionary> cache,
      AbsoluteTableIdentifier absoluteTableIdentifier, int index, String nullFormat,
      DictionaryClient client, Boolean useOnePass,
      Map<Object, Integer> localCache, boolean isEmptyBadRecord)
      throws IOException {
    if (dataField.getColumn().isDimension()) {
      if (dataField.getColumn().hasEncoding(Encoding.DIRECT_DICTIONARY) &&
          !dataField.getColumn().isComplex()) {
        return new DirectDictionaryFieldConverterImpl(dataField, nullFormat, index,
            isEmptyBadRecord);
      } else if (dataField.getColumn().hasEncoding(Encoding.DICTIONARY) &&
          !dataField.getColumn().isComplex()) {
        DictionaryColumnUniqueIdentifier identifier = null;
        if (null == dataField.getColumn().getColumnSchema().getParentColumnTableRelations()
            || dataField.getColumn().getColumnSchema().getParentColumnTableRelations().isEmpty()) {
          identifier = new DictionaryColumnUniqueIdentifier(absoluteTableIdentifier,
              dataField.getColumn().getColumnIdentifier(), dataField.getColumn().getDataType());
          return new DictionaryFieldConverterImpl(dataField, cache, absoluteTableIdentifier,
              nullFormat, index, client, useOnePass, localCache, isEmptyBadRecord,
              identifier);
        } else {
          ParentColumnTableRelation parentColumnTableRelation =
              dataField.getColumn().getColumnSchema().getParentColumnTableRelations().get(0);
          RelationIdentifier relationIdentifier =
              parentColumnTableRelation
                  .getRelationIdentifier();
          CarbonTableIdentifier parentTableIdentifier =
              new CarbonTableIdentifier(relationIdentifier.getDatabaseName(),
                  relationIdentifier.getTableName(), relationIdentifier.getTableId());
          ColumnIdentifier parentColumnIdentifier =
              new ColumnIdentifier(parentColumnTableRelation.getColumnId(), null,
                  dataField.getColumn().getDataType());
          CarbonTablePath carbonTablePath =
              CarbonStorePath.getCarbonTablePath(absoluteTableIdentifier);
          AbsoluteTableIdentifier parentAbsoluteTableIdentifier =
              AbsoluteTableIdentifier.from(
              CarbonUtil.getNewTablePath(carbonTablePath, parentTableIdentifier.getTableName()),
              parentTableIdentifier);
          identifier = new DictionaryColumnUniqueIdentifier(parentAbsoluteTableIdentifier,
              parentColumnIdentifier, dataField.getColumn().getDataType());
          return new DictionaryFieldConverterImpl(dataField, cache, parentAbsoluteTableIdentifier,
              nullFormat, index, null, false, null, isEmptyBadRecord, identifier);
        }
      } else if (dataField.getColumn().isComplex()) {
        return new ComplexFieldConverterImpl(
            createComplexType(dataField, cache, absoluteTableIdentifier,
                client, useOnePass, localCache), index);
      } else {
        return new NonDictionaryFieldConverterImpl(dataField, nullFormat, index, isEmptyBadRecord);
      }
    } else {
      return new MeasureFieldConverterImpl(dataField, nullFormat, index, isEmptyBadRecord);
    }
  }
public FieldConverter createFieldEncoder ( DataField dataField , Cache < DictionaryColumnUniqueIdentifier , Dictionary > cache , AbsoluteTableIdentifier absoluteTableIdentifier , int index , String nullFormat , DictionaryClient client , Boolean useOnePass , Map < Object , Integer > localCache , boolean isEmptyBadRecord ) throws IOException { if ( dataField . getColumn ( ) . isDimension ( ) ) { if ( dataField . getColumn ( ) . hasEncoding ( Encoding . DIRECT_DICTIONARY ) && ! dataField . getColumn ( ) . isComplex ( ) ) { return new DirectDictionaryFieldConverterImpl ( dataField , nullFormat , index , isEmptyBadRecord ) ; } else if ( dataField . getColumn ( ) . hasEncoding ( Encoding . DICTIONARY ) && ! dataField . getColumn ( ) . isComplex ( ) ) { DictionaryColumnUniqueIdentifier identifier = null ; if ( null == dataField . getColumn ( ) . getColumnSchema ( ) . getParentColumnTableRelations ( ) || dataField . getColumn ( ) . getColumnSchema ( ) . getParentColumnTableRelations ( ) . isEmpty ( ) ) { identifier = new DictionaryColumnUniqueIdentifier ( absoluteTableIdentifier , dataField . getColumn ( ) . getColumnIdentifier ( ) , dataField . getColumn ( ) . getDataType ( ) ) ; return new DictionaryFieldConverterImpl ( dataField , cache , absoluteTableIdentifier , nullFormat , index , client , useOnePass , localCache , isEmptyBadRecord , identifier ) ; } else { ParentColumnTableRelation parentColumnTableRelation = dataField . getColumn ( ) . getColumnSchema ( ) . getParentColumnTableRelations ( ) . get ( 0 ) ; RelationIdentifier relationIdentifier = parentColumnTableRelation . getRelationIdentifier ( ) ; CarbonTableIdentifier parentTableIdentifier = new CarbonTableIdentifier ( relationIdentifier . getDatabaseName ( ) , relationIdentifier . getTableName ( ) , relationIdentifier . getTableId ( ) ) ; ColumnIdentifier parentColumnIdentifier = new ColumnIdentifier ( parentColumnTableRelation . getColumnId ( ) , null , dataField . getColumn ( ) . getDataType ( ) ) ; CarbonTablePath carbonTablePath = CarbonStorePath . getCarbonTablePath ( absoluteTableIdentifier ) ; AbsoluteTableIdentifier parentAbsoluteTableIdentifier = AbsoluteTableIdentifier . from ( CarbonUtil . getNewTablePath ( carbonTablePath , parentTableIdentifier . getTableName ( ) ) , parentTableIdentifier ) ; identifier = new DictionaryColumnUniqueIdentifier ( parentAbsoluteTableIdentifier , parentColumnIdentifier , dataField . getColumn ( ) . getDataType ( ) ) ; return new DictionaryFieldConverterImpl ( dataField , cache , parentAbsoluteTableIdentifier , nullFormat , index , null , false , null , isEmptyBadRecord , identifier ) ; } } else if ( dataField . getColumn ( ) . isComplex ( ) ) { return new ComplexFieldConverterImpl ( createComplexType ( dataField , cache , absoluteTableIdentifier , client , useOnePass , localCache ) , index ) ; } else { return new NonDictionaryFieldConverterImpl ( dataField , nullFormat , index , isEmptyBadRecord ) ; } } else { return new MeasureFieldConverterImpl ( dataField , nullFormat , index , isEmptyBadRecord ) ; } }
Creates the FieldConverter for all dimensions, for measures return null.
Creates the FieldConverter for all dimensions for measures return null .
// Converters are only needed for dimensions and measures it return null. // if parent column table relation is not null then it's a child table // in case of child table it will use parent table dictionary