22 友盟項目--sparkstreaming對接kafka、集成redis--從redis中查詢月留存率
阿新 • • 發佈:2018-11-15
span 掃描 stream -c appid edi pac connect div 實時存儲到redis,更新用戶使用時間的最大、最小值--》來求留存率 避免全表掃描問題
1.spark 對接kafka 消費者 解析json
2.concat(appid,‘#‘,appversion,‘#‘,brand,‘#‘,appplatform,‘#‘,devicestyle,‘#‘,ostype,‘#‘,deviceid) ---> 作為key 各個維度
3.選出用戶使用app的最小時間戳min , 最大時間戳max -->作為value
4.存儲到redis
依賴
<dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming_2.11</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-streaming-kafka-0-10_2.11</artifactId> <version>2.1.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.17</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency>
22 友盟項目--sparkstreaming對接kafka、集成redis--從redis中查詢月留存率