object TopNApp {
  def  main (args: Array[String]) {
    if (args != 3) {
      System.err.println("usage: <flag> <inputpath> <outputpath>")
      System.exit(1)

      //应用类型
      val flag = args(0)
      //获得上下文内容
      val sc = new SparkContext
      //hdfsduqu 数据
      val datas = sc.textFile(args(1))
      val cache = datas.cache()

      //排序
      cache.filter(_.split('\t').length == 4).filter(_.split('\t')(0) == flag).map(_.split('\t')(1) -> 1)
        .reduceByKey(_ + _).map(x => (x._2, x._1)).sortByKey(false).map(y => (y._2, y._1)).saveAsTextFile(args(2))
      map((_, 1))
    }
  }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2021-07-20
  • 2022-12-23
  • 2021-10-25
  • 2021-08-02
猜你喜欢
  • 2022-12-23
  • 2021-04-18
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-02-08
  • 2021-06-04
相关资源
相似解决方案