LuciferYang commented on code in PR #37843:
URL: https://github.com/apache/spark/pull/37843#discussion_r967610013
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Expression.java:
##########
@@ -44,7 +44,16 @@ public interface Expression {
* List of fields or columns that are referenced by this expression.
*/
default NamedReference[] references() {
Review Comment:
Compare
```
public static TestValue[] distinctUseStreamApi(TestObj[] input) {
return Arrays.stream(input).map(s -> s.values)
.flatMap(Arrays::stream).distinct().toArray(TestValue[]::new);
}
```
and
```
public static TestValue[] distinctUseLoopApi(TestObj[] input) {
List<TestValue> list = new ArrayList<>();
Set<TestValue> uniqueValues = new HashSet<>();
for (TestObj s : input) {
TestValue[] values = s.values;
for (TestValue testValue : values) {
if (uniqueValues.add(testValue)) {
list.add(testValue);
}
}
}
return list.toArray(new TestValue[0]);
}
```
`TestValue` and `TestObj` define as follows:
```
public static class TestObj {
TestValue[] values;
public TestObj(int size, int range) {
values = new TestValue[size];
for (int i = 0; i < values.length; i++) {
values[i] = new TestValue(RandomUtils.nextInt(0, range));
}
}
}
public static class TestValue {
private int value;
public TestValue(int value) {
this.value = value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestValue testValue = (TestValue) o;
return value == testValue.value;
}
@Override
public int hashCode() {
return Objects.hashCode(value);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]