Spark SQL 项目:实现各区域热门商品前N统计

2023-11-20

一. 需求

1.1 需求简介
这里的热门商品是从点击量的维度来看的.

计算各个区域前三大热门商品,并备注上每个商品在主要城市中的分布比例,超过两个城市用其他显示。




1.2 思路分析
使用 sql 来完成. 碰到复杂的需求, 可以使用 udf 或 udaf

查询出来所有的点击记录, 并与 city_info 表连接, 得到每个城市所在的地区. 与 Product_info 表连接得到产品名称
按照地区和商品 id 分组, 统计出每个商品在每个地区的总点击次数
每个地区内按照点击次数降序排列
只取前三名. 并把结果保存在数据库中
城市备注需要自定义 UDAF 函数



二. 实际操作
1. 准备数据
  我们这次 Spark-sql 操作中所有的数据均来自 Hive.

  首先在 Hive 中创建表, 并导入数据.

  一共有 3 张表: 1 张用户行为表, 1 张城市表, 1 张产品表

1. 打开Hive




2. 创建三个表

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE TABLE `user_visit_action`(
  `date` string,
  `user_id` bigint,
  `session_id` string,
  `page_id` bigint,
  `action_time` string,
  `search_keyword` string,
  `click_category_id` bigint,
  `click_product_id` bigint,
  `order_category_ids` string,
  `order_product_ids` string,
  `pay_category_ids` string,
  `pay_product_ids` string,
  `city_id` bigint)
row format delimited fields terminated by '\t';
 
CREATE TABLE `product_info`(
  `product_id` bigint,
  `product_name` string,
  `extend_info` string)
row format delimited fields terminated by '\t';
 
CREATE TABLE `city_info`(
  `city_id` bigint,
  `city_name` string,
  `area` string)
row format delimited fields terminated by '\t';





3. 上传数据

 
1
2
3
load data local inpath '/opt/module/datas/user_visit_action.txt' into table spark0806.user_visit_action;
load data local inpath '/opt/module/datas/product_info.txt' into table spark0806.product_info;
load data local inpath '/opt/module/datas/city_info.txt' into table spark0806.city_info;





4. 测试是否上传成功

 
1
hive> select * from city_info;





2. 显示各区域热门商品 Top3

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// user_visit_action  product_info  city_info
 
1. 先把需要的字段查出来   t1
select
    ci.*,
    pi.product_name,
    click_product_id
from user_visit_action uva
join product_info pi on uva.click_product_id=pi.product_id
join city_info ci on uva.city_id=ci.city_id
 
2. 按照地区和商品名称聚合
select
    area,
    product_name,
    count(*)  count
from t1
group by area , product_name
 
3. 按照地区进行分组开窗 排序 开窗函数 t3 // (rank(1 2 2 4 5...) row_number(1 2 3 4...) dense_rank(1 2 2 3 4...))
select
    area,
    product_name,
    count,
    rank() over(partition by area order by count desc)
from  t2
 
 
4. 过滤出来名次小于等于3的
select
    area,
    product_name,
    count
from  t3
where rk <=3



2. 运行结果




3. 定义udaf函数 得到需求结果

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.buwenbuhuo.spark.sql.project
 
import java.text.DecimalFormat
 
import org.apache.spark.sql.Row
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction}
import org.apache.spark.sql.types._
 
 
/**
 **
 *
 * @author 不温卜火
 *         *
 * @create 2020-08-06 13:24
 **
 *         MyCSDN :  [url=https://buwenbuhuo.blog.csdn.net/]https://buwenbuhuo.blog.csdn.net/[/url]
 *
 */
class CityRemarkUDAF extends UserDefinedAggregateFunction {
  // 输入数据的类型:  北京  String
  override def inputSchema: StructType = {
    StructType(Array(StructField("city", StringType)))
  }
 
  // 缓存的数据的类型 每个地区的每个商品 缓冲所有城市的点击量 北京->1000, 天津->5000  Map,  总的点击量  1000/?
  override def bufferSchema: StructType = {
    StructType(Array(StructField("map", MapType(StringType, LongType)), StructField("total", LongType)))
  }
 
  // 输出的数据类型  "北京21.2%,天津13.2%,其他65.6%"  String
  override def dataType: DataType = StringType
 
  // 相同的输入是否应用有相同的输出.
  override def deterministic: Boolean = true
 
  // 给存储数据初始化
  override def initialize(buffer: MutableAggregationBuffer): Unit = {
    //初始化map缓存
    buffer(0) = Map[String, Long]()
    // 初始化总的点击量
    buffer(1) = 0L
  }
 
  // 分区内合并 Map[城市名, 点击量]
  override def update(buffer: MutableAggregationBuffer, input: Row): Unit = {
    input match {
      case Row(cityName: String) =>
        // 1. 总的点击量 + 1
        buffer(1) = buffer.getLong(1) + 1L
        // 2. 给这个城市的点击量 +1 =>   找到缓冲区的map,取出来这个城市原来的点击 + 1 ,再复制过去
        val map: collection.Map[String, Long] = buffer.getMap[String, Long](0)
        buffer(0) = map + (cityName -> (map.getOrElse(cityName, 0L) + 1L))
      case _ =>
    }
  }
 
  // 分区间的合并
  override def merge(buffer1: MutableAggregationBuffer, buffer2: Row): Unit = {
    val map1 = buffer1.getAs[Map[String, Long]](0)
    val map2 = buffer2.getAs[Map[String, Long]](0)
 
    val total1: Long = buffer1.getLong(1)
    val total2: Long = buffer2.getLong(1)
 
    // 1. 总数的聚合
    buffer1(1) = total1 + total2
    // 2. map的聚合
    buffer1(0) = map1.foldLeft(map2) {
      case (map, (cityName, count)) =>
        map + (cityName -> (map.getOrElse(cityName, 0L) + count))
    }
 
  }
 
  // 最终的输出结果
  override def evaluate(buffer: Row): Any = {
    // "北京21.2%,天津13.2%,其他65.6%"
    val cityAndCount: collection.Map[String, Long] = buffer.getMap[String, Long](0)
    val total: Long = buffer.getLong(1)
 
    val cityCountTop2: List[(String, Long)] = cityAndCount.toList.sortBy(-_._2).take(2)
    var cityRemarks: List[CityRemark] = cityCountTop2.map {
      case (cityName, count) => CityRemark(cityName, count.toDouble / total)
    }
//    CityRemark("其他",1 - cityremarks.foldLeft(0D)(_+_.cityRatio))
    cityRemarks :+= CityRemark("其他",cityRemarks.foldLeft(1D)(_ - _.cityRatio))
    cityRemarks.mkString(",")
  }
}
 
case class CityRemark(cityName: String, cityRatio: Double) {
  val formatter = new DecimalFormat("0.00%")
 
  override def toString: String = s"$cityName:${formatter.format(cityRatio)}"
 
}



运行结果




4 .保存到Mysql

1. 源码

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
val props: Properties = new Properties()
props.put("user","root")
props.put("password","199712")
spark.sql(
  """
    |select
    |    area,
    |    product_name,
    |    count,
    |    remark
    |from t3
    |where rk<=3
    |""".stripMargin)
  .coalesce(1)
  .write
  .mode("overwrite")
  .jdbc("jdbc:mysql://hadoop002:3306/rdd?useUnicode=true&characterEncoding=utf8", "spark0806", props)



2.运行结果





三. 完整代码

1. udaf

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.buwenbuhuo.spark.sql.project
 
import java.text.DecimalFormat
 
import org.apache.spark.sql.Row
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction}
import org.apache.spark.sql.types._
 
 
/**
 **
 *
 * @author 不温卜火
 *         *
 * @create 2020-08-06 13:24
 **
 *         MyCSDN :  [url=https://buwenbuhuo.blog.csdn.net/]https://buwenbuhuo.blog.csdn.net/[/url]
 *
 */
class CityRemarkUDAF extends UserDefinedAggregateFunction {
  // 输入数据的类型:  北京  String
  override def inputSchema: StructType = {
    StructType(Array(StructField("city", StringType)))
  }
 
  // 缓存的数据的类型 每个地区的每个商品 缓冲所有城市的点击量 北京->1000, 天津->5000  Map,  总的点击量  1000/?
  override def bufferSchema: StructType = {
    StructType(Array(StructField("map", MapType(StringType, LongType)), StructField("total", LongType)))
  }
 
  // 输出的数据类型  "北京21.2%,天津13.2%,其他65.6%"  String
  override def dataType: DataType = StringType
 
  // 相同的输入是否应用有相同的输出.
  override def deterministic: Boolean = true
 
  // 给存储数据初始化
  override def initialize(buffer: MutableAggregationBuffer): Unit = {
    //初始化map缓存
    buffer(0) = Map[String, Long]()
    // 初始化总的点击量
    buffer(1) = 0L
  }
 
  // 分区内合并 Map[城市名, 点击量]
  override def update(buffer: MutableAggregationBuffer, input: Row): Unit = {
    input match {
      case Row(cityName: String) =>
        // 1. 总的点击量 + 1
        buffer(1) = buffer.getLong(1) + 1L
        // 2. 给这个城市的点击量 +1 =>   找到缓冲区的map,取出来这个城市原来的点击 + 1 ,再复制过去
        val map: collection.Map[String, Long] = buffer.getMap[String, Long](0)
        buffer(0) = map + (cityName -> (map.getOrElse(cityName, 0L) + 1L))
      case _ =>
    }
  }
 
  // 分区间的合并
  override def merge(buffer1: MutableAggregationBuffer, buffer2: Row): Unit = {
    val map1 = buffer1.getAs[Map[String, Long]](0)
    val map2 = buffer2.getAs[Map[String, Long]](0)
 
    val total1: Long = buffer1.getLong(1)
    val total2: Long = buffer2.getLong(1)
 
    // 1. 总数的聚合
    buffer1(1) = total1 + total2
    // 2. map的聚合
    buffer1(0) = map1.foldLeft(map2) {
      case (map, (cityName, count)) =>
        map + (cityName -> (map.getOrElse(cityName, 0L) + count))
    }
 
  }
 
  // 最终的输出结果
  override def evaluate(buffer: Row): Any = {
    // "北京21.2%,天津13.2%,其他65.6%"
    val cityAndCount: collection.Map[String, Long] = buffer.getMap[String, Long](0)
    val total: Long = buffer.getLong(1)
 
    val cityCountTop2: List[(String, Long)] = cityAndCount.toList.sortBy(-_._2).take(2)
    var cityRemarks: List[CityRemark] = cityCountTop2.map {
      case (cityName, count) => CityRemark(cityName, count.toDouble / total)
    }
//    CityRemark("其他",1 - cityremarks.foldLeft(0D)(_+_.cityRatio))
    cityRemarks :+= CityRemark("其他",cityRemarks.foldLeft(1D)(_ - _.cityRatio))
    cityRemarks.mkString(",")
  }
}
 
case class CityRemark(cityName: String, cityRatio: Double) {
  val formatter = new DecimalFormat("0.00%")
 
  override def toString: String = s"$cityName:${formatter.format(cityRatio)}"
 
}



2. 主程序(具体实现)

 

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.buwenbuhuo.spark.sql.project
 
import java.util.Properties
 
import org.apache.spark.sql.SparkSession
 
/**
 **
 *
 * @author 不温卜火
 *         *
 * @create 2020-08-05 19:01
 **
 *         MyCSDN :  [url=https://buwenbuhuo.blog.csdn.net/]https://buwenbuhuo.blog.csdn.net/[/url]
 *
 */
object SqlApp {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession
      .builder()
      .master("local")
      .appName("SqlApp")
      .enableHiveSupport()
      .getOrCreate()
    import spark.implicits._
    spark.udf.register("remark",new CityRemarkUDAF)
 
    // 去执行sql,从hive查询数据
    spark.sql("use spark0806")
    spark.sql(
      """
        |select
        |    ci.*,
        |    pi.product_name,
        |    uva.click_product_id
        |from user_visit_action uva
        |join product_info pi on uva.click_product_id=pi.product_id
        |join city_info ci on uva.city_id=ci.city_id
        |
        |""".stripMargin).createOrReplaceTempView("t1")
 
    spark.sql(
      """
        |select
        |    area,
        |    product_name,
        |    count(*) count,
        |    remark(city_name) remark
        |from t1
        |group by area, product_name
        |""".stripMargin).createOrReplaceTempView("t2")
 
    spark.sql(
      """
        |select
        |    area,
        |    product_name,
        |    count,
        |    remark,
        |    rank() over(partition by area order by count desc) rk
        |from t2
        |""".stripMargin).createOrReplaceTempView("t3")
 
    val props: Properties = new Properties()
    props.put("user","root")
    props.put("password","199712")
    spark.sql(
      """
        |select
        |    area,
        |    product_name,
        |    count,
        |    remark
        |from t3
        |where rk<=3
        |""".stripMargin)
      .coalesce(1)
      .write
      .mode("overwrite")
      .jdbc("jdbc:mysql://hadoop002:3306/rdd?useUnicode=true&characterEncoding=utf8", "spark0806", props)
 
 
    // 把结果写入到mysql中
 
    spark.close()
  }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spark SQL 项目:实现各区域热门商品前N统计 的相关文章

  • 基于Spark的电商用户行为实时分析可视化系统(Flask-SocketIO)

    基于Spark的电商用户行为实时分析可视化系统 Flask SocketIO 项目简介 该项目已上线蓝桥课程 有需要的可凭邀请码 UB5mdLbl 学习哦 有优惠 课程地址 https www lanqiao cn courses 2629
  • HDFS 分布式文件系统详解

    1 HDFS概述 Hadoop 分布式系统框架中 首要的基础功能就是文件系统 在 Hadoop 中使用 FileSystem 这个抽象类来表示我们的文件系统 这个抽象类下面有很多子实现类 究竟使用哪一种 需要看我们具体的实现类 在我们实际工
  • GBase 8a 问题处理-集群管理节点无法正常启动

    问题版本 GBase 8a V8 6 2 43 R20 问题简述 在进行迁移工作的数据导入之后 启动集群所有管理节点一直不能正常启动 通过命令service gcware stop 也不能停止 报错信息 gcadmin 报错 Could n
  • 记一次Spark打包错误:object java.lang.Object in compiler mirror

    使用maven compile和package 一直报错scala reflect internal MissingRequirementError object scala runtime in compiler mirror not f
  • Hadoop 之上的数据建模 - Data Vault 2.0

    对比传统的基于 RDBMS 之上的数据仓库和商业智能项目 尝试着说说 Hadoop 之上的数据仓库 从ETL 数据存储 到分析展现 重点围绕数据建模方面做分析 因为这是本文的重点 介绍一份新的数据建模方式 Data Vault 2 0 ET
  • IIS7解析漏洞复现

    首先我们在win7上安装IIS7 控制面板 程序 打开或关闭windows功能 勾选如下信息 尽量勾选多一点防止实验失败 点击确定 稍等 在windows7虚拟机安装phpstudy2018版本 可先在物理机下载压缩包 然后上传到虚拟机 然
  • spark-submit 报错 Initial job has not accepted any resources

    spark submit 报这样的错误 WARN scheduler TaskSchedulerImpl Initial job has not accepted any resources check your cluster UI to
  • 学习笔记-Spark环境搭建与使用

    一 20 04 Ubuntu安装 清华源ISO源 https mirrors tuna tsinghua edu cn ubuntu releases 20 04 下载链接 https mirrors tuna tsinghua edu c
  • 11.Linux下Spark的安装配置以及spark-shell的启动和 Spark集群环境搭建

    本案例软件包 链接 https pan baidu com s 1zABhjj2umontXe2CYBW DQ 提取码 1123 若链接失效在下面评论 我会及时更新 目录 1 安装Spark 1 先用xftp将安装包传到home hadoo
  • sparkstreamming 消费kafka(2)

    spark streaming提供了两种获取方式 一种是同storm一样 实时读取缓存到内存中 另一种是定时批量读取 这两种方式分别是 Receiver base Direct 一 Receiver base Spark官方最先提供了基于R
  • 数据ETL面临的问题----数据缺失

    数据缺失的类型有 完全随机缺失 Missing Completely at Random MCAR 数据的缺失与不完全变量以及完全变量都是无关的 随机缺失 Missing at Random MAR 数据的缺失不是完全随机的 数据的缺失只依
  • HiveSQL原理和优化详解

    Hive SQL 编译成MapReduce过程 编译 SQL 的任务是在上节中介绍的 COMPILER 编译器组件 中完成的 Hive将SQL转化为MapReduce任务 整个编译过程分为六个阶段 词法 语法解析 Antlr 定义 SQL
  • 大数据之hive(数据仓库工具)的分组和分区操作

    注 在对hive的概念 优缺点 安装部署和参数配置在之后再进行总结 本小节主要对hive中的分组和分区进行总结 一 分组 1 group by语句 group by通常和聚合函数一起使用 按照一个或者多个列进行分组 然后对每个组进行聚合操作
  • 数据挖掘知识浅析

    一 什么是数据挖掘 数据挖掘是指从大量数据中提取或 挖掘 知识 数据挖掘是一种 黄金挖掘 从沙子堆中挖掘出黄金 找出最有价值的黄金 这种有机的价值物提取的过程称为 黄金挖掘 通过某种手段或者经验丰富人士 从海量的数据中找出有用的 数据 掌握
  • Spark Sql之dropDuplicates去重

    文章目录 算子介绍 示例 问题 解决 dropDuplicates和distinct 参考 算子介绍 dropDuplicates去重原则 按数据行的顺序保留每行数据出现的第一条 dropDuplicates 在Spark源码里面提供了以下
  • 数仓面试总结

    2021年5月开始找工作 面试了若干个数仓的岗位 面的差不多也就2个 总结下大致的面试内容 一 字节视频面 上海的一个部门 视频面挂 小伙伴内推的 这个5月份面的 大概视频面试了一个小时 主要面试内容 1 问了mapreduce的具体执行过
  • Spark 配置

    文章目录 1 Spark 配置 1 1 Spark 属性 1 1 1 动态加载Spark属性 1 1 2 查看Spark属性 1 2 环境变量 2 重新指定配置文件目录 3 继承Hadoop集群配置 4 定制的Hadoop Hive配置 1
  • 头歌—密码学基础

    第1关 哈希函数 题目 任务描述 本关任务 利用哈希算法统计每个字符串出现的个数 相关知识 为了完成本关任务 你需要掌握 1 密码学哈希函数的概念及特性 2 安全哈希算法 密码学哈希函数的概念及特性 我们需要理解的第一个密码学的基础知识是密
  • 解决 Hive 外部表分隔符问题的实用指南

    简介 在使用 Hive 外部表时 分隔符设置不当可能导致数据导入和查询过程中的问题 本文将详细介绍如何解决在 Hive 外部表中正确设置分隔符的步骤 问题描述 在使用Hive外部表时 可能会遇到分隔符问题 这主要是因为Hive在读取数据时
  • 解决 Hive 外部表分隔符问题的实用指南

    简介 在使用 Hive 外部表时 分隔符设置不当可能导致数据导入和查询过程中的问题 本文将详细介绍如何解决在 Hive 外部表中正确设置分隔符的步骤 问题描述 在使用Hive外部表时 可能会遇到分隔符问题 这主要是因为Hive在读取数据时

随机推荐

  • shell命令之cp复制拷贝

    1 复制文件到文件中 cp file1 file2 file1 file2 表示某一文件 在当前目录下 将file1 的文件内容复制到file2 文件中 如果第二个文件不存在 则先创建文件 然后再拷贝内容 如果存在则直接覆盖 没有警告 加
  • C++ 函数指针

    include
  • 基于SSM+JSP的宠物医院信息管理系统

    项目背景 21世纪的今天 随着社会的不断发展与进步 人们对于信息科学化的认识 已由低层次向高层次发展 由原来的感性认识向理性认识提高 管理工作的重要性已逐渐被人们所认识 科学化的管理 使信息存储达到准确 快速 完善 并能提高工作管理效率 促
  • bp利率最新消息是多少,bps利率是什么意思

    武汉房贷利率最新消息2022 3月26日起 武汉房贷利率将下调48BP 首套房贷款利率为5 2 二套房为5 4 其实武汉下调房贷利率也是在意料之内 此前的利率放在全国范围内比较 其实是比较高的 那利率降低后 每月能省多少钱呢 武汉房贷利率最
  • SSM框架和Spring Boot+Mybatis框架的性能比较?

    SSM框架和Spring Boot Mybatis框架的性能比较 没有一个绝对的答案 因为它们的性能受到很多因素的影响 例如项目的规模 复杂度 需求 技术栈 团队水平 测试环境 测试方法等 因此 我们不能简单地说哪个框架的性能更好 而是需要
  • qt 使用uic.exe 生成ui_xxxx.h文件的方法

    自己遇到这个问题 看了下别人的回答 总是有些不太清楚 就自己完善了下 1 制作好自己的xxxx ui文件 2 确定uic exe文件的地址 比如我的就是 D Anaconda3 pkgs qt 5 9 7 vc14h73c81de 0 Li
  • 雪糕的最大数量 排序+贪心

    雪糕的最大数量 雪糕的最大数量 题目描述 样例 数据范围 思路 代码 题目描述 夏日炎炎 小男孩 Tony 想买一些雪糕消消暑 商店中新到 n 支雪糕 用长度为 n 的数组 costs 表示雪糕的定价 其中 costs i 表示第 i 支雪
  • 于仕琪老师libfacedetection最新开源代码使用测试配置

    一 首先要感谢于老师的分享 二 此教程只是方便像我这样编程小白入门使用 若有不足之处 请原谅 网上对libfacedetection的介绍已经很多了 我在这里就不进行多余的解释 直接进入主题 下载地址 https github com Sh
  • Fsm2 Fsm2

    This is a Moore state machine with two states two inputs and one output Implement this state machine This exercise is th
  • 时序预测

    时序预测 MATLAB实现DBN深度置信网络时间序列预测 目录 时序预测 MATLAB实现DBN深度置信网络时间序列预测 预测效果 基本介绍 模型描述 程序设计 参考资料 预测效果 基本介绍 BP神经网络是1968年由Rumelhart和M
  • QMainwindow中添加的其他组件无法发送消息调用槽函数

    QMainwindow中添加的其他组件无法发送消息调用槽函数 问题所在 解决办法 问题所在 include mainwindow h include ui mainwindow h include QDebug include QMessa
  • [超实用]Java返回结果的工具类

    在做项目中 处理完各种业务数据后都需要返回值告诉前端最后的操作结果 但又不能直接返回一串错误代码信息 这个时候结果处理工具类就起了有比较好的作用 在此记录下 比较简单返回结果处理方法供大家参考学习 1 结果返回处理业务类 package r
  • python123.io---双一流高校及所在省份统计

    双一流高校及所在省份统计 类型 Python 组合数据类型 字典 d 中存储了我国 42 所双一流高校及所在省份的对应关系 请以这个列表为数据变量 完善 Python 代码 统计各省份学校的数量 d 北京大学
  • vue安装Base64转码

    第一步 项目文件路径下运行 npm install save js base64 或者 cnpm install save js base64 第二步 main js文件中引入 const Base64 require js base64
  • vue——vue-video-player插件实现rtmp直播流

    更新 flash已不可再使用 大家另寻出路吧 安装前首先需要注意几个点 vue video player插件 其实就是 video js 集成到 vue 中 所以千万不要再安装 video js 可能会出错 视频流我这个项目选择rtmp格式
  • 3559摄像头

    input aoni Webcam as devices platform soc 12310000 xhci 1 usb1 1 1 1 1 1 0 input input0 yuv转 的代码 https github com 198708
  • DC/DC闭环控制的丘克(Cuk)变换电路原理设计及实验仿真

    如果将降压 Buck 变换电路和升压 Boost 变换电路的拓扑结构进行对偶变换 即Boost变换电路和Buck变换电路串联在一起得到一种新的电路拓扑结构 丘克 CUK 变换电路 如图所示 Cuk变换电路的输入和输出均有电感 增加电感的值
  • matlab画圆并生成随机数

    A区域生成随机数 画圆 t 0 pi 100 2 pi x 10 cos t 30 3 y 10 sin t 89 8 plot x y r 生成随机数 a zeros 2 8 i 1 while i lt 8 temp1 rand 1 2
  • node中间件是什么意思?

    node中间件是什么意思 2020 09 11 16 11 17分类 常见问题 Node js答疑阅读 1757 评论 0 中间件是一种独立的系统软件或服务程序 分布式应用软件借助这种软件在不同的技术之间共享资源 中间件位于客户机 服务器的
  • Spark SQL 项目:实现各区域热门商品前N统计

    一 需求1 1 需求简介这里的热门商品是从点击量的维度来看的 计算各个区域前三大热门商品 并备注上每个商品在主要城市中的分布比例 超过两个城市用其他显示 1 2 思路分析使用 sql 来完成 碰到复杂的需求 可以使用 udf 或 udaf查