Search in sources :

Example 1 with DELTA_COMMIT_ACTION

use of org.apache.hudi.common.table.timeline.HoodieTimeline.DELTA_COMMIT_ACTION in project hudi by apache.

the class ConcurrentOperation method init.

private void init(HoodieInstant instant) {
    if (this.metadataWrapper.isAvroMetadata()) {
        switch(getInstantActionType()) {
            case COMPACTION_ACTION:
                this.operationType = WriteOperationType.COMPACT;
                this.mutatedFileIds = this.metadataWrapper.getMetadataFromTimeline().getHoodieCompactionPlan().getOperations().stream().map(op -> op.getFileId()).collect(Collectors.toSet());
                break;
            case COMMIT_ACTION:
            case DELTA_COMMIT_ACTION:
                this.mutatedFileIds = CommitUtils.getFileIdWithoutSuffixAndRelativePathsFromSpecificRecord(this.metadataWrapper.getMetadataFromTimeline().getHoodieCommitMetadata().getPartitionToWriteStats()).keySet();
                this.operationType = WriteOperationType.fromValue(this.metadataWrapper.getMetadataFromTimeline().getHoodieCommitMetadata().getOperationType());
                break;
            case REPLACE_COMMIT_ACTION:
                if (instant.isCompleted()) {
                    this.mutatedFileIds = CommitUtils.getFileIdWithoutSuffixAndRelativePathsFromSpecificRecord(this.metadataWrapper.getMetadataFromTimeline().getHoodieReplaceCommitMetadata().getPartitionToWriteStats()).keySet();
                    this.operationType = WriteOperationType.fromValue(this.metadataWrapper.getMetadataFromTimeline().getHoodieReplaceCommitMetadata().getOperationType());
                } else {
                    HoodieRequestedReplaceMetadata requestedReplaceMetadata = this.metadataWrapper.getMetadataFromTimeline().getHoodieRequestedReplaceMetadata();
                    this.mutatedFileIds = requestedReplaceMetadata.getClusteringPlan().getInputGroups().stream().flatMap(ig -> ig.getSlices().stream()).map(file -> file.getFileId()).collect(Collectors.toSet());
                    this.operationType = WriteOperationType.CLUSTER;
                }
                break;
            default:
                throw new IllegalArgumentException("Unsupported Action Type " + getInstantActionType());
        }
    } else {
        switch(getInstantActionType()) {
            case COMMIT_ACTION:
            case DELTA_COMMIT_ACTION:
                this.mutatedFileIds = CommitUtils.getFileIdWithoutSuffixAndRelativePaths(this.metadataWrapper.getCommitMetadata().getPartitionToWriteStats()).keySet();
                this.operationType = this.metadataWrapper.getCommitMetadata().getOperationType();
                break;
            default:
                throw new IllegalArgumentException("Unsupported Action Type " + getInstantActionType());
        }
    }
}
Also used : HoodieMetadataWrapper(org.apache.hudi.common.model.HoodieMetadataWrapper) COMMIT_ACTION(org.apache.hudi.common.table.timeline.HoodieTimeline.COMMIT_ACTION) REPLACE_COMMIT_ACTION(org.apache.hudi.common.table.timeline.HoodieTimeline.REPLACE_COMMIT_ACTION) HoodieInstant(org.apache.hudi.common.table.timeline.HoodieInstant) Set(java.util.Set) IOException(java.io.IOException) HoodieCommitMetadata(org.apache.hudi.common.model.HoodieCommitMetadata) Option(org.apache.hudi.common.util.Option) CommitUtils(org.apache.hudi.common.util.CommitUtils) Collectors(java.util.stream.Collectors) COMPACTION_ACTION(org.apache.hudi.common.table.timeline.HoodieTimeline.COMPACTION_ACTION) HoodieRequestedReplaceMetadata(org.apache.hudi.avro.model.HoodieRequestedReplaceMetadata) MetadataConversionUtils(org.apache.hudi.client.utils.MetadataConversionUtils) HoodieTableMetaClient(org.apache.hudi.common.table.HoodieTableMetaClient) DELTA_COMMIT_ACTION(org.apache.hudi.common.table.timeline.HoodieTimeline.DELTA_COMMIT_ACTION) WriteOperationType(org.apache.hudi.common.model.WriteOperationType) Collections(java.util.Collections) HoodieRequestedReplaceMetadata(org.apache.hudi.avro.model.HoodieRequestedReplaceMetadata)

Aggregations

IOException (java.io.IOException)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 HoodieRequestedReplaceMetadata (org.apache.hudi.avro.model.HoodieRequestedReplaceMetadata)1 MetadataConversionUtils (org.apache.hudi.client.utils.MetadataConversionUtils)1 HoodieCommitMetadata (org.apache.hudi.common.model.HoodieCommitMetadata)1 HoodieMetadataWrapper (org.apache.hudi.common.model.HoodieMetadataWrapper)1 WriteOperationType (org.apache.hudi.common.model.WriteOperationType)1 HoodieTableMetaClient (org.apache.hudi.common.table.HoodieTableMetaClient)1 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)1 COMMIT_ACTION (org.apache.hudi.common.table.timeline.HoodieTimeline.COMMIT_ACTION)1 COMPACTION_ACTION (org.apache.hudi.common.table.timeline.HoodieTimeline.COMPACTION_ACTION)1 DELTA_COMMIT_ACTION (org.apache.hudi.common.table.timeline.HoodieTimeline.DELTA_COMMIT_ACTION)1 REPLACE_COMMIT_ACTION (org.apache.hudi.common.table.timeline.HoodieTimeline.REPLACE_COMMIT_ACTION)1 CommitUtils (org.apache.hudi.common.util.CommitUtils)1 Option (org.apache.hudi.common.util.Option)1