シータ交差
Datasketches Intersection オブジェクトを使用して、Datasketches ThetaSketch オブジェクトの 2 つのバイナリ表現の交差を返します。
構文
Python
from pyspark.sql import functions as sf
sf.theta_intersection(col1, col2)
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
|
| 最初のThetaスケッチ。 |
|
| 2番目のThetaスケッチ。 |
戻り値
pyspark.sql.Column: 交差した ThetaSketch のバイナリ表現。
例
例1 : 2つのThetaスケッチの交差を取得する
Python
from pyspark.sql import functions as sf
df = spark.createDataFrame([(1,1),(2,2),(3,2),(3,3)], "struct<v1:int,v2:int>")
df = df.agg(
sf.theta_sketch_agg("v1").alias("sketch1"),
sf.theta_sketch_agg("v2").alias("sketch2")
)
df.select(sf.theta_sketch_estimate(sf.theta_intersection(df.sketch1, "sketch2"))).show()
Output
+-----------------------------------------------------------+
|theta_sketch_estimate(theta_intersection(sketch1, sketch2))|
+-----------------------------------------------------------+
| 3|
+-----------------------------------------------------------+