Skip to content

Commit 54c9d98

Browse files
committed
python updates
1 parent ae48211 commit 54c9d98

6 files changed

Lines changed: 90 additions & 208 deletions

File tree

‎python/graphframes/classic/graphframe.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ def connectedComponents(
206206
algorithm: str = "graphframes",
207207
checkpointInterval: int = 2,
208208
broadcastThreshold: int = 1000000,
209+
useLabelsAsComponents: bool = False,
209210
) -> DataFrame:
210211
jdf = (
211212
self._jvm_graph.connectedComponents()
212213
.setAlgorithm(algorithm)
213214
.setCheckpointInterval(checkpointInterval)
214215
.setBroadcastThreshold(broadcastThreshold)
216+
.setUseLabelsAsComponents(useLabelsAsComponents)
215217
.run()
216218
)
217219
return DataFrame(jdf, self._spark)

‎python/graphframes/connect/graphframe_client.py‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ def connectedComponents(
504504
algorithm: str = "graphframes",
505505
checkpointInterval: int = 2,
506506
broadcastThreshold: int = 1000000,
507+
useLabelsAsComponents: bool = False,
507508
) -> DataFrame:
508509
class ConnectedComponents(LogicalPlan):
509510
def __init__(
@@ -513,28 +514,29 @@ def __init__(
513514
algorithm: str,
514515
checkpoint_interval: int,
515516
broadcast_threshold: int,
517+
useLabelsAsComponents: bool,
516518
) -> None:
517519
super().__init__(None)
518520
self.v = v
519521
self.e = e
520522
self.algorithm = algorithm
521523
self.checkpoint_interval = checkpoint_interval
522524
self.broadcast_threshold = broadcast_threshold
525+
self.useLabelsAsComponents = (useLabelsAsComponents,)
523526

524-
def plan(self, session: SparkConnectClient) -> proto.Relation:
525-
graphframes_api_call = GraphFrameConnect._get_pb_api_message(
526-
self.v, self.e, session
527-
)
528-
graphframes_api_call.connected_components.CopyFrom(
529-
pb.ConnectedComponents(
530-
algorithm=self.algorithm,
531-
checkpoint_interval=self.checkpoint_interval,
532-
broadcast_threshold=self.broadcast_threshold,
533-
)
527+
def plan(self, session: SparkConnectClient) -> proto.Relation:
528+
graphframes_api_call = GraphFrameConnect._get_pb_api_message(self.v, self.e, session)
529+
graphframes_api_call.connected_components.CopyFrom(
530+
pb.ConnectedComponents(
531+
algorithm=self.algorithm,
532+
checkpoint_interval=self.checkpoint_interval,
533+
broadcast_threshold=self.broadcast_threshold,
534+
use_labels_as_components=self.useLabelsAsComponents,
534535
)
535-
plan = self._create_proto_relation()
536-
plan.extension.Pack(graphframes_api_call)
537-
return plan
536+
)
537+
plan = self._create_proto_relation()
538+
plan.extension.Pack(graphframes_api_call)
539+
return plan
538540

539541
return _dataframe_from_plan(
540542
ConnectedComponents(
@@ -543,6 +545,7 @@ def plan(self, session: SparkConnectClient) -> proto.Relation:
543545
algorithm,
544546
checkpointInterval,
545547
broadcastThreshold,
548+
useLabelsAsComponents,
546549
),
547550
self._spark,
548551
)

0 commit comments

Comments
 (0)