Skip to content
/ neo4j Public

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

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE.neo4j-scala
MIT
MIT-LICENSE
Notifications You must be signed in to change notification settings

maiha/neo4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE.neo4j-scala
MIT
MIT-LICENSE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published