You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Trevor Grant <tr...@gmail.com> on 2016/04/27 16:07:02 UTC

Simple GraphX example.

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
https://github.com/rawkintrevo
http://stackexchange.com/users/3002022/rawkintrevo
http://trevorgrant.org

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

Re: Simple GraphX example.

Posted by Trevor Grant <tr...@gmail.com>.
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
https://github.com/rawkintrevo
http://stackexchange.com/users/3002022/rawkintrevo
http://trevorgrant.org

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


On Wed, Apr 27, 2016 at 9:13 AM, Aljoscha Krettek <al...@apache.org>
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 <tr...@gmail.com>
> 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
>> https://github.com/rawkintrevo
>> http://stackexchange.com/users/3002022/rawkintrevo
>> http://trevorgrant.org
>>
>> *"Fortunate is he, who is able to know the causes of things."  -Virgil*
>>
>>

Re: Simple GraphX example.

Posted by Aljoscha Krettek <al...@apache.org>.
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 <tr...@gmail.com> 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
> https://github.com/rawkintrevo
> http://stackexchange.com/users/3002022/rawkintrevo
> http://trevorgrant.org
>
> *"Fortunate is he, who is able to know the causes of things."  -Virgil*
>
>