1
Je courais le code suivant tente de créer un graphique en GraphX Spark Apache.VertexRDD me indiquant le type d'erreur non-concordance
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.graphx.GraphLoader
import org.apache.spark.graphx.Graph
import org.apache.spark.rdd.RDD
import org.apache.spark.graphx.VertexId
//loads file from the array
val lines = sc.textFile("hdfs://moonshot-ha-nameservice/data/google-plus/2309.graph");
//maps lines and takes the first 21 characters of each line which is the node.
val result = lines.map(line => line.substring(0,20))
//creates a new variable with each node followed by a long .
val result2 = result.map(word => (word,1L).toLong)
//where i am getting an error
val vertexRDD: RDD[(Long,Long)] = sc.parallelize(result2)
Je reçois l'erreur suivante:
error: type mismatch;
found : org.apache.spark.rdd.RDD[(Long, Long)]
required: Seq[?]
Error occurred in an application involving default arguments.
val vertexRDD: RDD[(Long, Long)] = sc.parallelize(result2)
quand je lance votre code j'obtiens ce qui suit: (0 + 9)/59] 16/12/16 18:12:26 WARN TaskSetManager: Tâche perdue 8.0 à l'étape 3.0 (TID 126, moon07.eecs.qmul.ac.uk): java.lang.NumberFormatException: Pour la chaîne d'entrée: "10867043655226952823" \t at java.lang.NumberFormatException.forInputString (NumberFormatException.java:65) \t at java.lang.Long.parseLong (Long.java:592) \t à java.lang.Long.parseLong (Long.java:631) \t à scala.collection.immutable.StringLike $ class.toLong (StringLike.scala: 230) ...... –
@RhysCopperthwaite Oh, bien sûr, la valeur Long maximale a 19 caractères, donc votre sous-chaîne devrait le limiter à 18 pour être sûr. GraphX ne prend pas en charge les sommets avec des chaînes comme ID, vous devez donc avoir un ID numérique qui correspond à une valeur Long. Vous pouvez aussi essayer 'line.hashCode()' au lieu de 'line.substring()' si vous le souhaitez. –
@RhysCopperthwaite utilisant 'hashCode()' n'est peut-être pas la meilleure façon de définir l'ID. Vous devez vous assurer que chaque nœud a un identifiant numérique distinct qui pourrait tenir dans une variable Long. –