測試mapGroupsWithState更新功能

TestGroupStateAPI使您能夠用於測試狀態更新功能Dataset.groupByKey (…) .mapGroupsWithState (…)Dataset.groupByKey (…) .flatMapGroupsWithState (…)

狀態更新函數之前狀態作為輸入使用一種類型的對象GroupState。看到Apache火花GroupState參考文檔。例如:

進口orgapache火花sql流媒體_進口orgapache火花apijava可選測試(“flatMapGroupsWithState狀態更新函數”){varprevState=TestGroupState創建(UserStatus)(optionalState=可選(UserStatus),timeoutConf=GroupStateTimeoutEventTimeTimeout,batchProcessingTimeMs=1 l,eventTimeWatermarkMs=可選(1 l),hasTimedOut=)瓦爾用戶標識:字符串=瓦爾行動:迭代器(UserAction]=斷言(!prevStatehasUpdated)updateState(用戶標識,行動,prevState)斷言(prevStatehasUpdated)}