feature(hudi-query): Hudi 时间线查询增加 instant 文件创建时间
Hudi 时间线查询增加分页参数下推,增加性能
This commit is contained in:
@@ -12,21 +12,21 @@ import java.util.Map;
|
||||
* @date 2023-04-26
|
||||
*/
|
||||
public class PageResponse<T> {
|
||||
private List<T> data = new ArrayList<>(0);
|
||||
private Iterable<T> data = new ArrayList<>(0);
|
||||
private Long total = 0L;
|
||||
private Map<String, Object> metadata = new HashMap<>();
|
||||
|
||||
public PageResponse() {
|
||||
}
|
||||
|
||||
public PageResponse(List<T> data) {
|
||||
public PageResponse(Iterable<T> data, Long total) {
|
||||
this.data = data;
|
||||
this.total = (long) data.size();
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public PageResponse(List<T> data, Long total) {
|
||||
this(data);
|
||||
this.total = total;
|
||||
public PageResponse(Iterable<T> data, Integer total) {
|
||||
this.data = data;
|
||||
this.total = total.longValue();
|
||||
}
|
||||
|
||||
public PageResponse(List<T> data, Long total, Map<String, Object> metadata) {
|
||||
@@ -34,11 +34,11 @@ public class PageResponse<T> {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public List<T> getData() {
|
||||
public Iterable<T> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<T> data) {
|
||||
public void setData(Iterable<T> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public class HudiInstant implements Comparable<HudiInstant> {
|
||||
private String state;
|
||||
private String timestamp;
|
||||
private String fileName;
|
||||
private Long fileTime = 0L;
|
||||
// active or archive
|
||||
private String type;
|
||||
|
||||
@@ -62,6 +63,13 @@ public class HudiInstant implements Comparable<HudiInstant> {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Long getFileTime() {
|
||||
return fileTime;
|
||||
}
|
||||
|
||||
public void setFileTime(Long fileTime) {
|
||||
this.fileTime = fileTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.lanyuanxiaoyao.service.configuration.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Function;
|
||||
import org.eclipse.collections.api.map.ImmutableMap;
|
||||
|
||||
/**
|
||||
* 生成字段比较器
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-04-21
|
||||
*/
|
||||
public class ComparatorUtil {
|
||||
public static final String ASC = "asc";
|
||||
public static final String DESC = "desc";
|
||||
|
||||
public static <T> Comparator<T> longComparator(String order, String direction, ImmutableMap<String, Function<T, Long>> getters) {
|
||||
if (StrUtil.isBlank(order) || StrUtil.isBlank(direction) || !getters.containsKey(order)) {
|
||||
return (o1, o2) -> 0;
|
||||
}
|
||||
Function<T, Long> getter = getters.get(order);
|
||||
if (DESC.equalsIgnoreCase(direction)) {
|
||||
return (o1, o2) -> Long.compare(getter.apply(o2), getter.apply(o1));
|
||||
} else if (ASC.equalsIgnoreCase(direction)) {
|
||||
return Comparator.comparingLong(getter::apply);
|
||||
} else {
|
||||
return (o1, o2) -> 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Comparator<T> stringComparator(String order, String direction, ImmutableMap<String, Function<T, String>> getters) {
|
||||
if (StrUtil.isBlank(order) || StrUtil.isBlank(direction) || !getters.containsKey(order)) {
|
||||
return (o1, o2) -> 0;
|
||||
}
|
||||
Function<T, String> getter = getters.get(order);
|
||||
if (DESC.equalsIgnoreCase(direction)) {
|
||||
return (o1, o2) -> StrUtil.compare(getter.apply(o2), getter.apply(o1), true);
|
||||
} else if (ASC.equalsIgnoreCase(direction)) {
|
||||
return (o1, o2) -> StrUtil.compare(getter.apply(o1), getter.apply(o2), true);
|
||||
} else {
|
||||
return (o1, o2) -> 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.lanyuanxiaoyao.service.configuration.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 日期工具
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-04-21
|
||||
*/
|
||||
public class DatetimeUtil {
|
||||
public static String fromNow(long now, Supplier<Long> supplier) {
|
||||
if (ObjectUtil.isNotNull(supplier.get()) && supplier.get() != 0) {
|
||||
return fromNow(now, supplier.get());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String fromNow(long now, long target) {
|
||||
long delta = now - target;
|
||||
if (delta == 0) {
|
||||
return "就是现在";
|
||||
}
|
||||
String suffix = delta > 0 ? "前" : "后";
|
||||
delta = Math.abs(delta);
|
||||
if (delta > 31536000000L) {
|
||||
return (int) (delta / 31536000000L) + " 年" + suffix;
|
||||
} else if (delta > 2592000000L) {
|
||||
return (int) (delta / 2592000000L) + " 个月" + suffix;
|
||||
} else if (delta > 604800000L) {
|
||||
return (int) (delta / 604800000L) + " 周" + suffix;
|
||||
} else if (delta > 86400000L) {
|
||||
return (int) (delta / 86400000L) + " 天" + suffix;
|
||||
} else if (delta > 3600000L) {
|
||||
return (int) (delta / 3600000L) + " 小时" + suffix;
|
||||
} else if (delta > 60000L) {
|
||||
return (int) (delta / 60000L) + " 分钟" + suffix;
|
||||
} else if (delta > 1000L) {
|
||||
return (delta / 1000L) + "秒" + suffix;
|
||||
} else {
|
||||
return "就是现在";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user