vlsi commented on a change in pull request #2353:
URL: https://github.com/apache/calcite/pull/2353#discussion_r583679658
##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -2792,40 +2792,8 @@ public static Collection multisetUnionAll(Collection
collection1,
* Function that, given a certain List containing single-item structs (i.e.
arrays / lists with
* a single item), builds an Enumerable that returns those single items
inside the structs.
*/
- public static Function1<Object, Enumerable<Comparable>> flatList() {
- return inputObject -> {
- final List list = (List) inputObject;
- final Enumerator<List<Object>> enumerator = Linq4j.enumerator(list);
- return new AbstractEnumerable<Comparable>() {
- @Override public Enumerator<Comparable> enumerator() {
- return new Enumerator<Comparable>() {
-
- @Override public boolean moveNext() {
- return enumerator.moveNext();
- }
-
- @Override public Comparable current() {
- final Object element = enumerator.current();
- final Comparable comparable;
- if (element.getClass().isArray()) {
- comparable = (Comparable) ((Object[]) element)[0];
- } else {
- comparable = (Comparable) ((List) element).get(0);
- }
- return comparable;
- }
-
- @Override public void reset() {
- enumerator.reset();
- }
-
- @Override public void close() {
- enumerator.close();
- }
- };
- }
- };
- };
+ public static Function1<List<Object>, Enumerable<Object>> flatList() {
+ return inputList -> Linq4j.asEnumerable(inputList).select(v ->
structAccess(v, 0, null));
Review comment:
Great. Now it is much easier to understand what this call does :)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]