首页 > 其他分享 >glom用法

glom用法

时间:2024-02-19 18:11:34浏览次数:19  
标签:glom val 用法 RDD conf sc dataRDD

Spark glom 功能:该函数将RDD中每一个分区变成一个数组,并放置在新的RDD中,数组中元素的类型与原分区中元素类型一致

    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("mapPartitionsWithIndex1")
    val sc = new SparkContext(conf)
    val dataRDD = sc.makeRDD(List(
      1,2,3,4
    ),2)
    /*
    * 内部调用MapPartitionsRDD方法,把每个partition的元素从Iterator类型转换为Array类型之后再包装到迭代器中返回
    * */
    val data: RDD[Int] = dataRDD.glom().map(_.max)
    println(data.collect().sum)
    sc.stop()

 

标签:glom,val,用法,RDD,conf,sc,dataRDD
From: https://www.cnblogs.com/huifeidezhuzai/p/18021700

相关文章

  • vue 监听器watch用法
    <template> <div>  <h1>{{message}}</h1>  <button@click="btnclick">点击</button> </div></template><script> exportdefault{  data(){   return{    message:'hello&......
  • vue 具名插槽slot 用法
    vue具名插槽slot为插槽取名字app.vue<template> <h1>插槽知识</h1> <SmallSlot> <template#header>  <div>  <ul>   <li>1</li>   <li>2</li>   <li>3</li>  </ul> ......
  • vue 插槽slot 用法
    vue插槽slot父组件为子组件传递html结构app.vue<template> <h1>插槽知识</h1> <SmallSlot> <div>  <ul>   <li>1</li>   <li>2</li>   <li>3</li>  </ul> </div> </Sma......
  • vue $emit事件用法
    App.vue<template> <ConpentA @paEvent="clickData"/> {{mes}}</template><script>importConpentAfrom'./components/ConpentA.vue';exportdefault{ data(){  return{   mes:''  } },......
  • Python 中 print 函数的用法
    在Python中,可以使用print函数来打印一个变量或者一个字符串:print("MynameisAlice")print(i)如果需要字符串格式化来打印一句话中包含变量的内容,有几种常用的方法:使用格式化字符串(f-string):在字符串前面加上字母"f",然后在字符串中使用大括号{}包裹变量名。示例代码如下:......
  • rand()函数用法、生成的范围
    1.rand()函数用法语法:#include<stdlib.h>intrand(void);功能:函数返回一个在零到RAND_MAX之间的伪随机整数。C++中引用头文件#include<cstdlib>2.rand()生成的范围1、rand()%100//返回0-99区间内一个随机数2、10+rand()%90//得到[10,99]区间内的一个随机数3、a......
  • vue 状态管理vuex action 用法
    index.jsimport{createStore}from"vuex";conststore=createStore({  state:{    count:100  },  getters:{    compower(state){      return(id)=>state.count*id    }  },  mutations:{   ......
  • vue 状态管理vuex Mutation 加传递参数用法
    index.js写法import{createStore}from"vuex";conststore=createStore({  state:{    count:100  },  getters:{    compower(state){      return(id)=>state.count*id    }  },  mutations:{  ......
  • SharePoint Online 列表规则的用法
    前言最近接到一个需求,用户希望如果有个列表的数据被其他用户设置成Closed状态的时候,能给管理员发邮件提个醒,邮件格式忽略不计。这个就好办了,尤其是邮件格式忽略不计,当然,如果邮件格式需要设计,也是可以做的,就不是半分钟能搞定的了。正文1.我们进入到列表里,......
  • 搜索引擎用法 cheatsheet
    逻辑写法与keyword1keyword2或keyword1ORkeyword2限定关键词的排列"keyword"限定搜索的网站site:cnblogs.comsite:cnblogs.com/Undefined443site:.com只搜索标题intitle:keywordallintitle:keyword1keyword2只搜索网页正文intext:keywordallint......