[
https://issues.apache.org/jira/browse/FLINK-5224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15834196#comment-15834196
]
ASF GitHub Bot commented on FLINK-5224:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/3118#discussion_r97098892
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/TableFunction.scala
---
@@ -99,27 +98,26 @@ abstract class TableFunction[T] extends
UserDefinedFunction {
//
----------------------------------------------------------------------------------------------
- private val rows: util.ArrayList[T] = new util.ArrayList[T]()
-
/**
* Emit an output row.
*
* @param row the output row
*/
protected def collect(row: T): Unit = {
- // cache rows for now, maybe immediately process them further
- rows.add(row)
+ collector.collect(row)
}
- /**
- * Internal use. Get an iterator of the buffered rows.
- */
- def getRowsIterator = rows.iterator()
+ //
----------------------------------------------------------------------------------------------
+
+ /** The code generated collector used to emit row. */
+ private var collector: Collector[T] = _
/**
- * Internal use. Clear buffered rows.
+ * Internal use. Sets the current collector.
*/
- def clear() = rows.clear()
+ def setCollector(collector: Collector[T]): Unit = {
--- End diff --
Could we set this to `private[flink]`? Than we could at least hide in Scala
API. It should still be accessible for Java runtime. And maybe also final?
> Improve UDTF: emit rows directly instead of buffering them
> ----------------------------------------------------------
>
> Key: FLINK-5224
> URL: https://issues.apache.org/jira/browse/FLINK-5224
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Reporter: Jark Wu
> Assignee: Jark Wu
>
> This needs to code generate a `Collector` and register it into instance of
> {{TableFunction}}, and emit the rows generated by the UDTF directly instead
> of buffering them.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)