Flink學習筆記2 Flink框架api介紹

2021-10-03 18:53:24 字數 1008 閱讀 9103

使用 transform 函式

/* mapfunction 介面 其中泛型的第一 string 代表輸入型別,第二個 integer 代表輸出型別

*/class

mymapfunction

implements

mapfunction

}//data.

map(

newmymapfunction()

);lambda表示式

data.

map(s -

> integer.

parseint

(s))

;//或者

data.

map(integer:

:parseint)

;

rich function

/**

* 與實現 mapfunction 介面類似,這裡是繼承了 richmapfunction 類

* 同時可以實現父類更多的方法

*/class

myrichmapfunction

extends

richmapfunction

@override

public runtimecontext getruntimecontext()

@override

public

void

setruntimecontext

(runtimecontext t)

@override

public integer map

(string value)

throws exception

@override

public

void

close()

throws exception

}data.

map(

newmyrichmapfunction()

);

flink學習 flink架構

flink結構 graph 2個併發度 source為1個併發度 的sockettextstreamwordcount四層執行圖的演變過程 jobgraph streamgraph經過優化後生成了 jobgraph,提交給 jobmanager 的資料結構。executiongraph jobman...

Flink學習筆記(五) flink資料合流

上一章記錄了flink的分流操作,那麼有分流是不是應該有合流呢?當然是有這樣的操作啦 stream1和stream2流需要合併為stream流 1.union合流 2.connect合流 前置配置 streamexecutionenvironment env streamexecutionenvir...

Flink學習筆記1 Flink框架api介紹

1.獲得 execution 環境 getexecutionenvironment createlocalenvironment createremoteenvironment string host,int port,string.jarfiles 批處理示例 executionenvironme...