Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Neo4j manager that provides many commands such as load,dump,touch,inspect,list

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README
neo4j
=====

  Neo4j manager that provides many storage commands


Usage
=====

  neo <db-dir> <command>

Following commands are available

  * touch      : create an empty database
  * example    : create a sample database
  * info       : print node information
  * load <tsv> : load graph data from tsv
  * dump       : dump graph data as tsv
  * list       : print list of node ids
  * edges      : print edge list


Requirement
===========

  * Scala-2.8.0

  Tested on following jars in neo4j-1.2.M02 

  * geronimo-jta_1.1_spec-1.1.1.jar
  * neo4j-graph-algo-0.7-1.2.M02.jar
  * neo4j-kernel-1.2-1.2.M02.jar


Setup
=====

  1. compile
    % sbt package

  2. alias for convenient access to neo4j.ctl object
    % alias neo="scala -cp 'lib/*:target/scala_2.8.0/*' sc.ala.neo4j.ctl"


StorageManaging
===============

  create a sample database in "/tmp/neo1"

    % neo /tmp/neo1 example

  dump graph data as tsv written with triple (n1,edge,n2)

    % neo /tmp/neo1 dump > data.tsv
    % cat data.tsv
    Java    -null   Scala
    Ruby    +robust Scala

  load graph data from tsv written with triple (n1,edge,n2)

    % neo /tmp/neo2 load data.tsv

  here, both /tmp/neo1 and /tmp/neo2 contain same data


Coding
======

  % sbt console

    import sc.ala.neo4j.Neo

    // create empty database
    new Neo("/tmp/neo3") { touch }

    // write new nodes and edges
    new Neo("/tmp/neo3") { W{
      N("Python") --> "Looks like" --> N("Ruby")
    }}
    // NOTE: here "W" is a writer transaction
    // and "N" is an alias for findNodeOrCreateByName

    // read node named "Ruby"
    new Neo("/tmp/neo3") { R{
      println("id: " + n("Ruby").getId)
    }}
    // => id: 2
    // NOTE: here "R" is a reader transaction
    // and "n" is an alias for findNodeByName

    // "n" raise an error when the node is not found
    new Neo("/tmp/neo3") { R{
      n("XXX")
    }}
    // => sc.ala.neo4j.NodeNotFound: XXX

    
Author
======

  maiha@wota.jp
Something went wrong with that request. Please try again.