1
0

[MINOR] optimize hudi timeline service (#1137)

This commit is contained in:
SteNicholas
2019-12-26 06:40:25 +08:00
committed by vinoth chandar
parent 3c811ec29b
commit def18a5086
5 changed files with 8 additions and 10 deletions

View File

@@ -58,7 +58,6 @@ public class FileSystemViewHandler {
private final FileSystemViewManager viewManager;
private final Javalin app;
private final Configuration conf;
private final TimelineHandler instantHandler;
private final FileSliceHandler sliceHandler;
private final DataFileHandler dataFileHandler;
@@ -66,7 +65,6 @@ public class FileSystemViewHandler {
public FileSystemViewHandler(Javalin app, Configuration conf, FileSystemViewManager viewManager) throws IOException {
this.viewManager = viewManager;
this.app = app;
this.conf = conf;
this.instantHandler = new TimelineHandler(conf, viewManager);
this.sliceHandler = new FileSliceHandler(conf, viewManager);
this.dataFileHandler = new DataFileHandler(conf, viewManager);
@@ -94,7 +92,7 @@ public class FileSystemViewHandler {
}
if ((localTimeline.getInstants().count() == 0)
&& lastKnownInstantFromClient.equals(HoodieTimeline.INVALID_INSTANT_TS)) {
&& HoodieTimeline.INVALID_INSTANT_TS.equals(lastKnownInstantFromClient)) {
return false;
}
@@ -131,7 +129,7 @@ public class FileSystemViewHandler {
}
private void writeValueAsString(Context ctx, Object obj) throws JsonProcessingException {
boolean prettyPrint = ctx.queryParam("pretty") != null ? true : false;
boolean prettyPrint = ctx.queryParam("pretty") != null;
long beginJsonTs = System.currentTimeMillis();
String result =
prettyPrint ? OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj) : OBJECT_MAPPER.writeValueAsString(obj);
@@ -267,7 +265,7 @@ public class FileSystemViewHandler {
ctx.validatedQueryParam(RemoteHoodieTableFileSystemView.BASEPATH_PARAM).getOrThrow(),
ctx.validatedQueryParam(RemoteHoodieTableFileSystemView.PARTITION_PARAM).getOrThrow(),
ctx.validatedQueryParam(RemoteHoodieTableFileSystemView.MAX_INSTANT_PARAM).getOrThrow(),
Boolean.valueOf(
Boolean.parseBoolean(
ctx.validatedQueryParam(RemoteHoodieTableFileSystemView.INCLUDE_FILES_IN_PENDING_COMPACTION_PARAM)
.getOrThrow()));
writeValueAsString(ctx, dtos);
@@ -294,7 +292,7 @@ public class FileSystemViewHandler {
}
private static boolean isRefreshCheckDisabledInQuery(Context ctxt) {
return Boolean.valueOf(ctxt.queryParam(RemoteHoodieTableFileSystemView.REFRESH_OFF));
return Boolean.parseBoolean(ctxt.queryParam(RemoteHoodieTableFileSystemView.REFRESH_OFF));
}
/**

View File

@@ -74,7 +74,7 @@ public class TimelineService {
@Parameter(names = {"--server-port", "-p"}, description = " Server Port")
public Integer serverPort = 26754;
@Parameter(names = {"--view-storage", "-st"}, description = "View Storage Type. Defaut - SPILLABLE_DISK")
@Parameter(names = {"--view-storage", "-st"}, description = "View Storage Type. Default - SPILLABLE_DISK")
public FileSystemViewStorageType viewStorageType = FileSystemViewStorageType.SPILLABLE_DISK;
@Parameter(names = {"--max-view-mem-per-table", "-mv"},

View File

@@ -45,7 +45,7 @@ public class DataFileHandler extends Handler {
public List<DataFileDTO> getLatestDataFile(String basePath, String partitionPath, String fileId) {
return viewManager.getFileSystemView(basePath).getLatestDataFile(partitionPath, fileId)
.map(DataFileDTO::fromHoodieDataFile).map(dto -> Arrays.asList(dto)).orElse(new ArrayList<>());
.map(DataFileDTO::fromHoodieDataFile).map(Arrays::asList).orElse(new ArrayList<>());
}
public List<DataFileDTO> getLatestDataFiles(String basePath) {

View File

@@ -75,7 +75,7 @@ public class FileSliceHandler extends Handler {
public List<FileSliceDTO> getLatestFileSlice(String basePath, String partitionPath, String fileId) {
return viewManager.getFileSystemView(basePath).getLatestFileSlice(partitionPath, fileId)
.map(FileSliceDTO::fromFileSlice).map(dto -> Arrays.asList(dto)).orElse(new ArrayList<>());
.map(FileSliceDTO::fromFileSlice).map(Arrays::asList).orElse(new ArrayList<>());
}
public List<CompactionOpDTO> getPendingCompactionOperations(String basePath) {

View File

@@ -40,7 +40,7 @@ public class TimelineHandler extends Handler {
public List<InstantDTO> getLastInstant(String basePath) {
return viewManager.getFileSystemView(basePath).getLastInstant().map(InstantDTO::fromInstant)
.map(dto -> Arrays.asList(dto)).orElse(new ArrayList<>());
.map(Arrays::asList).orElse(new ArrayList<>());
}
public TimelineDTO getTimeline(String basePath) {