Basically I am a java developer & now I got a chance to work on Spark & I gone through basics of the Spark api like what is SparkConfig, SparkContaxt, RDD, SQLContaxt, DataFrame, DataSet & then I able to perform some simple simple transformations using RDD, SQL.... but when I try to workout some sample graphframe application using java then I can'able to succeed & I gone through so many youtube tutorials, forums & stackoverflow threads but no where I haven't find any direct suggestion or solution.Actually I facing this issue when I try to create a object to GraphFrame class & I have downloaded receptive jar(graphframes-0.2.0-spark2.0-s_2.11.jar) too but still facing issue now I want put my analysis till where I reach due to very new to Spark I can't able to move further so if someone help me it's really helpful to all. Thanks in advance. The exception is I am facing The constructor GraphFrame(DataFrame, DataFrame) is undefined
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.RowFactory;
import org.apache.spark.sql.SQLContext;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.apache.spark.storage.StorageLevel;
import org.graphframes.GraphFrame;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
public class SparkJavaGraphFrameOne {
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException{
SparkConf conf = new SparkConf().setAppName("test").setMaster("local");
JavaSparkContext sc = new JavaSparkContext(conf);
SQLContext sqlContext = new org.apache.spark.sql.SQLContext(sc);
JavaRDD<Row> verRow = sc.parallelize(Arrays.asList(RowFactory.create(1,"A"),RowFactory.create(2,"B")));
JavaRDD<Row> edgRow = sc.parallelize(Arrays.asList(RowFactory.create(1,2,"Edge")));
List<StructField> verFields = new ArrayList<StructField>();
verFields.add(DataTypes.createStructField("id",DataTypes.IntegerType, true));
verFields.add(DataTypes.createStructField("name",DataTypes.StringType, true));
List<StructField> EdgFields = new ArrayList<StructField>();
EdgFields.add(DataTypes.createStructField("fromId",DataTypes.IntegerType, true));
EdgFields.add(DataTypes.createStructField("toId",DataTypes.IntegerType, true));
EdgFields.add(DataTypes.createStructField("name",DataTypes.StringType, true));
StructType verSchema = DataTypes.createStructType(verFields);
StructType edgSchema = DataTypes.createStructType(EdgFields);
DataFrame verDF = sqlContext.createDataFrame(verRow, verSchema);
DataFrame edgDF = sqlContext.createDataFrame(edgRow, edgSchema);
GraphFrame g = new GraphFrame(verDF,edgDF);
g.vertices().show();
g.edges().show();
g.persist(StorageLevel.MEMORY_AND_DISK());
}
}
I am able to replicate the issue(running continuously) in 0.5.0-spark2.1-s_2.11 and working fine in 0.4.0-spark2.1-s_2.11
I have written sample program in java using Spark 2.0.0 and GraphFrame 0.2.0. This program is based on the sample program given at http://graphframes.github.io/quick-start.html#start-using-graphframes. Hope this helps.
pom.xml
SparkGraphFrameSample.java
User.java
Relation.java
Console output
I don't know whether you are able to solve your problem or not. I have just seen your problem. I think for getting Exception in thread "main" java.lang.NoClassDefFoundError: com/typesafe/scalalogging/slf4j/LazyLogging, you need to put the following jar in your pom.xml
I have encountered the same issue and by adding this jar , I was able to resolve that issue.