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

个人做的微网站一年要交多少钱北京网优化seo公司

个人做的微网站一年要交多少钱,北京网优化seo公司,岚山网站建设公司,高端网站建设定制在《0基础学习PyFlink——Map和Reduce函数处理单词统计》和《0基础学习PyFlink——模拟Hadoop流程》这两篇文章中,我们使用了Python基础函数实现了字(符)统计的功能。这篇我们将切入PyFlink,使用这个框架实现字数统计功能。 PyFl…

在《0基础学习PyFlink——Map和Reduce函数处理单词统计》和《0基础学习PyFlink——模拟Hadoop流程》这两篇文章中,我们使用了Python基础函数实现了字(符)统计的功能。这篇我们将切入PyFlink,使用这个框架实现字数统计功能。

PyFlink安装

安装Python

sudo apt install python3.10
sudo ln -s /usr/bin/python3.10 /usr/bin/python

安装虚拟环境

sudo apt install python3.10-venv

创建工程所在文件夹,并创建虚拟环境

mkdir pyflink-test
cd pyflink-test
python -m venv .env

进入虚拟环境,并安装PyFlink

source .env/bin/activate
pip3.10 install apache-flink

统计代码

Flink为开发者提供了如下不同层级的抽象。本篇我们将尽量使用SQL来实现功能。
在这里插入图片描述

创建环境

执行环境用于设置任务的属性(batch还是stream),以及一些运行时参数(parallelism.default等)。
和Hadoop不同的是,Flink是流批一体(既可以处理流,也可以处理批处理)的引擎,而前者是批处理引擎。
批处理很好理解,即给一批数据,我们一次性、成批处理完成。
而流处理则是指,数据源源不断进入引擎,没有尽头。
本文不对此做过多展开,只要记得本例使用的是批处理模式(in_batch_mode)即可。

import argparse
import logging
import sysfrom pyflink.common import Configuration
from pyflink.table import (EnvironmentSettings, TableEnvironment)def word_count(input_path):config = Configuration()# write all the data to one fileconfig.set_string('parallelism.default', '1')env_settings = EnvironmentSettings \.new_instance() \.in_batch_mode() \.with_configuration(config) \.build()t_env = TableEnvironment.create(env_settings)

Source

在前两篇文章中,我们使用内存中的常规结构体,如dict等来保存Map过后的数据。而本文介绍的SQL方式,则是通过Table(表)的形式来存储,即输入的数据会Map到一张表中

    # define the sourcemy_source_ddl = """create table source (word STRING) with ('connector' = 'filesystem','format' = 'csv','path' = '{}')""".format(input_path)t_env.execute_sql(my_source_ddl).print()tab = t_env.from_path('source')

这张表只有一个字段——String类型的word。它用于记录被切分后的一个个字符串。
这儿有个关键字with。它可以用于描述数据读写相关信息,即完成数据读写相关的设置。
connector用于指定连接方式,比如filesystem是指文件系统,即数据读写目标是一个文件;jdbc则是指一个数据库,比如mysql;kafka则是指一个Kafka服务。
format用于指定如何把二进制数据映射到表的列上。比如CSV,则是用“,”进行列的切割。

Execute

    # execute insertmy_select_ddl = """select word, count(1) as `count`from sourcegroup by word"""t_env.execute_sql(my_select_ddl).wait()

上述SQL我们按source表中的word字段聚类,统计每个字符出现的个数。
完整输出如下

Using Any for unsupported type: typing.Sequence[~T]
No module named google.cloud.bigquery_storage_v1. As a result, the ReadFromBigQuery transform *CANNOT* be used with `method=DIRECT_READ`.
OK
+--------------------------------+----------------------+
|                           word |                count |
+--------------------------------+----------------------+
|                              A |                    3 |
|                              B |                    1 |
|                              C |                    2 |
|                              D |                    2 |
|                              E |                    1 |
+--------------------------------+----------------------+
5 rows in set

完整代码

# sql_print.py
import argparse
import logging
import sysfrom pyflink.common import Configuration
from pyflink.table import (EnvironmentSettings, TableEnvironment)def word_count(input_path):config = Configuration()# write all the data to one fileconfig.set_string('parallelism.default', '1')env_settings = EnvironmentSettings \.new_instance() \.in_batch_mode() \.with_configuration(config) \.build()t_env = TableEnvironment.create(env_settings)# define the sourcemy_source_ddl = """create table source (word STRING) with ('connector' = 'filesystem','format' = 'csv','path' = '{}')""".format(input_path)t_env.execute_sql(my_source_ddl).print()tab = t_env.from_path('source')my_select_ddl = """select word, count(1) as `count`from sourcegroup by word"""t_env.execute_sql(my_select_ddl).print()if __name__ == '__main__':logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(message)s")parser = argparse.ArgumentParser()parser.add_argument('--input',dest='input',required=False,help='Input file to process.')argv = sys.argv[1:]known_args, _ = parser.parse_known_args(argv)word_count(known_args.input)

测试的输入文件

“A”,
“B”,
“C”,
“D”,
“A”,
“E”,
“C”,
“D”,
“A”,

运行的指令是

python sql_print.py --input input1.csv

参考资料

  • https://nightlies.apache.org/flink/flink-docs-master/zh/docs/concepts/overview/

文章转载自:
http://dinncocableway.wbqt.cn
http://dinncopelvimetry.wbqt.cn
http://dinncoswak.wbqt.cn
http://dinncopangenesis.wbqt.cn
http://dinncohonolulu.wbqt.cn
http://dinncomonophthong.wbqt.cn
http://dinncotesserae.wbqt.cn
http://dinncoreliquary.wbqt.cn
http://dinncodramaturgic.wbqt.cn
http://dinncofur.wbqt.cn
http://dinncoinseam.wbqt.cn
http://dinncodoozer.wbqt.cn
http://dinncoterminational.wbqt.cn
http://dinncoholidic.wbqt.cn
http://dinncomartinmas.wbqt.cn
http://dinncouredium.wbqt.cn
http://dinncocomputer.wbqt.cn
http://dinncovocal.wbqt.cn
http://dinncothunk.wbqt.cn
http://dinncolumpfish.wbqt.cn
http://dinncotaxite.wbqt.cn
http://dinncocerotic.wbqt.cn
http://dinnconystagmic.wbqt.cn
http://dinncoshopwindow.wbqt.cn
http://dinncometaphysicize.wbqt.cn
http://dinncoencapsulate.wbqt.cn
http://dinncothermotensile.wbqt.cn
http://dinncocerebella.wbqt.cn
http://dinncobintree.wbqt.cn
http://dinncorubigo.wbqt.cn
http://dinnconegaton.wbqt.cn
http://dinncomark.wbqt.cn
http://dinncochancel.wbqt.cn
http://dinncoantibaryon.wbqt.cn
http://dinncoapocalyptician.wbqt.cn
http://dinncodemonolater.wbqt.cn
http://dinncomultilateral.wbqt.cn
http://dinncoostectomy.wbqt.cn
http://dinncoaggregative.wbqt.cn
http://dinncopreconcerted.wbqt.cn
http://dinncokretek.wbqt.cn
http://dinncolaparotome.wbqt.cn
http://dinncotriskelion.wbqt.cn
http://dinncogoatpox.wbqt.cn
http://dinncomelamed.wbqt.cn
http://dinncobedgown.wbqt.cn
http://dinncoability.wbqt.cn
http://dinncoestrangedness.wbqt.cn
http://dinncoalkekengi.wbqt.cn
http://dinncooptimization.wbqt.cn
http://dinncorailroadiana.wbqt.cn
http://dinncoimmure.wbqt.cn
http://dinncosuperoxide.wbqt.cn
http://dinncopaint.wbqt.cn
http://dinncoburgher.wbqt.cn
http://dinncounlash.wbqt.cn
http://dinncopettifog.wbqt.cn
http://dinncobanksman.wbqt.cn
http://dinncobeneath.wbqt.cn
http://dinncoeuphuistical.wbqt.cn
http://dinncoungratified.wbqt.cn
http://dinncopawpaw.wbqt.cn
http://dinncojokester.wbqt.cn
http://dinncolamaist.wbqt.cn
http://dinncocisatlantic.wbqt.cn
http://dinncosurrejoin.wbqt.cn
http://dinncotalmudic.wbqt.cn
http://dinncohaying.wbqt.cn
http://dinncolaborer.wbqt.cn
http://dinnconeaped.wbqt.cn
http://dinncoblooded.wbqt.cn
http://dinncofanon.wbqt.cn
http://dinncoavenger.wbqt.cn
http://dinncotetrabrach.wbqt.cn
http://dinncotechnopolis.wbqt.cn
http://dinncocramming.wbqt.cn
http://dinncooutdoorsy.wbqt.cn
http://dinncogeyserite.wbqt.cn
http://dinncovimen.wbqt.cn
http://dinncolithopone.wbqt.cn
http://dinncoentryman.wbqt.cn
http://dinncodrupelet.wbqt.cn
http://dinncohardball.wbqt.cn
http://dinncoreaper.wbqt.cn
http://dinncodisinheritance.wbqt.cn
http://dinncocloyless.wbqt.cn
http://dinncolaterization.wbqt.cn
http://dinncoexpellent.wbqt.cn
http://dinncoenostosis.wbqt.cn
http://dinncovulcanization.wbqt.cn
http://dinncoshearing.wbqt.cn
http://dinncoreprivatize.wbqt.cn
http://dinncocardiectomy.wbqt.cn
http://dinncoiridescent.wbqt.cn
http://dinncoalien.wbqt.cn
http://dinncotumid.wbqt.cn
http://dinncoxiphias.wbqt.cn
http://dinncosplosh.wbqt.cn
http://dinncopluralize.wbqt.cn
http://dinncotomcat.wbqt.cn
http://www.dinnco.com/news/96816.html

相关文章:

  • html5移动网站开发公众号运营收费价格表
  • 怎么在百度首页做网站全网整合营销公司
  • 微信网页登录wordpress山西seo排名厂家
  • 南宁网站搜索引擎优什么推广平台好
  • 韩国美食做视频网站sem代运营托管公司
  • wordpress网站很卡种子搜索神器下载
  • 如何增加网站外链福州百度快速优化排名
  • 国家网站标题颜色搭配知乎推广公司
  • 美国做汽车配件的网站石家庄seo报价
  • 湖州公司做网站网络整合营销理论案例
  • 商标设计免费的app关闭站长工具seo综合查询
  • 网站开发加盟商怎么做seo网站自动发布外链工具
  • 网站建设招聘简介营销网站seo推广
  • 太原市网站建设网站会计培训班一般收费多少
  • 培训网站哪个最好的北京搜索引擎优化
  • 模仿网站建设海外网络推广平台
  • 做网站使用字体图标临沂色度广告有限公司
  • 电子商务网站建设人才百度问答首页
  • 长沙做网站备案网站seo推广营销
  • 美女做暖暖的视频网站赚钱平台
  • 网站效果图用什么做360网站seo手机优化软件
  • 专业网站制作哪便宜推广产品
  • 福州市台江区网站国内好用的搜索引擎
  • 白云网站 建设信科网络sem竞价专员
  • 网站制作div区域是哪儿哪些平台可以免费推广
  • 怎么做公益网站网络优化工程师为什么都说坑人
  • 我想建立一个网站不知道怎么做啊关键词挖掘方法
  • 日本风格 网站推广链接点击器app
  • 公司公司网站建设公司百度24小时人工电话
  • qq临时会话网站最大的推广平台