flink中的table api中的CloseableIterator是什么意思?
在官網玩耍table api的時候看一個 table api的example的時候看到這么一段代碼:
try (CloseableIterator<Row> iterator = youngCustomers.execute().collect()) {
? ? final Set<Row> expectedOutput = new HashSet<>();
? ? expectedOutput.add(Row.of("GUILLERMO SMITH", LocalDate.parse("1992-12-12"), "4081 VALLEY ROAD, 08540, NEW JERSEY"));
? ? expectedOutput.add(Row.of("JOHN TURNER", LocalDate.parse("1982-10-02"), "2359 NEW STREET, 60605, CHICAGO"));
? ? expectedOutput.add(Row.of("ELLEN ORTEGA", LocalDate.parse("1985-06-18"), "2448 RODNEY STREET, 85023, PHOENIX"));
? ? final Set<Row> actualOutput = new HashSet<>();
? ? iterator.forEachRemaining(actualOutput::add);
? ? if (actualOutput.equals(expectedOutput)) {
? ? ? ? System.out.println("SUCCESS!");
? ? } else {
? ? ? ? System.out.println("FAILURE!");
? ? }
}
顯然迭代器很好理解,就是需要使用了才放入內存.
這里的java.io.Closeable怎么理解呢?
最終結合[2]可知CloseableIterator就是一種可是手動釋放資源的iterator.
下面開始解析:
根據[1]可知,繼承關系是:
public interface CloseableIterator<T>
extends java.util.Iterator<T>, java.io.Closeable
顯然迭代器很好理解,就是需要使用了才放入內存.
這里的java.io.Closeable怎么理解呢?
最終結合[2]可知CloseableIterator就是一種可是手動釋放資源的iterator.
附錄
graphviz代碼如下:
digraph G {
? ? size = "4, 4";
? ? "java.util.Iterator<T>" -> "CloseableIterator<T>";
? ? "java.io.Closeable" -> "CloseableIterator<T>";
}
dot -Tpng test.dot -o test.png
?
?
Reference:
[1]Interface CloseableIterator
[2]java.io.Closeable
總結
以上是生活随笔為你收集整理的flink中的table api中的CloseableIterator是什么意思?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 万能小组件怎么恢复图标
- 下一篇: 中国建设银行怎么开通短信提醒(《中国》第