1. 程式人生 > >RDD常用方法之subtract&intersection&cartesian

RDD常用方法之subtract&intersection&cartesian

subtract Return an RDD with the elements from `this` that are not in `other` .    
def subtract(other: RDD[T]): RDD[T]
def subtract(other: RDD[T], numPartitions: Int): RDD[T]
def subtract(other: RDD[T], p: Partitioner): RDD[T]
val a = sc.parallelize(1 to 5)
val b = sc.parallelize(1 to 3
) val c = a.subtract(b) c.collect Array[Int] = Array(4, 5)
intersection Return the intersection of this RDD and another one.  The output will not contain any duplicate elements, even if the input RDDs did.   交集
def intersection(other: RDD[T], numPartitions: Int): RDD[T]
def intersection(other: RDD[T], partitioner: Partitioner)(implicit ord: Ordering[T] 
= null): RDD[T] def intersection(other: RDD[T]): RDD[T]
val x = sc.parallelize(1 to 10)
val y = sc.parallelize(2 to 8)
val z = x.intersection(y)
z.collect
 Array[Int] = Array(4, 6, 8, 2, 3, 7, 5)
cartesian Return the Cartesian product of this RDD and another one, that is, the RDD of all pairs of elements (a, b) where a is in `this` and b is in `other` .   笛卡爾積
def cartesian[U: ClassTag](other: RDD[U]): RDD[(T, U)] 
val x = sc.parallelize(List(1,2,3))
val y = sc.parallelize(List(6,7,8))
x.cartesian(y).collect
 Array[(Int, Int)] = Array((1,6), (1,7), (1,8), (2,6), (3,6), (2,7), (2,8), (3,7), (3,8))

相關推薦

RDD常用方法subtract&intersection&cartesian

subtract Return an RDD with the elements from `this` that are not in `other` .     def subtract(other: RDD[T]): RDD[T] def subtract(other: RDD[T], n

PyQt基本佈局常用方法addStretch

from PyQt4.QtGui import * from PyQt4.QtCore import * import sys class LayoutDialog(QDialog): def __init__(self,parent=None):

C#專案常用方法靜態擴充套件

  一般專案中我們經常用到資料Json的序列化與反序列化,為了方便在需要的地方快速使用,一般建議都封裝為靜態擴充套件方法,在需要的地方可直接使用。   而目前C#專案中序列化一般都是用的 Newtonsoft.Json 來做的,因此這裡貼出通用靜態擴充套件方法供大家參考。 PS:若要新增此擴充套件方法,必須得

初識多線程基礎知識與常用方法

splay 線程與進程 -- 實現 class png sleep .com code 1.線程與進程的描述: 1.1進程:每個進程都有獨立的代碼和數據空間(進程上下文),進程間的切換會有較大的開銷,一個進程包含1~n個線程。(進程是資源分配的最小單位)   1.2線程:

Java線程,常用方法,線程同步,死鎖

時間 imp log 沖突 根據 oms adl 無法 誰的 1, 線程的概念 進程與線程 進程:每個進程都有獨立的代碼和數據空間(進程上下文),進程間的切換會有較大的開銷,一個進程包含1--n個線程。(進程是資源分配的最小單位) 線程:同一類線程共享代碼和數據空間,每個線

Ajax技術XMLHttpRequest(二)【XMLHttpRequest常用方法和屬性】

tro 沒有 body htm 事件 thead 指定 response date 一、XMLHttpRequest中常用的方法: (1)open()方法:用於設置進行異步請求目標的URL、請求方法以及其他參數信息。 函數原型:open("method","URL",asy

Selenium腳本基本元素常用方法

自動化測試 selenium webdriver 元素定位 上傳圖片 頁面基本元素:1.圖片上傳方法 private static void fileUpload(WebDriver driver, String s, String filepath) { WebElem

pythontime和datetime的常用方法

展現 時間戳 delta tuple sta 8.0 hour min alt 一、time的常用方法: import time,datetime# 時間有三種展現方式:時間戳,時間元組,格式化的時間print(time.time())#當前時間戳print(int(tim

Python學習路-string字符串的常用方法

sta with abs art nds tab isl ket itl 大小寫轉換 1 __author__ = "KuanKuan" 2 print("name is JankinYu".capitalize())#轉為首字母大寫 3 print("name i

Python學習路-list的常用方法

mov color copy dex span pen int 切片 python學習 增 append() insert(index,obj) #可以向指定位置添加 1 __author__ = "KuanKuan" 2 list = [] 3 list.append

Python學習路-字典dict常用方法

round 存在 set get 輸出 查詢 val 沒有 span 字典特性: dict無序 key唯一,天生去重 創建字典: way1:小心列表坑 1 __author__ = "KuanKuan" 2 d = dict.fromkeys([1, 2, 3

Integer常用方法

常用 ret static 進制數 exception BE pub parse num public static int parseInt(String s, int radix) throws NumberFormatException

Apache Commons IOFileUtils的常用方法

unit 文件系統 全部 string類 force 輸出 cfi 異常 兩個文件 Apache Commons IO 在學習io流的時候研究(翻譯)了一下這個,只有FileUtils的某些方法,並不全面,還請諒解 org.apache.commons.io 這個包下定義了

Java 集合HashSet常用方法實例介紹

java args arr 子類 boolean 常用 地址 比例 可能 一.簡介HashSet是Set常見的子類對象,此類實現Set接口,由哈希表(實際為HashMap實例)支持。 對集合的叠代次序不作任何保證; 特別是,它不能保證訂單在一段時間內保持不變。這個類允許nu

Spring註解開發-全面解析常用註解使用方法生命周期

統一 ota tco conf struct 賦值 組件註冊 功能 pri 本文github位置:https://github.com/WillVi/Spring-Annotation/ 往期文章:Spring註解開發-全面解析常用註解使用方法之組件註冊 bean生命周期

QT---QStringList類常用方法

從QList <QString>繼承而來,它提供快速索引為基礎的接入以及快速插入和清除 其成員函式用於操作這個字串列表如 append(),insert(), replace(), removeAll(), removeAt(), removeFirst(), removeLast(),

python資料型別列表(list)和其常用方法

列表是python常用資料型別之一,是可變的,可由n = []建立,也可由n = list()建立,第一種方法更常用。   常用方法總結:   # 建立方法 n = [] 或者 n = list() # index 查詢索引值 li = ['Edward', 'Mark'

python資料型別字典(dict)和其常用方法

字典的特徵: key-value結構key必須可hash,且必須為不可變資料型別、必須唯一。 # hash值都是數字,可以用類似於2分法(但比2分法厲害的多的方法)找。可存放任意多個值、可修改、可以不唯一無序查詢速度快常用方法: info = {'stu01': 'alex', 'stu02':

python資料型別集合(set)和其常用方法

集合是一個無序的,不重複的資料組合作用(集合的重點):1.去重,把一個列表變成集合就自動去重了2.關係測試,測試兩組資料庫之前的交集、差集、並集等關係 s = {1, 1, 2, 2, 3, 4, 'a', 'a', '!', '!'} print(type(s)) # <class 'set

Mysql基礎教程mysql 設定引數常用方法

1)設定mysql的全域性方法,設定完立刻重啟mysqlvim /etc/my.cnf[mysqld]interactive_timeout=1800wait_timeout=1800 全域性永久生效現在資料庫中設定,在修改檔案等需要重啟資料庫的時候在重啟mysqlset global interactiv