Skip to content

Commit

Permalink
Refactor getDataSourceNames method logic for reducing loop (apache#19159
Browse files Browse the repository at this point in the history
)

* Refactor getDataSourceNames method logic for reducing loop

* Refactor name and javadoc of ReadQueryLoadBalanceAlgorithm implementation class

* Inline datasourceName to add method

* Revert "Refactor name and javadoc of ReadQueryLoadBalanceAlgorithm implementation class"

This reverts commit b08335d.
  • Loading branch information
strongduanmu authored Jul 15, 2022
1 parent 0fe7f40 commit dbeef68
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ private static Collection<String> parseDateSource(final String dateSource) {
}

private static Collection<String> getDataSourceNames(final Collection<String> actualDataNodes) {
return actualDataNodes.stream().map(each -> {
if (isValidDataNode(each)) {
return actualDataNodes.stream().map(each1 -> new DataNode(each1).getDataSourceName()).collect(Collectors.toList());
}
return Collections.singletonList(each);
}).flatMap(Collection::stream).collect(Collectors.toCollection(LinkedHashSet::new));
Collection<String> result = new HashSet<>();
for (String each : actualDataNodes) {
result.add(isValidDataNode(each) ? new DataNode(each).getDataSourceName() : each);
}
return result;
}

private static Collection<String> getDataSourceNames(final Collection<ShardingTableRuleConfiguration> tableRuleConfigs,
Expand Down

0 comments on commit dbeef68

Please sign in to comment.