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

Refactor ShadowRule #33547

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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 @@ -132,9 +132,9 @@ public Collection<String> getAllShadowTableNames() {
}

/**
* Get related hint shadow algorithms.
* Get all hint shadow algorithms.
*
* @return related hint shadow algorithms
* @return all hint shadow algorithms
*/
@HighFrequencyInvocation
@SuppressWarnings("unchecked")
Expand All @@ -158,8 +158,7 @@ public Collection<HintShadowAlgorithm<Comparable<?>>> getAllHintShadowAlgorithms
@SuppressWarnings("unchecked")
public Collection<HintShadowAlgorithm<Comparable<?>>> getHintShadowAlgorithms(final String tableName) {
Collection<HintShadowAlgorithm<Comparable<?>>> result = new LinkedList<>();
Collection<String> hintShadowAlgorithmNames = tableRules.get(tableName).getHintShadowAlgorithmNames();
for (String each : hintShadowAlgorithmNames) {
for (String each : tableRules.get(tableName).getHintShadowAlgorithmNames()) {
result.add((HintShadowAlgorithm<Comparable<?>>) shadowAlgorithms.get(each));
}
return result;
Expand All @@ -168,16 +167,16 @@ public Collection<HintShadowAlgorithm<Comparable<?>>> getHintShadowAlgorithms(fi
/**
* Get column shadow algorithms.
*
* @param shadowOperationType shadow operation type
* @param operationType shadow operation type
* @param tableName table name
* @param shadowColumnName shadow column name
* @return column shadow algorithms
*/
@HighFrequencyInvocation
@SuppressWarnings("unchecked")
public Collection<ColumnShadowAlgorithm<Comparable<?>>> getColumnShadowAlgorithms(final ShadowOperationType shadowOperationType, final String tableName, final String shadowColumnName) {
public Collection<ColumnShadowAlgorithm<Comparable<?>>> getColumnShadowAlgorithms(final ShadowOperationType operationType, final String tableName, final String shadowColumnName) {
Collection<ColumnShadowAlgorithm<Comparable<?>>> result = new LinkedList<>();
for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(shadowOperationType, Collections.emptyList())) {
for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(operationType, Collections.emptyList())) {
if (shadowColumnName.equals(each.getShadowColumnName())) {
result.add((ColumnShadowAlgorithm<Comparable<?>>) shadowAlgorithms.get(each.getShadowAlgorithmName()));
}
Expand All @@ -188,14 +187,14 @@ public Collection<ColumnShadowAlgorithm<Comparable<?>>> getColumnShadowAlgorithm
/**
* Get shadow column names.
*
* @param shadowOperationType shadow operation type
* @param operationType shadow operation type
* @param tableName table name
* @return got shadow column names
*/
@HighFrequencyInvocation
public Collection<String> getShadowColumnNames(final ShadowOperationType shadowOperationType, final String tableName) {
public Collection<String> getShadowColumnNames(final ShadowOperationType operationType, final String tableName) {
Collection<String> result = new LinkedList<>();
for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(shadowOperationType, Collections.emptyList())) {
for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(operationType, Collections.emptyList())) {
result.add(each.getShadowColumnName());
}
return result;
Expand Down