hudi-common/src/main/java/org/apache/hudi/common/table/HoodieTableMetaClient.java
/**
   * Helper method to initialize a given path as a hoodie table with configs passed in as as Properties.
   *
   * @return Instance of HoodieTableMetaClient
   */
Helper method to initialize a given path as a hoodie table with configs passed in as as Properties.
@return Instance of HoodieTableMetaClient
Helper method to initialize a given path as a hoodie table with configs passed in as as Properties . @return Instance of HoodieTableMetaClient
public static HoodieTableMetaClient initTableAndGetMetaClient(Configuration hadoopConf, String basePath,
      Properties props) throws IOException {
    LOG.info("Initializing " + basePath + " as hoodie table " + basePath);
    Path basePathDir = new Path(basePath);
    final FileSystem fs = FSUtils.getFs(basePath, hadoopConf);
    if (!fs.exists(basePathDir)) {
      fs.mkdirs(basePathDir);
    }
    Path metaPathDir = new Path(basePath, METAFOLDER_NAME);
    if (!fs.exists(metaPathDir)) {
      fs.mkdirs(metaPathDir);
    }
    String archiveLogPropVal = props.getProperty(HoodieTableConfig.HOODIE_ARCHIVELOG_FOLDER_PROP_NAME,
        HoodieTableConfig.DEFAULT_ARCHIVELOG_FOLDER);
    if (!archiveLogPropVal.equals(HoodieTableConfig.DEFAULT_ARCHIVELOG_FOLDER)) {
      Path archiveLogDir = new Path(metaPathDir, archiveLogPropVal);
      if (!fs.exists(archiveLogDir)) {
        fs.mkdirs(archiveLogDir);
      }
    }
    final Path temporaryFolder = new Path(basePath, HoodieTableMetaClient.TEMPFOLDER_NAME);
    if (!fs.exists(temporaryFolder)) {
      fs.mkdirs(temporaryFolder);
    }
    final Path auxiliaryFolder = new Path(basePath, HoodieTableMetaClient.AUXILIARYFOLDER_NAME);
    if (!fs.exists(auxiliaryFolder)) {
      fs.mkdirs(auxiliaryFolder);
    }
    initializeBootstrapDirsIfNotExists(hadoopConf, basePath, fs);
    HoodieTableConfig.createHoodieProperties(fs, metaPathDir, props);
    HoodieTableMetaClient metaClient = new HoodieTableMetaClient(hadoopConf, basePath);
    LOG.info("Finished initializing Table of type " + metaClient.getTableConfig().getTableType() + " from " + basePath);
    return metaClient;
  }
public static HoodieTableMetaClient initTableAndGetMetaClient ( Configuration hadoopConf , String basePath , Properties props ) throws IOException { LOG . info ( "Initializing " + basePath + " as hoodie table " + basePath ) ; Path basePathDir = new Path ( basePath ) ; final FileSystem fs = FSUtils . getFs ( basePath , hadoopConf ) ; if ( ! fs . exists ( basePathDir ) ) { fs . mkdirs ( basePathDir ) ; } Path metaPathDir = new Path ( basePath , METAFOLDER_NAME ) ; if ( ! fs . exists ( metaPathDir ) ) { fs . mkdirs ( metaPathDir ) ; } String archiveLogPropVal = props . getProperty ( HoodieTableConfig . HOODIE_ARCHIVELOG_FOLDER_PROP_NAME , HoodieTableConfig . DEFAULT_ARCHIVELOG_FOLDER ) ; if ( ! archiveLogPropVal . equals ( HoodieTableConfig . DEFAULT_ARCHIVELOG_FOLDER ) ) { Path archiveLogDir = new Path ( metaPathDir , archiveLogPropVal ) ; if ( ! fs . exists ( archiveLogDir ) ) { fs . mkdirs ( archiveLogDir ) ; } } final Path temporaryFolder = new Path ( basePath , HoodieTableMetaClient . TEMPFOLDER_NAME ) ; if ( ! fs . exists ( temporaryFolder ) ) { fs . mkdirs ( temporaryFolder ) ; } final Path auxiliaryFolder = new Path ( basePath , HoodieTableMetaClient . AUXILIARYFOLDER_NAME ) ; if ( ! fs . exists ( auxiliaryFolder ) ) { fs . mkdirs ( auxiliaryFolder ) ; } initializeBootstrapDirsIfNotExists ( hadoopConf , basePath , fs ) ; HoodieTableConfig . createHoodieProperties ( fs , metaPathDir , props ) ; HoodieTableMetaClient metaClient = new HoodieTableMetaClient ( hadoopConf , basePath ) ; LOG . info ( "Finished initializing Table of type " + metaClient . getTableConfig ( ) . getTableType ( ) + " from " + basePath ) ; return metaClient ; }
Helper method to initialize a given path as a hoodie table with configs passed in as as Properties.
Helper method to initialize a given path as a hoodie table with configs passed in as as Properties .
// if anything other than default archive log folder is specified, create that too // Always create temporaryFolder which is needed for finalizeWrite for Hoodie tables // Always create auxiliary folder which is needed to track compaction workloads (stats and any metadata in future) // We should not use fs.getConf as this might be different from the original configuration // used to create the fs in unit tests