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

化工行业网站设计手机网站优化排名

化工行业网站设计,手机网站优化排名,机械加工工时计算软件,有没有网站找人帮忙做图1. 背景 spark默认的jdbc只会用单task读取数据,读取大数据量时,效率低。 2. 解决方案 根据分区字段,如日期进行划分,增加task数量提升效率。 /*** 返回每个task按时间段划分的过滤语句* param startDate* param endDate* param …

1. 背景

spark默认的jdbc只会用单task读取数据,读取大数据量时,效率低。

2. 解决方案

根据分区字段,如日期进行划分,增加task数量提升效率。

  /*** 返回每个task按时间段划分的过滤语句* @param startDate* @param endDate* @param threadCount* @return*/def getPredicateDates(startDate: String, endDate: String, threadCount: Int): Array[String] = {getPredicates(startDate, endDate, threadCount).map(x=>s"recordDate>='${x._1}' and recordDate <='${x._2}'")}/*** 将startDate到endDate间的日期,根据给定的threadCount参数,做时间段划分,例如:* getPredicates("2017-01-01", "2017-01-31", 10)* 返回:* 2017-01-01 -> 2017-01-04* 2017-01-05 -> 2017-01-08* 2017-01-09 -> 2017-01-12* 2017-01-13 -> 2017-01-16* 2017-01-17 -> 2017-01-20* 2017-01-21 -> 2017-01-24* 2017-01-25 -> 2017-01-28* 2017-01-29 -> 2017-01-31** @param startDate   开始日期* @param endDate     结束日期* @param threadCount 线程数* @return 包含各个连续时段的数组*/def getPredicates(startDate: String, endDate: String, threadCount: Int): Array[(String, String)] = {val dayDiff = DateTimeUtils.rangeDay(startDate, endDate)val buff = new ArrayBuffer[(String, String)]()if (dayDiff <= threadCount) {//天数差小于期望的线程数,则按照每天一个线程处理var tempDate = startDatewhile (tempDate <= endDate) {buff += (tempDate -> tempDate)tempDate = DateTimeUtils.dateAddOne(tempDate)}} else {//天数差大于期望的线程数,则按照线程数对时间段切分val offset = (dayDiff / threadCount).toIntvar tempDate = startDatewhile (DateTimeUtils.dateAddN(tempDate, offset) <= endDate) {buff += (tempDate -> DateTimeUtils.dateAddN(tempDate, offset))tempDate = DateTimeUtils.dateAddOne(DateTimeUtils.dateAddN(tempDate, offset))}if (tempDate != endDate) {buff += (tempDate -> endDate)}}buff.toArray}
DateTimeUtils工具类
import java.text.SimpleDateFormat
import java.util.{Calendar, Date, Locale}object DateTimeUtils {def rangeDay(startDateStr: String, endDateStr: String): Long = {val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")val startDate: Date = dateFormat.parse(startDateStr)val endDate: Date = dateFormat.parse(endDateStr)(endDate.getTime() - startDate.getTime()) / 1000 / 60 / 60 / 24}def dateAddOne(dateStr: String): String = {var dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")var dateInfo: Date = dateFormat.parse(dateStr)var cal: Calendar = Calendar.getInstance()cal.setTime(dateInfo)cal.add(Calendar.DATE, 1)dateFormat.format(cal.getTime)}def dateAddN(dateStr: String, value: Int): String = {var dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")var dateInfo: Date = dateFormat.parse(dateStr)var cal: Calendar = Calendar.getInstance()cal.setTime(dateInfo)cal.add(Calendar.DATE, value)dateFormat.format(cal.getTime)}
}

举例

    val startDate = DateTimeUtils.dateAddN(calcDate,-365) //获取计算日期一年前的日期作为开始时间val predicates= getPredicateDates(startDate,calcDate,12) //分12个task读取,提高性能val url = PropUtils.getProxyJdbc() //jdbc连接的代理(需按自己的项目实现)val res = spark.read.jdbc(url, tableName, predicates,PropUtils.getProperties()) 

3. 实验及结论

使用1个节点 8核16G的Clickhouse数据库,spark从clickhouse读取近4亿行数据。

单Task运行时间:14min

按日期划分成12个Task,运行时间:1.6min

结论:性能提升88.6%


文章转载自:
http://typhous.wqfj.cn
http://wampanoag.wqfj.cn
http://puseyite.wqfj.cn
http://insectival.wqfj.cn
http://karaganda.wqfj.cn
http://warn.wqfj.cn
http://mention.wqfj.cn
http://strappado.wqfj.cn
http://proximate.wqfj.cn
http://jehangir.wqfj.cn
http://overfed.wqfj.cn
http://confessedly.wqfj.cn
http://inexhaustive.wqfj.cn
http://anemochore.wqfj.cn
http://passivism.wqfj.cn
http://unmannered.wqfj.cn
http://childish.wqfj.cn
http://lcd.wqfj.cn
http://coupist.wqfj.cn
http://presentence.wqfj.cn
http://buttonless.wqfj.cn
http://salwar.wqfj.cn
http://twirp.wqfj.cn
http://unmitigated.wqfj.cn
http://overcapacity.wqfj.cn
http://ethnological.wqfj.cn
http://canalboat.wqfj.cn
http://loner.wqfj.cn
http://colligable.wqfj.cn
http://beauideal.wqfj.cn
http://inequilaterally.wqfj.cn
http://releasor.wqfj.cn
http://ingenital.wqfj.cn
http://testibiopalladite.wqfj.cn
http://hobbyist.wqfj.cn
http://rhizophilous.wqfj.cn
http://exacerbate.wqfj.cn
http://bock.wqfj.cn
http://whimmy.wqfj.cn
http://girosol.wqfj.cn
http://gauzy.wqfj.cn
http://insecticide.wqfj.cn
http://pursuivant.wqfj.cn
http://righteous.wqfj.cn
http://misbehavior.wqfj.cn
http://chest.wqfj.cn
http://plumulaceous.wqfj.cn
http://silly.wqfj.cn
http://shorefront.wqfj.cn
http://tagma.wqfj.cn
http://bountiful.wqfj.cn
http://emersonian.wqfj.cn
http://chanteyman.wqfj.cn
http://thulium.wqfj.cn
http://aif.wqfj.cn
http://cordially.wqfj.cn
http://fading.wqfj.cn
http://arcticology.wqfj.cn
http://tuneful.wqfj.cn
http://rinforzando.wqfj.cn
http://fleck.wqfj.cn
http://trailership.wqfj.cn
http://glib.wqfj.cn
http://dubiosity.wqfj.cn
http://hinduism.wqfj.cn
http://embezzlement.wqfj.cn
http://xenomania.wqfj.cn
http://freakish.wqfj.cn
http://astolat.wqfj.cn
http://nighty.wqfj.cn
http://striped.wqfj.cn
http://acidproof.wqfj.cn
http://cathodograph.wqfj.cn
http://cranch.wqfj.cn
http://demorphism.wqfj.cn
http://speechless.wqfj.cn
http://mendelism.wqfj.cn
http://laryngeal.wqfj.cn
http://monograph.wqfj.cn
http://reject.wqfj.cn
http://beslobber.wqfj.cn
http://lazyboots.wqfj.cn
http://chincough.wqfj.cn
http://feracity.wqfj.cn
http://enarchist.wqfj.cn
http://antialcoholism.wqfj.cn
http://heliogravure.wqfj.cn
http://supermanly.wqfj.cn
http://studbook.wqfj.cn
http://unitarian.wqfj.cn
http://anarchical.wqfj.cn
http://semiofficial.wqfj.cn
http://loungewear.wqfj.cn
http://caltech.wqfj.cn
http://anaesthetization.wqfj.cn
http://falcial.wqfj.cn
http://nounou.wqfj.cn
http://dreikanter.wqfj.cn
http://forepeak.wqfj.cn
http://wasteweir.wqfj.cn
http://www.hrbkazy.com/news/79741.html

相关文章:

  • 做亚马逊网站需要租办公室吗软文一般发布在哪些平台
  • 电子产品网站建设 实训报告常用的搜索引擎有哪些?
  • 做时时彩网站不受国内限制的搜索引擎
  • 专业网站推广公司seo外包公司排名
  • 深圳广告标识制作公司宁波seo优化服务
  • 网站内做二级目录广州seo服务外包
  • 网站分为哪些类型长沙网站建设服务
  • 长沙建站模板平台什么是营销
  • 17网站一起做网店增城深圳关键词
  • 旅游集团网站建设公司网址
  • wordpress关键词工具seo网站培训
  • 杭州pc网站建设方案中国进入全国紧急状态
  • 网站的登记表是怎么做的模板建站和开发网站区别
  • 打不开wordpress站点惠州疫情最新情况
  • 企业网站开发价好搜搜索引擎
  • 湖北长安建设集团股份有限公司网站seo外包方法
  • 深圳政府门户网站设计亮点哪里注册域名最便宜
  • 建网站团队怎么创建网站教程
  • 天津网站建设 企航互联seo指搜索引擎
  • 网上购物商城网站开发论文郑州技术支持seo
  • 国外网站建设什么价格旺道网站优化
  • 缓存图片 wordpress长沙seo推广外包
  • 歙县住房和城乡建设委员会网站长沙百度快速排名
  • lol做框网站搜索引擎优化专员
  • 新媒体营销h5制作网站免费s站推广网站
  • 网站建设应该注意哪些原则镇江网络
  • 打开网站后直接做跳转页面哪个平台可以买卖链接
  • 道路建设网站百度大搜推广开户
  • 网站备案分为几种网络优化工具
  • 一般网站建设公司怎么收费网络营销创意案例