Giter Site home page Giter Site logo

rhino-graph-example's Introduction

Project Rhino Graph Example

Example code to read data from Project Rhino's dataset.

Requirements

  • Java (>=1.6)
  • Maven

Example Run

Let's say we have a part of the dataset at /home/stephen/part-m-00000.

We can make sure maven is all working by running:

mvn compile

We'll likely see some warnings but it should be fine as long as we see:

[INFO] BUILD SUCCESS

Next we can actually run the code:

mvn compile exec:java \
  -Dexec.mainClass="rhino.graph.example.CombinedGraphReaderExample" \
  -Dexec.args="/home/stephen/part-m-00000"

And we should see something like:

[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ rhino-graph-example ---
2014-07-04 19:11:40.414 java[62890:3c07] Unable to load realm info from SCDynamicStore
14/07/04 19:11:40 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your
platform... using builtin-java classes where applicable
Starting read.

2305843009225712352	 rhinoId: 2305843009225712352 Properties: [songLength:
<Item int_value:211000> songName: <Item string_value:Hackwave> songId:
<Item int_value:12018400> songMbid: <Item string_value:9783a9ef-629f-3374-8dde-633c3a156ac2> ]
outEdges: {similarSong --> 2305843009213804804 Properties:
[similarSongScore: <Item double_value:0.0010929900454357266> ] ...

Thrift Definition

Let's take a look at the thrift definition in graph.thrift:

struct TVertex { 1: optional i64 rhinoId, // A unique ID in the dataset for the vertex. 3: optional map<string, Item> properties, 4: optional list outEdges, }

(Note I've omitted fields that aren't present in the published data. We use those fields as part of the ETL pipeline outlined here.)

Each vertex has a 64bit ID named rhinoId. The properties field is a key-value map for the vertex. (ex. songName: ). These properties are defined by:

union Item {
  1: i16 short_value;
  2: i32 int_value;
  3: i64 long_value;
  4: double double_value;
  5: string string_value;
  6: binary bytes_value;
}

I don't think we use bytes_value anywhere.

Each vertex has a list of (directed) edges starting from itself.

struct TEdge {
    3: optional i64 rightRhinoId,
    5: optional string label, // The type of edge.
    6: optional map<string, Item> properties
}

Java Code

I've provided an example of reading the data files in CombinedGraphReaderExample. You may wish to modify the code to convert the data into a format more convenient for your use.

Getting the Data

Contact [email protected]

rhino-graph-example's People

Contributors

sholiday avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

sholiday

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.