在使用Java绑定创建Spark GraphX中的图时,那些 “evidence” 参数是什么?

huangapple go评论74阅读模式
英文:

Making a Graph in Spark GraphX using Java bindings: What are those "evidence" arguments?

问题

Spark GraphX javadoc中,fromEdges()方法具有未记录的参数,如evidence$17。这些很可能是Scala实现的遗留物,但在Java中我应该怎么处理它们?

public static <VD, ED> Graph<VD, ED> fromEdges(RDD<Edge<ED>> edges,
	 VD defaultValue,
	 StorageLevel edgeStorageLevel,
	 StorageLevel vertexStorageLevel,
	 scala.reflect.ClassTag<VD> evidence$16,
	 scala.reflect.ClassTag<ED> evidence$17)

更新:我找到了一些其他的Scala/Java示例,似乎正确的做法是ClassTag$.MODULE$.apply(myClass),其中myClass分别是VD或ED类型的类。尽管这实际上并不起作用,因为它会导致后来出现神秘的异常,比如在org.apache.spark.graphx.impl.EdgePartitionBuilder.toEdgePartition中出现java.lang.ArrayStoreException: java.lang.Integer的异常。

更新:确实,ClassTag$.MODULE$.apply(Long.class)对我有效。我之前遇到的错误是因为我将默认值设置为1而不是1L。

英文:

In the Spark GraphX javadoc the fromEdges() method has undocumented arguments like evidence$17. Presumably these are artifacts of the Scala implementation, but what should I do with them in Java?

public static &lt;VD,ED&gt; Graph&lt;VD,ED&gt; fromEdges(RDD&lt;Edge&lt;ED&gt;&gt; edges,
	 VD defaultValue,
	 StorageLevel edgeStorageLevel,
	 StorageLevel vertexStorageLevel,
	 scala.reflect.ClassTag&lt;VD&gt; evidence$16,
	 scala.reflect.ClassTag&lt;ED&gt; evidence$17)

UPDATE: found some other Scala/Java examples, and it seems like the right thing is ClassTag$.MODULE$.apply(myClass) where myClass is the class of the VD or ED type, respectively. Not that this actually works, as it leads to later, mysterious exceptions, like java.lang.ArrayStoreException: java.lang.Integer deep in org.apache.spark.graphx.impl.EdgePartitionBuilder.toEdgePartition

UPDATE: Indeed, the ClassTag$.MODULE$.apply(Long.class) works for me. The error I was getting was due to passing in 1 for the default value instead of 1L.

答案1

得分: 0

证据参数使用ClassTag$.MODULE$.apply(myClass)填充,其中myClass分别是VD或ED类型的类。

如果您将Long.class用于ED和VD类型,请确保在调用Graph.fromEdges()时使用匹配的默认值。特别是对于Long.class,请使用1L作为默认值,而不是1

英文:

The evidence arguments are filled in using ClassTag$.MODULE$.apply(myClass) where myClass is the class of the VD or ED type, respectively.

If you use Long.class for the ED and VD types, make sure to use a matching value for the defaults when you call Graph.fromEdges(). In particular for Long.class use e.g. 1L for the default value instead of 1.

huangapple
  • 本文由 发表于 2023年6月18日 21:23:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76500761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定