flink-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andra Lungu <lungu.an...@gmail.com>
Subject Re: Queries regarding RDFs with Flink
Date Sun, 22 Mar 2015 12:07:10 GMT
Hi Flavio,

We don't have a specific example for generating RDF graphs using Gelly, but
I will try to drop some lines of code here and hope you will find them
useful.

An RDF statement is formed of Subject - Predicate - Object triples. In Edge
notation, the Subject and the Object will be the source and target vertices
respectively, while the edge value will be the predicate.

This being said, say you have an input plain text file that represents the
edges.
A line would look like this : http://test/Frank, marriedWith,
http://test/Mary

This is internally coded in Flink like a Tuple3. So, to read this edge file
you should have something like this:

private static DataSet<Edge<String, String>>
getEdgesDataSet(ExecutionEnvironment env) {
   if (fileOutput) {
      return env.readCsvFile(edgesInputPath)
            .lineDelimiter("\n")

            // the subject, predicate, object

            .types(String.class, String.class, String.class)
            .map(new MapFunction<Tuple3<String, String, String>,
                                                      Edge<String, String>>() {

               @Override
               public Edge<String, String> map(Tuple3<String, String,
String> tuple3) throws Exception {
                  return new Edge(tuple3.f0, tuple3.f2, tuple3.f1);
               }
            });
   } else {
      return getDefaultEdges(env);
   }
}

After you have this, in your main method, you just write:
Graph<Long, String, String> rdfGraph = Graph.fromDataSet(edges, env);

I picked up the conversation later on, not sure if that's what you meant by
"graph generation"...

Cheers,
Andra

On Sun, Mar 22, 2015 at 12:42 PM, Flavio Pompermaier <pompermaier@okkam.it>
wrote:

> Is there anu example about rdf graph generation based on a skeleton
> structure?
> On Mar 22, 2015 12:28 PM, "Fabian Hueske" <fhueske@gmail.com> wrote:
>
> > Hi Flavio,
> >
> > also, Gelly is a superset of Spargel. It provides the same features and
> > much more.
> >
> > Since RDF is graph-structured, Gelly might be a good fit for your use
> case.
> >
> > Cheers, Fabian
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message