use of org.apache.hudi.avro.model.HoodieSavepointMetadata in project hudi by apache.
the class ExportCommand method copyNonArchivedInstants.
private int copyNonArchivedInstants(List<HoodieInstant> instants, int limit, String localFolder) throws Exception {
int copyCount = 0;
if (instants.isEmpty()) {
return limit;
}
final Logger LOG = LogManager.getLogger(ExportCommand.class);
final HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient();
final HoodieActiveTimeline timeline = metaClient.getActiveTimeline();
for (HoodieInstant instant : instants) {
String localPath = localFolder + Path.SEPARATOR + instant.getFileName();
byte[] data = null;
switch(instant.getAction()) {
case HoodieTimeline.CLEAN_ACTION:
{
HoodieCleanMetadata metadata = TimelineMetadataUtils.deserializeHoodieCleanMetadata(timeline.getInstantDetails(instant).get());
data = HoodieAvroUtils.avroToJson(metadata, true);
break;
}
case HoodieTimeline.DELTA_COMMIT_ACTION:
case HoodieTimeline.COMMIT_ACTION:
case HoodieTimeline.COMPACTION_ACTION:
{
// Already in json format
data = timeline.getInstantDetails(instant).get();
break;
}
case HoodieTimeline.ROLLBACK_ACTION:
{
HoodieRollbackMetadata metadata = TimelineMetadataUtils.deserializeHoodieRollbackMetadata(timeline.getInstantDetails(instant).get());
data = HoodieAvroUtils.avroToJson(metadata, true);
break;
}
case HoodieTimeline.SAVEPOINT_ACTION:
{
HoodieSavepointMetadata metadata = TimelineMetadataUtils.deserializeHoodieSavepointMetadata(timeline.getInstantDetails(instant).get());
data = HoodieAvroUtils.avroToJson(metadata, true);
break;
}
default:
{
throw new HoodieException("Unknown type of action " + instant.getAction());
}
}
if (data != null) {
writeToFile(localPath, data);
}
}
return copyCount;
}
Aggregations