失效链接处理 |
基于Flink构建实时数据仓库 PDF 下载
本站整理下载:
相关截图:
主要内容:
public class UserDimFunc extends TableFunction<Tupl.e2<String, String» { private Map<String, Userlnfo> userDimCache = new HashMap<>();
色 Override
public void open(Functioncontext context) throws Exception { TimerTask repeatedTask = new TimerTask() {
public void run() {
// connect to mysql/hive
// userDimCache =...
}
};
Timer timer = new Timer( name: "LoadTimer"); timer.scheduleAtFixedRate(repeatedTask, delay: 0, period: 3600000L);
}
©Override
public Typeinformation<Tuple2<String, String» getResultType() return lypes.TUPLE(Types.STRING, Types.STRING);
}
public void evaKString id) { Userinfo user = userDimCache.get(id); if (user != null) {
collect(new Tuple2<>(user.name, user.region));
}
}
}
|