英文:
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 <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)
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论