-
Notifications
You must be signed in to change notification settings - Fork 264
Allow setting default ConnectedComponents configurations from spark config #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+181
−48
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/main/scala/org/apache/spark/sql/graphframes/GraphFramesConf.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| package org.apache.spark.sql.graphframes | ||
|
|
||
| import org.apache.spark.internal.config.ConfigEntry | ||
| import org.apache.spark.sql.SparkSession | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.storage.StorageLevel | ||
|
|
||
| object GraphFramesConf { | ||
| private val CONNECTED_COMPONENTS_ALGORITHM = | ||
| SQLConf | ||
| .buildConf("spark.graphframes.connectedComponents.algorithm") | ||
| .doc(""" Sets the connected components algorithm to use (default: "graphframes"). Supported algorithms | ||
| | - "graphframes": Uses alternating large star and small star iterations proposed in | ||
| | [[http://dx.doi.org/10.1145/2670979.2670997 Connected Components in MapReduce and Beyond]] | ||
| | with skewed join optimization. | ||
| | - "graphx": Converts the graph to a GraphX graph and then uses the connected components | ||
| | implementation in GraphX. | ||
| | @see org.graphframes.lib.ConnectedComponents.supportedAlgorithms""".stripMargin) | ||
| .version("0.9.0") | ||
| .stringConf | ||
| .createOptional | ||
|
|
||
| private val CONNECTED_COMPONENTS_BROADCAST_THRESHOLD = | ||
| SQLConf | ||
| .buildConf("spark.graphframes.connectedComponents.broadcastthreshold") | ||
| .doc(""" Sets broadcast threshold in propagating component assignments (default: 1000000). If a node | ||
| | degree is greater than this threshold at some iteration, its component assignment will be | ||
| | collected and then broadcasted back to propagate the assignment to its neighbors. Otherwise, | ||
| | the assignment propagation is done by a normal Spark join. This parameter is only used when | ||
| | the algorithm is set to "graphframes".""".stripMargin) | ||
| .version("0.9.0") | ||
| .intConf | ||
| .createOptional | ||
|
|
||
| private val CONNECTED_COMPONENTS_CHECKPOINT_INTERVAL = | ||
| SQLConf | ||
| .buildConf("spark.graphframes.connectedComponents.checkpointinterval") | ||
| .doc(""" Sets checkpoint interval in terms of number of iterations (default: 2). Checkpointing | ||
| | regularly helps recover from failures, clean shuffle files, shorten the lineage of the | ||
| | computation graph, and reduce the complexity of plan optimization. As of Spark 2.0, the | ||
| | complexity of plan optimization would grow exponentially without checkpointing. Hence, | ||
| | disabling or setting longer-than-default checkpoint intervals are not recommended. Checkpoint | ||
| | data is saved under `org.apache.spark.SparkContext.getCheckpointDir` with prefix | ||
| | "connected-components". If the checkpoint directory is not set, this throws a | ||
| | `java.io.IOException`. Set a nonpositive value to disable checkpointing. This parameter is | ||
| | only used when the algorithm is set to "graphframes". Its default value might change in the | ||
| | future. | ||
| | @see `org.apache.spark.SparkContext.setCheckpointDir` in Spark API doc""".stripMargin) | ||
| .version("0.9.0") | ||
| .intConf | ||
| .createOptional | ||
|
|
||
| private val CONNECTED_COMPONENTS_INTERMEDIATE_STORAGE_LEVEL = | ||
| SQLConf | ||
| .buildConf("spark.graphframes.connectedComponents.intermediatestoragelevel") | ||
| .doc("Sets storage level for intermediate datasets that require multiple passes (default: ``MEMORY_AND_DISK``).") | ||
| .version("0.9.0") | ||
| .stringConf | ||
| .createOptional | ||
|
|
||
| private def get(entry: ConfigEntry[_]): Option[String] = { | ||
| try { | ||
| Option(SparkSession.getActiveSession.get.conf.get(entry.key)) | ||
| } catch { | ||
| case _: NoSuchElementException => None | ||
| } | ||
| } | ||
|
|
||
| def getConnectedComponentsAlgorithm: Option[String] = { | ||
| get(CONNECTED_COMPONENTS_ALGORITHM) match { | ||
| case Some(threshold) => Some(threshold.toLowerCase) | ||
| case _ => None | ||
| } | ||
| } | ||
|
|
||
| def getConnectedComponentsBroadcastThreshold: Option[Int] = { | ||
| get(CONNECTED_COMPONENTS_BROADCAST_THRESHOLD) match { | ||
| case Some(threshold) => Some(threshold.toInt) | ||
| case _ => None | ||
| } | ||
| } | ||
|
|
||
| def getConnectedComponentsCheckpointInterval: Option[Int] = { | ||
| get(CONNECTED_COMPONENTS_CHECKPOINT_INTERVAL) match { | ||
| case Some(interval) => Some(interval.toInt) | ||
| case _ => None | ||
| } | ||
| } | ||
|
|
||
| def getConnectedComponentsStorageLevel: Option[StorageLevel] = { | ||
| get(CONNECTED_COMPONENTS_INTERMEDIATE_STORAGE_LEVEL) match { | ||
| case Some(level) => Some(StorageLevel.fromString(level.toUpperCase)) | ||
| case _ => None | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.