Skip to content

Commit

Permalink
Merge 2 constructors became 1 on LocalDataQueryResultRow (#30095)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Feb 11, 2024
1 parent b898ded commit 9e22577
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Collection<LocalDataQueryResultRow> buildColumnData(final EncryptTableRu
AlgorithmConfiguration encryptorAlgorithmConfig = encryptors.get(each.getCipher().getEncryptorName());
AlgorithmConfiguration assistedQueryEncryptorAlgorithmConfig = each.getAssistedQuery().isPresent() ? encryptors.get(each.getAssistedQuery().get().getEncryptorName()) : null;
AlgorithmConfiguration likeQueryEncryptorAlgorithmConfig = each.getLikeQuery().isPresent() ? encryptors.get(each.getLikeQuery().get().getEncryptorName()) : null;
result.add(new LocalDataQueryResultRow(Arrays.asList(
result.add(new LocalDataQueryResultRow(
tableRuleConfig.getName(),
each.getName(),
each.getCipher().getName(),
Expand All @@ -79,7 +79,7 @@ private Collection<LocalDataQueryResultRow> buildColumnData(final EncryptTableRu
null == assistedQueryEncryptorAlgorithmConfig ? "" : assistedQueryEncryptorAlgorithmConfig.getType(),
null == assistedQueryEncryptorAlgorithmConfig ? "" : PropertiesConverter.convert(assistedQueryEncryptorAlgorithmConfig.getProps()),
null == likeQueryEncryptorAlgorithmConfig ? "" : likeQueryEncryptorAlgorithmConfig.getType(),
null == likeQueryEncryptorAlgorithmConfig ? "" : PropertiesConverter.convert(likeQueryEncryptorAlgorithmConfig.getProps()))));
null == likeQueryEncryptorAlgorithmConfig ? "" : PropertiesConverter.convert(likeQueryEncryptorAlgorithmConfig.getProps())));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ private Collection<LocalDataQueryResultRow> buildColumnData(final MaskTableRuleC
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
tableRuleConfig.getColumns().forEach(each -> {
AlgorithmConfiguration maskAlgorithmConfig = algorithmMap.get(each.getMaskAlgorithm());
result.add(new LocalDataQueryResultRow(
Arrays.asList(tableRuleConfig.getName(), each.getLogicColumn(), maskAlgorithmConfig.getType(), PropertiesConverter.convert(maskAlgorithmConfig.getProps()))));
result.add(new LocalDataQueryResultRow(tableRuleConfig.getName(), each.getLogicColumn(), maskAlgorithmConfig.getType(), PropertiesConverter.convert(maskAlgorithmConfig.getProps())));
});
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ private Collection<LocalDataQueryResultRow> buildColumnData(final ShadowDataSour
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
dataSourceTable.forEach((key, value) -> value.getShadowAlgorithmNames().forEach(each -> {
AlgorithmConfiguration algorithmConfig = algorithmConfigs.get(each);
result.add(new LocalDataQueryResultRow(Arrays.asList(key, dataSourceConfig.getName(), dataSourceConfig.getProductionDataSourceName(), dataSourceConfig.getShadowDataSourceName(),
algorithmConfig.getType(), PropertiesConverter.convert(algorithmConfig.getProps()))));
result.add(new LocalDataQueryResultRow(key, dataSourceConfig.getName(), dataSourceConfig.getProductionDataSourceName(), dataSourceConfig.getShadowDataSourceName(),
algorithmConfig.getType(), PropertiesConverter.convert(algorithmConfig.getProps())));
}));
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
package org.apache.shardingsphere.infra.merge.result.impl.local;

import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;

/**
* Local data query result row.
*/
@RequiredArgsConstructor
public final class LocalDataQueryResultRow {

private final List<Object> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -59,22 +58,19 @@ void assertGetCalendarValue() {

@Test
void assertGetInputStream() {
List<Object> row = Collections.singletonList("value");
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow(row)));
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow("value")));
assertThrows(SQLFeatureNotSupportedException.class, () -> actual.getInputStream(1, "Ascii"));
}

@Test
void assertGetCharacterStream() {
List<Object> row = Collections.singletonList("value");
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow(row)));
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow("value")));
assertThrows(SQLFeatureNotSupportedException.class, () -> actual.getCharacterStream(1));
}

@Test
void assertWasNull() {
List<Object> row = Collections.singletonList("value");
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow(row)));
LocalDataMergedResult actual = new LocalDataMergedResult(Collections.singletonList(new LocalDataQueryResultRow("value")));
assertTrue(actual.next());
assertFalse(actual.wasNull());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
* Show migration source storage units executor.
Expand All @@ -51,7 +50,7 @@ public Collection<LocalDataQueryResultRow> getRows(final ShowMigrationSourceStor
Iterator<Collection<Object>> data = jobAPI.listMigrationSourceResources(new PipelineContextKey(InstanceType.PROXY)).iterator();
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
while (data.hasNext()) {
result.add(new LocalDataQueryResultRow((List<Object>) data.next()));
result.add(new LocalDataQueryResultRow(data.next().toArray()));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void execute(final ConnectionSession connectionSession) {
metaData.add(new RawQueryResultColumnMetaData("", name, name, Types.VARCHAR, "VARCHAR", 1024, 0));
}
queryResultMetaData = new RawQueryResultMetaData(metaData);
mergedResult = new LocalDataMergedResult(Collections.singleton(new LocalDataQueryResultRow(columnsOfRow)));
mergedResult = new LocalDataMergedResult(Collections.singleton(new LocalDataQueryResultRow(columnsOfRow.toArray())));
}

/**
Expand Down

0 comments on commit 9e22577

Please sign in to comment.