Skip to content

Commit

Permalink
[AMORO-3218] Fix logic for consturct the result of optimizer tables api
Browse files Browse the repository at this point in the history
  • Loading branch information
klion26 committed Sep 30, 2024
1 parent dc8f32f commit 86b3c08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

/** The controller that handles optimizer requests. */
Expand Down Expand Up @@ -75,10 +76,15 @@ public void getOptimizerTables(Context ctx) {
List<TableRuntime> tableRuntimes =
tableRuntimeBeans.stream()
.map(meta -> tableService.getRuntime(meta.getTableId()))
.filter(Objects::nonNull)
.collect(Collectors.toList());

PageResult<TableOptimizingInfo> amsPageResult =
PageResult.of(tableRuntimes, offset, pageSize, OptimizingUtil::buildTableOptimizeInfo);
PageResult.of(
tableRuntimes.stream()
.map(OptimizingUtil::buildTableOptimizeInfo)
.collect(Collectors.toList()),
tableService.getRuntimeCount());
ctx.json(OkResponse.of(amsPageResult));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ public TableRuntime getRuntime(Long tableId) {
return tableRuntimeMap.get(tableId);
}

public int getRuntimeCount() {
checkStarted();
return tableRuntimeMap.size();
}

@Override
public boolean contains(Long tableId) {
checkStarted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public interface TableManager extends TableRuntimeHandler {

TableRuntime getRuntime(Long tableId);

int getRuntimeCount();

default boolean contains(Long tableId) {
return getRuntime(tableId) != null;
}
Expand Down

0 comments on commit 86b3c08

Please sign in to comment.