diff options
author | Ankur Dave <ankurdave@gmail.com> | 2014-01-11 13:15:46 -0800 |
---|---|---|
committer | Ankur Dave <ankurdave@gmail.com> | 2014-01-11 13:15:46 -0800 |
commit | 02771aa087f1ee8f8e766f85d4092f4fc040f89f (patch) | |
tree | 6afd204b5dc7343b0ff5d6959672674ac5c442e1 /graphx/src | |
parent | 574c0d28c2e859a6ed31a2c193cf04e0aa7404a5 (diff) | |
download | spark-02771aa087f1ee8f8e766f85d4092f4fc040f89f.tar.gz spark-02771aa087f1ee8f8e766f85d4092f4fc040f89f.tar.bz2 spark-02771aa087f1ee8f8e766f85d4092f4fc040f89f.zip |
Make EdgeDirection val instead of case object for Java compat.
Diffstat (limited to 'graphx/src')
3 files changed, 15 insertions, 5 deletions
diff --git a/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala b/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala index 05103f6883..9d37f6513f 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala @@ -3,7 +3,7 @@ package org.apache.spark.graphx /** * The direction of a directed edge relative to a vertex. */ -sealed abstract class EdgeDirection { +class EdgeDirection private (private val name: String) extends Serializable { /** * Reverse the direction of an edge. An in becomes out, * out becomes in and both remains both. @@ -13,16 +13,25 @@ sealed abstract class EdgeDirection { case EdgeDirection.Out => EdgeDirection.In case EdgeDirection.Both => EdgeDirection.Both } + + override def toString: String = "EdgeDirection." + name + + override def equals(o: Any) = o match { + case other: EdgeDirection => other.name == name + case _ => false + } + + override def hashCode = name.hashCode } object EdgeDirection { /** Edges arriving at a vertex. */ - case object In extends EdgeDirection + final val In = new EdgeDirection("In") /** Edges originating from a vertex. */ - case object Out extends EdgeDirection + final val Out = new EdgeDirection("Out") /** All edges adjacent to a vertex. */ - case object Both extends EdgeDirection + final val Both = new EdgeDirection("Both") } diff --git a/graphx/src/main/scala/org/apache/spark/graphx/GraphKryoRegistrator.scala b/graphx/src/main/scala/org/apache/spark/graphx/GraphKryoRegistrator.scala index 681074ba10..d79bdf9618 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/GraphKryoRegistrator.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/GraphKryoRegistrator.scala @@ -23,6 +23,7 @@ class GraphKryoRegistrator extends KryoRegistrator { kryo.register(classOf[VertexAttributeBlock[Object]]) kryo.register(classOf[PartitionStrategy]) kryo.register(classOf[BoundedPriorityQueue[Object]]) + kryo.register(classOf[EdgeDirection]) // This avoids a large number of hash table lookups. kryo.setReferences(false) diff --git a/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala b/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala index c66b8c804f..6a2abc71cc 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/impl/GraphImpl.scala @@ -283,7 +283,7 @@ class GraphImpl[VD: ClassTag, ED: ClassTag] protected ( } case Some(EdgeDirection.In) => edgePartition.iterator.filter(e => vPart.isActive(e.dstId)) - case None => + case _ => // None edgePartition.iterator } |