Master vs Worker Nodes

    0

    1

    def getEventCountOnWeekdaysPerMonth(data: RDD[(LocalDateTime, Long)]): Array[(String, Long)] = {

    val result = data

    result.filter(e => e._1.getDayOfWeek.getValue < DayOfWeek.SATURDAY.getValue).map(mapDateTime2Date)

    result.reduceByKey(_ + _)

    result

    .map(e => (e._1.format(dateTimeFormatter), e.

    val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM")
    
    def getEventCountOnWeekdaysPerMonth(data: RDD[(LocalDateTime, Long)]): Array[(String, Long)] = {
      val result = data
        .filter(e => e._1.getDayOfWeek.getValue < DayOfWeek.SATURDAY.getValue)
        .map(mapDateTime2Date)
        .reduceByKey(_ + _)
        .collect()
    
      result
        .map(e => (e._1.format(formatter), e._2))
    }
    
    private def mapDateTime2Date(v: (LocalDateTime, Long)): (LocalDate, Long) = {
      (v._1.toLocalDate.withDayOfMonth(1), v._2)
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.