当前位置: 首页 > news >正文

网站建设关键词排名优化虚拟主机和vps的区别

网站建设关键词排名优化,虚拟主机和vps的区别,网站建设建站,教育机构logo大纲 sourceMapSplittingMapping ReduceKeyingReducing 完整代码结构参考资料 在《0基础学习PyFlink——模拟Hadoop流程》一文中#xff0c;我们看到Hadoop在处理大数据时的MapReduce过程。 本节介绍的DataStream API#xff0c;则使用了类似的结构。 source 为了方便我们看到Hadoop在处理大数据时的MapReduce过程。 本节介绍的DataStream API则使用了类似的结构。 source 为了方便我们依然使用from_collection从内存中读取数据。 和使用Table API类似我们给from_collection传递的第二参数是每行数据类型。本例中是String即“A C B”的类型。 from pyflink.common import Types from pyflink.datastream import StreamExecutionEnvironment, RuntimeExecutionModeword_count_data [A C B,A E B,E C D]def word_count():env StreamExecutionEnvironment.get_execution_environment()env.set_runtime_mode(RuntimeExecutionMode.BATCH)# write all the data to one fileenv.set_parallelism(1)source_type_info Types.STRING()# define the sourcesource env.from_collection(word_count_data, source_type_info)可以使用下面指令输出source内容 source.print()A C B A E B E C DMap 和上图一样Map由Splitting和Mapping组成。它们分别将数据切割成做小运算单元和生成map结构。 Splitting def split(line):for s in line.split():yield ssplitted source.flat_map(split) 上述splitted的结构输出是 A C B A E B E C DMapping Mapping的操作就是将之前的数组结构转换成map结构 mappedsplitted.map(lambda i: (i, 1), Types.TUPLE([Types.STRING(), Types.INT()]))mapped的输出值如下可以看到它还是按我们输入数据的顺序排列的。 (A,1) (C,1) (B,1) (A,1) (E,1) (B,1) (E,1) (C,1) (D,1)Reduce Keying 这一步对应于上图中的ShufflingSorting它会将相同key的数据进行分区以供后面reducing操作使用。 keyedmapped.key_by(lambda i: i[0]) 可以看到keyed数据已经经过排序和聚合了。 (A,1) (A,1) (B,1) (B,1) (C,1) (C,1) (D,1)Reducing reducedkeyed.reduce(lambda i, j: (i[0], i[1] j[1]))reduce的方法有如下注释 Applies a reduce transformation on the grouped data stream grouped on by the given key position. The ReduceFunction will receive input values based on the key value. Only input values with the same key will go to the same reducer. 特别是最后一句非常有用“Only input values with the same key will go to the same reducer”只有相同Key的输入数据才会进入相同的Reducer中。这句话意味着上述Keyed的数据会被分组执行于是就不会出现计算错乱。 (A,2) (B,2) (C,2) (D,1) (E,2)完整代码 from pyflink.common import Types from pyflink.datastream import StreamExecutionEnvironment, RuntimeExecutionModeword_count_data [A C B,A E B,E C D]def word_count():env StreamExecutionEnvironment.get_execution_environment()env.set_runtime_mode(RuntimeExecutionMode.BATCH)# write all the data to one fileenv.set_parallelism(1)source_type_info Types.STRING()# define the sourcesource env.from_collection(word_count_data, source_type_info)# source.print()def split(line):for s in line.split():yield ssplitted source.flat_map(split) # splitted.print()mappedsplitted.map(lambda i: (i, 1), Types.TUPLE([Types.STRING(), Types.INT()]))# mapped.print()keyedmapped.key_by(lambda i: i[0]) # keyed.print()reducedkeyed.reduce(lambda i, j: (i[0], i[1] j[1]))# define the sinkreduced.print()# submit for executionenv.execute()if __name__ __main__:word_count()结构 参考资料 https://nightlies.apache.org/flink/flink-docs-master/zh/docs/dev/python/datastream_tutorial/
http://www.zqtcl.cn/news/610185/

相关文章:

  • 数码港 太原网站开发公司iis 建立子网站
  • 做一个自己的网站需要什么商标设计网站猪八戒
  • 傻瓜式网站建设软件保险预约
  • 网站 备案规定自己做简单网站
  • 网站上怎么做支付接口南乐网站建设
  • 咸阳网站建设公司电话做个公司网站大概多少钱
  • 网站如何做关键词排名点子网创意网
  • 浙江建设培训考试网站河源东莞网站建设
  • 网站移动端做pc端的301跳转哪些网站是增值网
  • wordpress新闻站浙江耀华建设集团网站
  • 网站开发代理企业网站推广技巧和方法
  • 俄语网站开发用模板做的网站多少钱
  • 丽水网站建设公司广州网络公司
  • 做基金的网站哪个好针对大学生推广引流
  • 国外对旅游网站的建设互联网推广和互联网营销
  • 海南省建设厅网站首页有什么做设计的兼职网站
  • 网站导航功能苏州市高新区建设局网站
  • jsp网站 值班多语种网站开发
  • 公司网站英文做电商
  • 合肥企业网站建设公司哪家好卖产品怎么做网站
  • 网站建设公司86215中国中小企业网站
  • 做网站 如何 挣钱游戏网站开发协议
  • 网站建设发展wordpress比较慢
  • 收费网站推广动漫制作就业方向
  • 湖北优化网站建设设计公司需要什么资质
  • 个人网站怎么制作wordpress创意小工具
  • 网站管理维护怎么做在线oa
  • vue做企业网站wordpress 不发送邮件
  • 深圳做网站哪家便宜邮政编码html编写
  • 黑龙江营商环境建设局网站门户网站整改报告