Skip to content

Commit

Permalink
Refactor a difficult to read method
Browse files Browse the repository at this point in the history
  • Loading branch information
gortiz committed Oct 10, 2024
1 parent 598b17e commit 75d077f
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,20 @@ private WorkerManager getWorkerManager(SqlNodeAndOptions sqlNodeAndOptions) {
String useImplicitColocatedOptionValue = sqlNodeAndOptions.getOptions()
.get(CommonConstants.Broker.Request.QueryOptionKey.IMPLICIT_COLOCATE_JOIN);
WorkerManager workerManager = _envConfig.getWorkerManager();
if (Boolean.parseBoolean(useImplicitColocatedOptionValue)) {
Objects.requireNonNull(workerManager, "WorkerManager is required for implicit colocated join");
return workerManager;
} else if (useImplicitColocatedOptionValue == null) {
boolean useImplicitColocated = _envConfig.useImplicitColocatedByDefault();
if (useImplicitColocated) {

if (useImplicitColocatedOptionValue == null) {
return _envConfig.useImplicitColocatedByDefault() ? workerManager : null;
}
switch (useImplicitColocatedOptionValue.toLowerCase()) {
case "true":
Objects.requireNonNull(workerManager, "WorkerManager is required for implicit colocated join");
return workerManager;
} else {
case "false":
return null;
}
} else if ("false".equalsIgnoreCase(useImplicitColocatedOptionValue)) {
return null;
} else {
throw new RuntimeException("Invalid value for query option '"
+ CommonConstants.Broker.Request.QueryOptionKey.IMPLICIT_COLOCATE_JOIN + "': "
+ useImplicitColocatedOptionValue);
default:
throw new RuntimeException("Invalid value for query option '"
+ CommonConstants.Broker.Request.QueryOptionKey.IMPLICIT_COLOCATE_JOIN + "': "
+ useImplicitColocatedOptionValue);
}
}

Expand Down

0 comments on commit 75d077f

Please sign in to comment.