class AggregateMessages extends Arguments with Serializable
This is a primitive for implementing graph algorithms. This method aggregates messages from the neighboring edges and vertices of each vertex.
For each triplet (source vertex, edge, destination vertex) in GraphFrame.triplets, this can send a message to the source and/or destination vertices.
AggregateMessages.sendToSrc()
sends a message to the source vertex of each tripletAggregateMessages.sendToDst()
sends a message to the destination vertex of each tripletAggregateMessages.agg
specifies an aggregation function for aggregating the messages sent to each vertex. It also runs the aggregation, computing a DataFrame with one row for each vertex which receives > 0 messages. The DataFrame has 2 columns:- vertex column ID (named GraphFrame.ID)
- aggregate from messages sent to vertex (with the name given to the
Column
specified inAggregateMessages.agg()
)
When specifying the messages and aggregation function, the user may reference columns using:
- AggregateMessages.src: column for source vertex of edge
- AggregateMessages.edge: column for edge
- AggregateMessages.dst: column for destination vertex of edge
- AggregateMessages.msg: message sent to vertex (for aggregation function)
Note: If you use this operation to write an iterative algorithm, you may want to use getCachedDataFrame() as a workaround for caching issues.
We can use this function to compute the in-degree of each vertex
val g: GraphFrame = Graph.textFile("twittergraph") val inDeg: DataFrame = g.aggregateMessages().sendToDst(lit(1)).agg(sum(AggregateMessagesBuilder.msg))
- Alphabetic
- By Inheritance
- AggregateMessages
- Serializable
- Arguments
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from AggregateMessages toany2stringadd[AggregateMessages] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (AggregateMessages, B)
- Implicit
- This member is added by an implicit conversion from AggregateMessages toArrowAssoc[AggregateMessages] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def agg(aggCol: String): DataFrame
Run the aggregation, specifying SQL expression as a String
Run the aggregation, specifying SQL expression as a String
See the overloaded method documentation for more details.
- def agg(aggCol: Column): DataFrame
Run the aggregation, returning the resulting DataFrame of aggregated messages.
Run the aggregation, returning the resulting DataFrame of aggregated messages. This is a lazy operation, so the DataFrame will not be materialized until an action is executed on it.
This returns a DataFrame with schema:
- column "id": vertex ID
- aggCol: aggregate result If you need to join this with the original GraphFrame.vertices, you can run an inner join of the form:
val g: GraphFrame = ... val aggResult = g.AggregateMessagesBuilder.sendToSrc(msg).agg(aggFunc) aggResult.join(g.vertices, ID)
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def ensuring(cond: (AggregateMessages) => Boolean, msg: => Any): AggregateMessages
- Implicit
- This member is added by an implicit conversion from AggregateMessages toEnsuring[AggregateMessages] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (AggregateMessages) => Boolean): AggregateMessages
- Implicit
- This member is added by an implicit conversion from AggregateMessages toEnsuring[AggregateMessages] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): AggregateMessages
- Implicit
- This member is added by an implicit conversion from AggregateMessages toEnsuring[AggregateMessages] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): AggregateMessages
- Implicit
- This member is added by an implicit conversion from AggregateMessages toEnsuring[AggregateMessages] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def sendToDst(value: String): AggregateMessages.this.type
Send message to destination vertex, specifying SQL expression as a String
- def sendToDst(value: Column): AggregateMessages.this.type
Send message to destination vertex
- def sendToSrc(value: String): AggregateMessages.this.type
Send message to source vertex, specifying SQL expression as a String
- def sendToSrc(value: Column): AggregateMessages.this.type
Send message to source vertex
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from AggregateMessages toStringFormat[AggregateMessages] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (AggregateMessages, B)
- Implicit
- This member is added by an implicit conversion from AggregateMessages toArrowAssoc[AggregateMessages] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.