All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.uber.hoodie.common.HoodieCleanStat Maven / Gradle / Ivy

There is a newer version: 0.4.7
Show newest version
/*
 *  Copyright (c) 2016 Uber Technologies, Inc. ([email protected])
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *           http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.uber.hoodie.common;

import com.uber.hoodie.common.model.HoodieCleaningPolicy;
import com.uber.hoodie.common.table.timeline.HoodieInstant;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;

/**
 * Collects stats about a single partition clean operation
 */
public class HoodieCleanStat implements Serializable {

  // Policy used
  private final HoodieCleaningPolicy policy;
  // Partition path cleaned
  private final String partitionPath;
  // The patterns that were generated for the delete operation
  private final List deletePathPatterns;
  private final List successDeleteFiles;
  // Files that could not be deleted
  private final List failedDeleteFiles;
  // Earliest commit that was retained in this clean
  private final String earliestCommitToRetain;

  public HoodieCleanStat(HoodieCleaningPolicy policy, String partitionPath,
      List deletePathPatterns, List successDeleteFiles,
      List failedDeleteFiles, String earliestCommitToRetain) {
    this.policy = policy;
    this.partitionPath = partitionPath;
    this.deletePathPatterns = deletePathPatterns;
    this.successDeleteFiles = successDeleteFiles;
    this.failedDeleteFiles = failedDeleteFiles;
    this.earliestCommitToRetain = earliestCommitToRetain;
  }

  public HoodieCleaningPolicy getPolicy() {
    return policy;
  }

  public String getPartitionPath() {
    return partitionPath;
  }

  public List getDeletePathPatterns() {
    return deletePathPatterns;
  }

  public List getSuccessDeleteFiles() {
    return successDeleteFiles;
  }

  public List getFailedDeleteFiles() {
    return failedDeleteFiles;
  }

  public String getEarliestCommitToRetain() {
    return earliestCommitToRetain;
  }

  public static HoodieCleanStat.Builder newBuilder() {
    return new Builder();
  }

  public static class Builder {

    private HoodieCleaningPolicy policy;
    private List deletePathPatterns;
    private List successDeleteFiles;
    private List failedDeleteFiles;
    private String partitionPath;
    private String earliestCommitToRetain;

    public Builder withPolicy(HoodieCleaningPolicy policy) {
      this.policy = policy;
      return this;
    }

    public Builder withDeletePathPattern(List deletePathPatterns) {
      this.deletePathPatterns = deletePathPatterns;
      return this;
    }

    public Builder withSuccessfulDeletes(List successDeleteFiles) {
      this.successDeleteFiles = successDeleteFiles;
      return this;
    }

    public Builder withFailedDeletes(List failedDeleteFiles) {
      this.failedDeleteFiles = failedDeleteFiles;
      return this;
    }

    public Builder withPartitionPath(String partitionPath) {
      this.partitionPath = partitionPath;
      return this;
    }

    public Builder withEarliestCommitRetained(Optional earliestCommitToRetain) {
      this.earliestCommitToRetain = (earliestCommitToRetain.isPresent()) ?
          earliestCommitToRetain.get().getTimestamp() :
          "-1";
      return this;
    }

    public HoodieCleanStat build() {
      return new HoodieCleanStat(policy, partitionPath, deletePathPatterns,
          successDeleteFiles, failedDeleteFiles, earliestCommitToRetain);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy