Skip to content

Commit

Permalink
[HUDI-2475] Metadata table creation and bootstrapping from write client
Browse files Browse the repository at this point in the history
 - Incorporating review comments on the variable naming and code style
  • Loading branch information
manojpec authored and nsivabalan committed Nov 26, 2021
1 parent b65bdb3 commit 9665eaa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -737,11 +737,11 @@ public HoodieEngineContext getContext() {
/**
* Get Table metadata writer.
*
* @param inFlightInstantTimestamp - InFlight instant timestamp for which metadata writer is needed
* @param triggeringInstantTimestamp - The instant that is triggering this metadata write
* @return instance of {@link HoodieTableMetadataWriter
*/
public final Option<HoodieTableMetadataWriter> getMetadataWriter(String inFlightInstantTimestamp) {
return getMetadataWriter(inFlightInstantTimestamp, Option.empty());
public final Option<HoodieTableMetadataWriter> getMetadataWriter(String triggeringInstantTimestamp) {
return getMetadataWriter(triggeringInstantTimestamp, Option.empty());
}

/**
Expand All @@ -761,10 +761,10 @@ public final Option<HoodieTableMetadataWriter> getMetadataWriter(String inFlight
* are blocked from doing the similar initial metadata table creation and
* the bootstrapping.
*
* @param inFlightInstantTimestamp - InFlight instant timestamp for which metadata writer is needed
* @param triggeringInstantTimestamp - The instant that is triggering this metadata write
* @return instance of {@link HoodieTableMetadataWriter}
*/
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String inFlightInstantTimestamp,
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String triggeringInstantTimestamp,
Option<T> actionMetadata) {
// Each engine is expected to override this and
// provide the actual metadata writer, if enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ protected HoodieIndex getIndex(HoodieWriteConfig config, HoodieEngineContext con
* @return instance of {@link HoodieTableMetadataWriter}
*/
@Override
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String inFlightInstantTimestamp,
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String triggeringInstantTimestamp,
Option<T> actionMetadata) {
if (config.isMetadataTableEnabled()) {
return Option.of(FlinkHoodieBackedTableMetadataWriter.create(context.getHadoopConf().get(), config,
context, actionMetadata, Option.of(inFlightInstantTimestamp)));
context, actionMetadata, Option.of(triggeringInstantTimestamp)));
} else {
return Option.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public abstract class HoodieSparkTable<T extends HoodieRecordPayload>
extends HoodieTable<T, JavaRDD<HoodieRecord<T>>, JavaRDD<HoodieKey>, JavaRDD<WriteStatus>> {

private volatile boolean isMetadataTableBasePathExists = false;
private volatile boolean isMetadataTableExists = false;

protected HoodieSparkTable(HoodieWriteConfig config, HoodieEngineContext context, HoodieTableMetaClient metaClient) {
super(config, context, metaClient);
Expand Down Expand Up @@ -110,15 +110,18 @@ protected HoodieIndex getIndex(HoodieWriteConfig config, HoodieEngineContext con
* @return instance of {@link HoodieTableMetadataWriter}
*/
@Override
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String inFlightInstantTimestamp,
public <T extends SpecificRecordBase> Option<HoodieTableMetadataWriter> getMetadataWriter(String triggeringInstantTimestamp,
Option<T> actionMetadata) {
if (config.isMetadataTableEnabled()) {
// Create the metadata table writer. First time after the upgrade this creation might trigger
// metadata table bootstrapping. Bootstrapping process could fail and checking the table
// existence after the creation is needed.
final HoodieTableMetadataWriter metadataWriter = SparkHoodieBackedTableMetadataWriter.create(
context.getHadoopConf().get(), config, context, actionMetadata, Option.of(inFlightInstantTimestamp));
context.getHadoopConf().get(), config, context, actionMetadata, Option.of(triggeringInstantTimestamp));
try {
if (isMetadataTableBasePathExists || metaClient.getFs().exists(new Path(
if (isMetadataTableExists || metaClient.getFs().exists(new Path(
HoodieTableMetadata.getMetadataTableBasePath(metaClient.getBasePath())))) {
isMetadataTableBasePathExists = true;
isMetadataTableExists = true;
return Option.of(metadataWriter);
}
} catch (IOException e) {
Expand Down

0 comments on commit 9665eaa

Please sign in to comment.