package com.lanyuanxiaoyao.service.configuration.entity.hudi;

import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.map.ImmutableMap;

/**
 * Hudi 压缩计划
 *
 * @author lanyuanxiaoyao
 * @date 2023-05-11
 */
public final class HudiCompactionPlan {
    private Integer version;
    private ImmutableList<Operation> operations;
    private ImmutableMap<String, String> extraMetadata;

    public HudiCompactionPlan() {
    }

    public HudiCompactionPlan(Integer version, ImmutableList<Operation> operations, ImmutableMap<String, String> extraMetadata) {
        this.version = version;
        this.operations = operations;
        this.extraMetadata = extraMetadata;
    }

    public Integer getVersion() {
        return version;
    }

    public ImmutableList<Operation> getOperations() {
        return operations;
    }

    public ImmutableMap<String, String> getExtraMetadata() {
        return extraMetadata;
    }

    @Override
    public String toString() {
        return "HudiCompactionPlan{" +
                "version=" + version +
                ", operations=" + operations +
                ", extraMetadata=" + extraMetadata +
                '}';
    }

    public static final class Operation {
        private String baseInstantTime;
        private ImmutableList<String> deltaFilePaths;
        private String dataFilePath;
        private String fileId;
        private String partitionPath;
        private ImmutableMap<String, Double> metrics;
        private String bootstrapFilePath;

        public Operation() {
        }

        public Operation(String baseInstantTime, ImmutableList<String> deltaFilePaths, String dataFilePath, String fileId, String partitionPath, ImmutableMap<String, Double> metrics, String bootstrapFilePath) {
            this.baseInstantTime = baseInstantTime;
            this.deltaFilePaths = deltaFilePaths;
            this.dataFilePath = dataFilePath;
            this.fileId = fileId;
            this.partitionPath = partitionPath;
            this.metrics = metrics;
            this.bootstrapFilePath = bootstrapFilePath;
        }

        public String getBaseInstantTime() {
            return baseInstantTime;
        }

        public ImmutableList<String> getDeltaFilePaths() {
            return deltaFilePaths;
        }

        public String getDataFilePath() {
            return dataFilePath;
        }

        public String getFileId() {
            return fileId;
        }

        public String getPartitionPath() {
            return partitionPath;
        }

        public ImmutableMap<String, Double> getMetrics() {
            return metrics;
        }

        public String getBootstrapFilePath() {
            return bootstrapFilePath;
        }

        @Override
        public String toString() {
            return "Operation{" +
                    "baseInstantTime='" + baseInstantTime + '\'' +
                    ", deltaFilePaths=" + deltaFilePaths +
                    ", dataFilePath='" + dataFilePath + '\'' +
                    ", fileId='" + fileId + '\'' +
                    ", partitionPath='" + partitionPath + '\'' +
                    ", metrics=" + metrics +
                    ", bootstrapFilePath='" + bootstrapFilePath + '\'' +
                    '}';
        }
    }
}
