SparkSql-redis:将查询到的结果保存到redis中
2020.12.08號(hào)作業(yè)題
1.啟動(dòng)redis
redis-server /usr/local/redis/redis.conf
2.寫代碼
問(wèn)題1.計(jì)算出總的成交量總額(結(jié)果保存到redis中)
問(wèn)題2.計(jì)算每個(gè)商品分類的成交量(結(jié)果保存到redis中)
問(wèn)題3.計(jì)算每個(gè)省份的成交總額(結(jié)果保存到redis)
3.參考數(shù)據(jù)
A0001,202.106.196.115,手機(jī),iphone8,8000,海南省
A0002,202.106.196.116,服裝,Tshirt,450,湖南省
A0003,202.106.196.117,藥品,阿莫西林,40,廣東省
A0004,202.106.196.118,藥品,板藍(lán)根,23,湖北省
A0005,202.106.196.119,手機(jī),iphone9,8000,海南省
A0006,202.106.196.120,服裝,Tshirt,320,海南省
A0007,202.106.196.121,藥品,阿莫西林,40,湖北省
A0008,202.106.196.122,藥品,板藍(lán)根,23,湖北省
A0009,202.106.196.123,手機(jī),iphone10,8000,湖北省
A0010,202.106.196.124,服裝,Tshirt,450,湖北省
A0011,202.106.196.125,藥品,阿莫西林,40,湖北省
A0012,202.106.196.126,藥品,板藍(lán)根,23,廣東省
A0013,202.106.196.127,手機(jī),iphone11,8000,湖南省
A0014,202.106.196.128,服裝,Tshirt,450,湖南省
A0015,202.106.196.129,藥品,阿莫西林,40,湖南省
A0016,202.106.196.130,藥品,板藍(lán)根,23,湖南省
A0017,202.106.196.131,手機(jī),iphone12,9999,廣東省
A0018,202.106.196.132,服裝,Tshirt,340,湖南省
4.pom坐標(biāo)
<dependencies><dependency><groupId>org.apache.spark</groupId><artifactId>spark-streaming_2.11</artifactId><version>2.2.3</version></dependency><dependency><groupId>org.apache.spark</groupId><artifactId>spark-streaming-kafka-0-10_2.11</artifactId><version>2.2.3</version></dependency><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>3.0.0</version></dependency><dependency><groupId>org.apache.spark</groupId><artifactId>spark-core_2.11</artifactId><version>2.2.3</version></dependency><dependency><groupId>org.apache.spark</groupId><artifactId>spark-sql_2.11</artifactId><version>2.2.3</version></dependency><dependency><groupId>org.apache.spark</groupId><artifactId>spark-hive_2.11</artifactId><version>2.2.3</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.28</version></dependency></dependencies>總結(jié)
以上是生活随笔為你收集整理的SparkSql-redis:将查询到的结果保存到redis中的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: RT-Thread柿饼控件(3)-- C
- 下一篇: 第二届“中国制造(深圳)高峰论坛”举行