Simple GraphX example.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple GraphX example.

Trevor Grant
Hi, I'm running Flink 1.0.2 from the Zeppelin/shell- trying to experiment with some graph stuff. 

Zeppelin has been known to add degrees of crazy to trouble shooting- but I intuitively feel like this is something I'm doing wrong on the Flink Side. 

The simplest example is not working for me.

import org.apache.flink.api.scala._

import org.apache.flink.graph.Edge
import org.apache.flink.graph.Vertex
import org.apache.flink.graph.Graph

val vertices = Seq(new Vertex[Long, String](1L, "foo"), new Vertex[Long, String](2L, "bar"))
val edges = Seq(new Edge[Long, String](1L, 2L, "foobar"))

val graph = Graph.fromCollection(edges, vertices)

Yields:

<console>:46: error: type mismatch;
found : Seq[org.apache.flink.graph.Edge[Long,String]]
required: java.util.Collection[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromCollection(edges, vertices)


I get a similar error when I try to make DataSets, 

found : org.apache.flink.api.scala.DataSet[org.apache.flink.graph.Edge[Long,Double]]
required: org.apache.flink.api.java.DataSet[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromDataSet( edges, vertices)

Thoughts?

thanks,
tg

Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil

Reply | Threaded
Open this post in threaded view
|

Re: Simple GraphX example.

Aljoscha Krettek
Hi,
I think you need to import the stuff from org.apache.flink.graph.scala.* instead of org.apache.flink.graph.*.

Cheers,
Aljoscha

On Wed, 27 Apr 2016 at 16:07 Trevor Grant <[hidden email]> wrote:
Hi, I'm running Flink 1.0.2 from the Zeppelin/shell- trying to experiment with some graph stuff. 

Zeppelin has been known to add degrees of crazy to trouble shooting- but I intuitively feel like this is something I'm doing wrong on the Flink Side. 

The simplest example is not working for me.

import org.apache.flink.api.scala._

import org.apache.flink.graph.Edge
import org.apache.flink.graph.Vertex
import org.apache.flink.graph.Graph

val vertices = Seq(new Vertex[Long, String](1L, "foo"), new Vertex[Long, String](2L, "bar"))
val edges = Seq(new Edge[Long, String](1L, 2L, "foobar"))

val graph = Graph.fromCollection(edges, vertices)

Yields:

<console>:46: error: type mismatch;
found : Seq[org.apache.flink.graph.Edge[Long,String]]
required: java.util.Collection[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromCollection(edges, vertices)


I get a similar error when I try to make DataSets, 

found : org.apache.flink.api.scala.DataSet[org.apache.flink.graph.Edge[Long,Double]]
required: org.apache.flink.api.java.DataSet[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromDataSet( edges, vertices)

Thoughts?

thanks,
tg

Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil

Reply | Threaded
Open this post in threaded view
|

Re: Simple GraphX example.

Trevor Grant
Ahh pro-tip.

Thanks Aljoscha!

Final solution in case any should stumble across this in the future:

You have to load the flink-gelly-scala jar AND the flink-gelly jar (to get access to the Edge/Vertex).

import org.apache.flink.api.scala._

import org.apache.flink.graph.scala._
import org.apache.flink.graph.Edge
import org.apache.flink.graph.Vertex


val vertices = Seq(new Vertex[Long, String](1L, "foo"), new Vertex[Long, String](2L, "bar"))
val edges = Seq(new Edge[Long, String](1L, 2L, "foobar"))

val graph = Graph.fromCollection( vertices, edges, env)


Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil


On Wed, Apr 27, 2016 at 9:13 AM, Aljoscha Krettek <[hidden email]> wrote:
Hi,
I think you need to import the stuff from org.apache.flink.graph.scala.* instead of org.apache.flink.graph.*.

Cheers,
Aljoscha

On Wed, 27 Apr 2016 at 16:07 Trevor Grant <[hidden email]> wrote:
Hi, I'm running Flink 1.0.2 from the Zeppelin/shell- trying to experiment with some graph stuff. 

Zeppelin has been known to add degrees of crazy to trouble shooting- but I intuitively feel like this is something I'm doing wrong on the Flink Side. 

The simplest example is not working for me.

import org.apache.flink.api.scala._

import org.apache.flink.graph.Edge
import org.apache.flink.graph.Vertex
import org.apache.flink.graph.Graph

val vertices = Seq(new Vertex[Long, String](1L, "foo"), new Vertex[Long, String](2L, "bar"))
val edges = Seq(new Edge[Long, String](1L, 2L, "foobar"))

val graph = Graph.fromCollection(edges, vertices)

Yields:

<console>:46: error: type mismatch;
found : Seq[org.apache.flink.graph.Edge[Long,String]]
required: java.util.Collection[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromCollection(edges, vertices)


I get a similar error when I try to make DataSets, 

found : org.apache.flink.api.scala.DataSet[org.apache.flink.graph.Edge[Long,Double]]
required: org.apache.flink.api.java.DataSet[org.apache.flink.graph.Edge[?,?]]
val graph = Graph.fromDataSet( edges, vertices)

Thoughts?

thanks,
tg

Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil