processing/src/main/java/org/apache/carbondata/processing/store/CarbonFactDataHandlerModel.java
/**
   * Create the model using @{@link CarbonDataLoadConfiguration}
   */
Create the model using @ CarbonDataLoadConfiguration
Create the model using @ CarbonDataLoadConfiguration
public static CarbonFactDataHandlerModel createCarbonFactDataHandlerModel(
      CarbonDataLoadConfiguration configuration, String[] storeLocation, int bucketId,
      int taskExtension) {
    CarbonTableIdentifier identifier =
        configuration.getTableIdentifier().getCarbonTableIdentifier();
    boolean[] isUseInvertedIndex =
        CarbonDataProcessorUtil.getIsUseInvertedIndex(configuration.getDataFields());
    int[] dimLensWithComplex = configuration.getCardinalityFinder().getCardinality();
    if (!configuration.isSortTable()) {
      for (int i = 0; i < dimLensWithComplex.length; i++) {
        if (dimLensWithComplex[i] != 0) {
          dimLensWithComplex[i] = Integer.MAX_VALUE;
        }
      }
    }
    CarbonTable carbonTable = CarbonMetadata.getInstance().getCarbonTable(
        identifier.getDatabaseName(), identifier.getTableName());
    List<ColumnSchema> wrapperColumnSchema = CarbonUtil
        .getColumnSchemaList(carbonTable.getDimensionByTableName(identifier.getTableName()),
            carbonTable.getMeasureByTableName(identifier.getTableName()));
    int[] colCardinality =
        CarbonUtil.getFormattedCardinality(dimLensWithComplex, wrapperColumnSchema);
    SegmentProperties segmentProperties =
        new SegmentProperties(wrapperColumnSchema, colCardinality);
    int[] dimLens = configuration.calcDimensionLengths();
    int dimensionCount = configuration.getDimensionCount();
    int noDictionaryCount = configuration.getNoDictionaryCount();
    int complexDimensionCount = configuration.getComplexColumnCount();
    int measureCount = configuration.getMeasureCount();
    int simpleDimsCount = dimensionCount - noDictionaryCount - complexDimensionCount;
    int[] simpleDimsLen = new int[simpleDimsCount];
    for (int i = 0; i < simpleDimsCount; i++) {
      simpleDimsLen[i] = dimLens[i];
    }
    int surrIndex = simpleDimsCount;
    Iterator<Map.Entry<String, GenericDataType>> complexMap =
        CarbonDataProcessorUtil.getComplexTypesMap(configuration.getDataFields()).entrySet()
            .iterator();
    Map<Integer, GenericDataType> complexIndexMap = new HashMap<>(complexDimensionCount);
    while (complexMap.hasNext()) {
      Map.Entry<String, GenericDataType> complexDataType = complexMap.next();
      complexDataType.getValue().setOutputArrayIndex(0);
      complexIndexMap.put(simpleDimsCount, complexDataType.getValue());
      simpleDimsCount++;
      List<GenericDataType> primitiveTypes = new ArrayList<GenericDataType>();
      complexDataType.getValue().getAllPrimitiveChildren(primitiveTypes);
      for (GenericDataType eachPrimitive : primitiveTypes) {
        eachPrimitive.setSurrogateIndex(surrIndex++);
      }
    }
    CarbonDataFileAttributes carbonDataFileAttributes =
        new CarbonDataFileAttributes(Long.parseLong(configuration.getTaskNo()),
            (Long) configuration.getDataLoadProperty(DataLoadProcessorConstants.FACT_TIME_STAMP));
    String carbonDataDirectoryPath = getCarbonDataFolderLocation(configuration);
    CarbonFactDataHandlerModel carbonFactDataHandlerModel = new CarbonFactDataHandlerModel();
    carbonFactDataHandlerModel.setSchemaUpdatedTimeStamp(configuration.getSchemaUpdatedTimeStamp());
    carbonFactDataHandlerModel.setDatabaseName(
        identifier.getDatabaseName());
    carbonFactDataHandlerModel
        .setTableName(identifier.getTableName());
    carbonFactDataHandlerModel.setMeasureCount(measureCount);
    carbonFactDataHandlerModel.setStoreLocation(storeLocation);
    carbonFactDataHandlerModel.setDimLens(dimLens);
    carbonFactDataHandlerModel.setNoDictionaryCount(noDictionaryCount);
    carbonFactDataHandlerModel.setDimensionCount(
        configuration.getDimensionCount() - noDictionaryCount);
    carbonFactDataHandlerModel.setComplexIndexMap(complexIndexMap);
    carbonFactDataHandlerModel.setSegmentProperties(segmentProperties);
    carbonFactDataHandlerModel.setColCardinality(colCardinality);
    carbonFactDataHandlerModel.setMeasureDataType(configuration.getMeasureDataType());
    carbonFactDataHandlerModel.setWrapperColumnSchema(wrapperColumnSchema);
    carbonFactDataHandlerModel.setPrimitiveDimLens(simpleDimsLen);
    carbonFactDataHandlerModel.setCarbonDataFileAttributes(carbonDataFileAttributes);
    carbonFactDataHandlerModel.setCarbonDataDirectoryPath(carbonDataDirectoryPath);
    carbonFactDataHandlerModel.setIsUseInvertedIndex(isUseInvertedIndex);
    carbonFactDataHandlerModel.setBlockSizeInMB(carbonTable.getBlockSizeInMB());
    carbonFactDataHandlerModel.setComplexDimensionKeyGenerator(
        configuration.createKeyGeneratorForComplexDimension());
    carbonFactDataHandlerModel.bucketId = bucketId;
    carbonFactDataHandlerModel.segmentId = configuration.getSegmentId();
    carbonFactDataHandlerModel.taskExtension = taskExtension;
    carbonFactDataHandlerModel.tableSpec = configuration.getTableSpec();
    carbonFactDataHandlerModel.sortScope = CarbonDataProcessorUtil.getSortScope(configuration);
    DataMapWriterListener listener = new DataMapWriterListener();
    listener.registerAllWriter(configuration.getTableIdentifier(), configuration.getSegmentId());
    carbonFactDataHandlerModel.dataMapWriterlistener = listener;
    carbonFactDataHandlerModel.writingCoresCount = configuration.getWritingCoresCount();
    return carbonFactDataHandlerModel;
  }
public static CarbonFactDataHandlerModel createCarbonFactDataHandlerModel ( CarbonDataLoadConfiguration configuration , String [ ] storeLocation , int bucketId , int taskExtension ) { CarbonTableIdentifier identifier = configuration . getTableIdentifier ( ) . getCarbonTableIdentifier ( ) ; boolean [ ] isUseInvertedIndex = CarbonDataProcessorUtil . getIsUseInvertedIndex ( configuration . getDataFields ( ) ) ; int [ ] dimLensWithComplex = configuration . getCardinalityFinder ( ) . getCardinality ( ) ; if ( ! configuration . isSortTable ( ) ) { for ( int i = 0 ; i < dimLensWithComplex . length ; i ++ ) { if ( dimLensWithComplex [ i ] != 0 ) { dimLensWithComplex [ i ] = Integer . MAX_VALUE ; } } } CarbonTable carbonTable = CarbonMetadata . getInstance ( ) . getCarbonTable ( identifier . getDatabaseName ( ) , identifier . getTableName ( ) ) ; List < ColumnSchema > wrapperColumnSchema = CarbonUtil . getColumnSchemaList ( carbonTable . getDimensionByTableName ( identifier . getTableName ( ) ) , carbonTable . getMeasureByTableName ( identifier . getTableName ( ) ) ) ; int [ ] colCardinality = CarbonUtil . getFormattedCardinality ( dimLensWithComplex , wrapperColumnSchema ) ; SegmentProperties segmentProperties = new SegmentProperties ( wrapperColumnSchema , colCardinality ) ; int [ ] dimLens = configuration . calcDimensionLengths ( ) ; int dimensionCount = configuration . getDimensionCount ( ) ; int noDictionaryCount = configuration . getNoDictionaryCount ( ) ; int complexDimensionCount = configuration . getComplexColumnCount ( ) ; int measureCount = configuration . getMeasureCount ( ) ; int simpleDimsCount = dimensionCount - noDictionaryCount - complexDimensionCount ; int [ ] simpleDimsLen = new int [ simpleDimsCount ] ; for ( int i = 0 ; i < simpleDimsCount ; i ++ ) { simpleDimsLen [ i ] = dimLens [ i ] ; } int surrIndex = simpleDimsCount ; Iterator < Map . Entry < String , GenericDataType > > complexMap = CarbonDataProcessorUtil . getComplexTypesMap ( configuration . getDataFields ( ) ) . entrySet ( ) . iterator ( ) ; Map < Integer , GenericDataType > complexIndexMap = new HashMap < > ( complexDimensionCount ) ; while ( complexMap . hasNext ( ) ) { Map . Entry < String , GenericDataType > complexDataType = complexMap . next ( ) ; complexDataType . getValue ( ) . setOutputArrayIndex ( 0 ) ; complexIndexMap . put ( simpleDimsCount , complexDataType . getValue ( ) ) ; simpleDimsCount ++ ; List < GenericDataType > primitiveTypes = new ArrayList < GenericDataType > ( ) ; complexDataType . getValue ( ) . getAllPrimitiveChildren ( primitiveTypes ) ; for ( GenericDataType eachPrimitive : primitiveTypes ) { eachPrimitive . setSurrogateIndex ( surrIndex ++ ) ; } } CarbonDataFileAttributes carbonDataFileAttributes = new CarbonDataFileAttributes ( Long . parseLong ( configuration . getTaskNo ( ) ) , ( Long ) configuration . getDataLoadProperty ( DataLoadProcessorConstants . FACT_TIME_STAMP ) ) ; String carbonDataDirectoryPath = getCarbonDataFolderLocation ( configuration ) ; CarbonFactDataHandlerModel carbonFactDataHandlerModel = new CarbonFactDataHandlerModel ( ) ; carbonFactDataHandlerModel . setSchemaUpdatedTimeStamp ( configuration . getSchemaUpdatedTimeStamp ( ) ) ; carbonFactDataHandlerModel . setDatabaseName ( identifier . getDatabaseName ( ) ) ; carbonFactDataHandlerModel . setTableName ( identifier . getTableName ( ) ) ; carbonFactDataHandlerModel . setMeasureCount ( measureCount ) ; carbonFactDataHandlerModel . setStoreLocation ( storeLocation ) ; carbonFactDataHandlerModel . setDimLens ( dimLens ) ; carbonFactDataHandlerModel . setNoDictionaryCount ( noDictionaryCount ) ; carbonFactDataHandlerModel . setDimensionCount ( configuration . getDimensionCount ( ) - noDictionaryCount ) ; carbonFactDataHandlerModel . setComplexIndexMap ( complexIndexMap ) ; carbonFactDataHandlerModel . setSegmentProperties ( segmentProperties ) ; carbonFactDataHandlerModel . setColCardinality ( colCardinality ) ; carbonFactDataHandlerModel . setMeasureDataType ( configuration . getMeasureDataType ( ) ) ; carbonFactDataHandlerModel . setWrapperColumnSchema ( wrapperColumnSchema ) ; carbonFactDataHandlerModel . setPrimitiveDimLens ( simpleDimsLen ) ; carbonFactDataHandlerModel . setCarbonDataFileAttributes ( carbonDataFileAttributes ) ; carbonFactDataHandlerModel . setCarbonDataDirectoryPath ( carbonDataDirectoryPath ) ; carbonFactDataHandlerModel . setIsUseInvertedIndex ( isUseInvertedIndex ) ; carbonFactDataHandlerModel . setBlockSizeInMB ( carbonTable . getBlockSizeInMB ( ) ) ; carbonFactDataHandlerModel . setComplexDimensionKeyGenerator ( configuration . createKeyGeneratorForComplexDimension ( ) ) ; carbonFactDataHandlerModel . bucketId = bucketId ; carbonFactDataHandlerModel . segmentId = configuration . getSegmentId ( ) ; carbonFactDataHandlerModel . taskExtension = taskExtension ; carbonFactDataHandlerModel . tableSpec = configuration . getTableSpec ( ) ; carbonFactDataHandlerModel . sortScope = CarbonDataProcessorUtil . getSortScope ( configuration ) ; DataMapWriterListener listener = new DataMapWriterListener ( ) ; listener . registerAllWriter ( configuration . getTableIdentifier ( ) , configuration . getSegmentId ( ) ) ; carbonFactDataHandlerModel . dataMapWriterlistener = listener ; carbonFactDataHandlerModel . writingCoresCount = configuration . getWritingCoresCount ( ) ; return carbonFactDataHandlerModel ; }
Create the model using @{@link CarbonDataLoadConfiguration}
Create the model using @ { @link CarbonDataLoadConfiguration }
//To Set MDKey Index of each primitive type in complex type