feature(hudi-query): 增加查询 Hudi 表全部时间线的功能

查询全部时间线默认包含已归档的时间线
This commit is contained in:
2023-05-01 15:39:41 +08:00
parent 9073a7706c
commit e2520fa15e
7 changed files with 420 additions and 13 deletions

View File

@@ -0,0 +1,81 @@
package com.lanyuanxiaoyao.service.configuration.entity.hudi;
import java.util.Comparator;
import org.eclipse.collections.api.factory.Maps;
import org.eclipse.collections.api.map.ImmutableMap;
/**
* Instant
*
* @author lanyuanxiaoyao
* @date 2023-05-01
*/
public class HudiInstant implements Comparable<HudiInstant> {
private static final ImmutableMap<String, String> COMPARABLE_ACTIONS = Maps.immutable.of("compaction", "commit");
private static final Comparator<HudiInstant> ACTION_COMPARATOR =
Comparator.comparing(instant -> getComparableAction(instant.getAction()));
private static final Comparator<HudiInstant> COMPARATOR =
Comparator.comparing(HudiInstant::getTimestamp)
.thenComparing(ACTION_COMPARATOR)
.thenComparing(HudiInstant::getState);
private static String getComparableAction(String action) {
return COMPARABLE_ACTIONS.getOrDefault(action, action);
}
private String action;
// REQUESTED, INFLIGHT, COMPLETED, INVALID
private String state;
private String timestamp;
private String fileName;
// active or archive
private String type;
public HudiInstant() {
}
public HudiInstant(String action, String state, String timestamp, String fileName, String type) {
this.action = action;
this.state = state;
this.timestamp = timestamp;
this.fileName = fileName;
this.type = type;
}
public String getAction() {
return action;
}
public String getState() {
return state;
}
public String getTimestamp() {
return timestamp;
}
public String getFileName() {
return fileName;
}
public String getType() {
return type;
}
@Override
public String toString() {
return "HudiInstant{" +
"action='" + action + '\'' +
", state='" + state + '\'' +
", timestamp='" + timestamp + '\'' +
", fileName='" + fileName + '\'' +
", type='" + type + '\'' +
'}';
}
@Override
public int compareTo(HudiInstant o) {
return COMPARATOR.compare(this, o);
}
}