Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code optimization #561

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class WorkSpaceConfiguration {
public static final CommonVars<Integer> FILESYSTEM_RESULTSET_ROW_LIMIT =
CommonVars$.MODULE$.apply("linkis.filesystem.resultset.row.limit", 100000);

public static final CommonVars<Integer> FILESYSTEM_RESULT_SET_COLUMN_LIMIT =
CommonVars$.MODULE$.apply("linkis.filesystem.result.set.column.limit", 10000);

public static final CommonVars<Boolean> FILESYSTEM_JVM_USER_SWITCH =
CommonVars$.MODULE$.apply("linkis.filesystem.jvm.user.switch", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ public class WorkspaceExceptionManager {
"The result set exceeds {0} rows and page viewing is currently not supported. Please download to view or view in the shared directory(结果集行数超过{0}行,暂不支持页面查看。请下载查看或在共享目录中查看)");
put(
"80035",
"Parameter error, column index order is incorrect, please pass parameters in ascending order (参数错误,列索引顺序不正确,请按升序传参)");
"Parameter error, column index order is incorrect, please pass parameters in ascending order (参数错误,列索引顺序不正确或范围错误,请传入非复数并按升序传参)");
put(
"80036",
"Parameter error, page size is incorrect, please pass in a number within [1-500] (参数错误,分页大小不正确,请传入[1-500]内的数)");
"Parameter error, page size is incorrect, please pass in a number within [1-500] (分页参数错误,页码从1开始,页大小需在[1-500]范围内)");
put(
"80037",
"Parameter error, page size is incorrect, please pass in a number within [1-500] (参数错误,列筛选最多支持筛选50列)");
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,6 @@ public Message fileInfo(
dataType = "String",
defaultValue = ""),
@ApiImplicitParam(name = "columnIndices", required = false, dataType = "array"),
@ApiImplicitParam(
name = "columnIndex",
required = false,
dataType = "Integer",
defaultValue = "0"),
@ApiImplicitParam(
name = "columnPageSize",
required = false,
Expand All @@ -623,7 +618,6 @@ public Message openFile(
@RequestParam(value = "pageSize", defaultValue = "5000") Integer pageSize,
@RequestParam(value = "nullValue", defaultValue = "") String nullValue,
@RequestParam(value = "enableLimit", defaultValue = "") String enableLimit,
@RequestParam(value = "columnIndices", required = false) int[] columnIndices,
@RequestParam(value = "columnPage", required = false, defaultValue = "1") Integer columnPage,
@RequestParam(value = "columnPageSize", required = false, defaultValue = "500")
Integer columnPageSize)
Expand All @@ -634,18 +628,12 @@ public Message openFile(
throw WorkspaceExceptionManager.createException(80004, path);
}

if (columnPageSize < 1 || columnPageSize > 500) {
if (columnPage < 1 || columnPageSize < 1 || columnPageSize > 500) {
throw WorkspaceExceptionManager.createException(80036, path);
}

// 组装列索引
if (columnIndices == null || columnIndices.length == 0) {
columnIndices = genColumnIndices(columnPage, columnPageSize);
} else {
if (!isAscending(columnIndices)) {
throw WorkspaceExceptionManager.createException(80035);
}
}
int[] columnIndices = genColumnIndices(columnPage, columnPageSize);

String userName = ModuleUserUtils.getOperationUser(req, "openFile " + path);
LoggerUtils.setJobIdMDC("openFileThread_" + userName);
Expand Down Expand Up @@ -707,9 +695,13 @@ public Message openFile(
Map[] realMap = (Map[]) metaMap;
int realSize = realMap.length;
message.data("totalColumn", realSize);
if (realSize > 10000) {
if (realSize > FILESYSTEM_RESULT_SET_COLUMN_LIMIT.getValue()) {
message.data("column_limit_display", true);
message.data("zh_msg", "全量结果集超过10000列,页面提供500列数据预览,如需查看完整结果集,请使用结果集导出功能");
message.data(
"zh_msg",
"全量结果集超过"
+ FILESYSTEM_RESULT_SET_COLUMN_LIMIT.getValue()
+ "列,页面提供500列数据预览,如需查看完整结果集,请使用结果集导出功能");
message.data(
"en_msg",
"Because your result set is large, to view the full result set, use the Result set Export feature.");
Expand Down Expand Up @@ -786,7 +778,7 @@ private static boolean isAscending(int[] array) {
return true;
}
for (int i = 0; i < array.length - 1; i++) {
if (array[i] > array[i + 1]) {
if (array[i] >= array[i + 1] || array[i] < 0 || array[i + 1] < 0) {
return false;
}
}
Expand Down
Loading