码迷,mamicode.com
首页 > 其他好文 > 详细

spark1.统计句子中特定内容

时间:2017-03-26 19:18:26      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:imp   name   length   sim   map   contain   pre   oca   cat   

    val logFile = "./README.md"  // Should be some file on your server.
val conf = new SparkConf().setAppName("Simple Application").setMaster("local")
val sc = new SparkContext(conf)
val logData = sc.textFile(logFile, 2).cache()
// val numAs = logData.filter(line => line.contains("h")).count()
// val numBs = logData.filter(line => line.contains("j")).count()
var params = List("h","j","c","w");

var searchAnylisay = params.map(item => logData.filter(line => line.contains(item)).count() )

println("searchAnylisay length : %s,".format(searchAnylisay.length))

searchAnylisay.foreach( x => println(x))

spark1.统计句子中特定内容

标签:imp   name   length   sim   map   contain   pre   oca   cat   

原文地址:http://www.cnblogs.com/wcLT/p/6623635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!