[HUDI-3780] improve drop partitions (#5178)
This commit is contained in:
@@ -421,25 +421,6 @@ public class TableSchemaResolver {
|
||||
return latestSchema;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Last commit's Metadata.
|
||||
*/
|
||||
public Option<HoodieCommitMetadata> getLatestCommitMetadata() {
|
||||
try {
|
||||
HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants();
|
||||
if (timeline.lastInstant().isPresent()) {
|
||||
HoodieInstant instant = timeline.lastInstant().get();
|
||||
byte[] data = timeline.getInstantDetails(instant).get();
|
||||
return Option.of(HoodieCommitMetadata.fromBytes(data, HoodieCommitMetadata.class));
|
||||
} else {
|
||||
return Option.empty();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new HoodieException("Failed to get commit metadata", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the parquet schema from a parquet File.
|
||||
*/
|
||||
|
||||
@@ -1336,4 +1336,22 @@ public class HoodieTableMetadataUtil {
|
||||
inflightAndCompletedPartitions.addAll(getCompletedMetadataPartitions(tableConfig));
|
||||
return inflightAndCompletedPartitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last commit's Metadata.
|
||||
*/
|
||||
public static Option<HoodieCommitMetadata> getLatestCommitMetadata(HoodieTableMetaClient metaClient) {
|
||||
try {
|
||||
HoodieTimeline timeline = metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants();
|
||||
if (timeline.lastInstant().isPresent()) {
|
||||
HoodieInstant instant = timeline.lastInstant().get();
|
||||
byte[] data = timeline.getInstantDetails(instant).get();
|
||||
return Option.of(HoodieCommitMetadata.fromBytes(data, HoodieCommitMetadata.class));
|
||||
} else {
|
||||
return Option.empty();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new HoodieException("Failed to get commit metadata", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user