Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tools/distributed_deduplication/dedup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import List, Optional, Tuple

from loguru import logger
from pyspark import SparkConf
from pyspark import SparkConf, StorageLevel
from pyspark.sql import SparkSession


Expand Down Expand Up @@ -93,10 +93,22 @@ def find_components(edges):

a = edges
while True:
b = a.flatMap(large_star_map).groupByKey().flatMap(large_star_reduce).distinct().cache()
a = b.map(small_star_map).groupByKey().flatMap(small_star_reduce).distinct().cache()
changes = a.subtract(b).union(b.subtract(a)).collect()
if len(changes) == 0:
b = (
a.flatMap(large_star_map)
.groupByKey()
.flatMap(large_star_reduce)
.distinct()
.persist(StorageLevel.MEMORY_AND_DISK)
)
a = (
b.map(small_star_map)
.groupByKey()
.flatMap(small_star_reduce)
.distinct()
.persist(StorageLevel.MEMORY_AND_DISK)
)
changes = a.subtract(b).union(b.subtract(a)).count()
if changes == 0:
break

results = a.collect()
Expand Down