BIRGGIT stands for: Barely-Implemented and Roughly Graph-based GIT. This is clearly not an industrial project and is just meant as a funny nerdy introduction to Neo4J.
- JDK 7
- Maven 3
- Git 1.7+
- a certain sense of humor
See src/main/java/com/github/lateralthoughts/hands_on_neo4j/domain
.
All exercises are versioned under src/test/java/Exercise_x_Test.java
classes where x is a natural integer.
Given that those are arranged by increasing difficulty, we strongly advise you to follow the suggested order.
Other classes that might be of your interest lie in com.github.lateralthoughts.birggit.domain
and com.github.lateralthoughts.birggit.frontend.BIRGGIT
: the actual frontend for all your almighty commands.
Unless mentioned otherwise, the exercises will mostly consist in conforming to the written tests by filling the "holes" left in com.github.lateralthoughts.birggit.frontend.BIRGGIT
.
Please execute: git checkout -f exercise_1
.
Alright, you got it, BIRGGIT is just a brand new kick-ass versioning system.
Let us start with basic operations. Open com.github.lateralthoughts.birggit.Exercise_1_Test
and:
- register a project
- register a commit
- amend a commit
- big combo: commit to a branch of a project
As this is the first exercise, you might feel a bit lost.
Do not hesitate to check the test "infrastructure", i.e.
com.github.lateralthoughts.birggit.framework.suite.GraphTestSuite
. This class is
responsible for starting up/shutting down an embedded Neo4J instance and exposes our
software frontend class: com.github.lateralthoughts.birggit.frontend.BIRGGIT
.
We also wanted to keep the code concise in our test classes and thus removed some boilerplate.
To this extent, the most curious of you can check our custom AssertJ assertions for Neo4J
(com.github.lateralthoughts.birggit.framework.assertions.Neo4jAssertions
) as well as
LabelFinder, RelationTypeFinder and PropertyFinder which are in charge on configuring/inferring respectively
Neo4J Node label, Relationship type and properties.
The current way of handling unicity constraint is kinda cumbersome.
Try working with org.neo4j.graphdb.index.UniqueFactory.UniqueNodeFactory
and
org.neo4j.graphdb.index.UniqueFactory.UniqueRelationshipFactory
as well as our crafted
com.github.lateralthoughts.birggit.framework.annotations.GloballyUniqueIdentifier
annotation.
Please execute: git checkout -f exercise_2
.
The goal of this phase is to discover a few tricks :
- How to index data put into the Neo4j Graph using the embedded Lucene engine
- How to get these data back, and create new nodes.
So the real-life goal to achieve is to merge two branches,
we'll assume for the sake of simplicity that merging the branch feature into the branch master
only consists in taking the last two commits of both branches and creating a third commit
with the last two commits as parent.
So if you're ready : Open com.github.lateralthoughts.birggit.Exercise_2_Test
and let's merge !
Please execute: git checkout -f exercise_3
.
The goal of this exercise is to implement the real world feature of “git log”, that’s to say : “show me all the commits on a designated branch and optionally allow me to limit the number of results to be returned”.
In Neo4J, this will help to understand the key concept of “Traversals”. A Traversal has its own “dsl” and allows you to follow a Graph using a start node and some conditions.
The full API Documentation is available here : http://docs.neo4j.org/chunked/stable/tutorial-traversal-java-api.html
Hint to start : org.neo4j.kernel.Traversal.description
is the starting point
Hint 2 : You can decide whether it will be Breadth First Search (BFS) or Depth First Search (DFS).
Hint 3 : .traverse allows you to set the start node
Hint 4 : relationships have a direction “INCOMING” or “OUTGOING”
Please execute: git checkout -f exercise_4
.
As many modern systems, BIRGGIT builds in a top-notch garbage collector. Well... the “top-nochness” is still up to you : you have to implement it :-)
The main idea is to detect isolated commits (i.e. not in relation with any other nodes) and delete them, given they are not useful anymore.
To achieve so, let’s start playing with Cypher, the kick-ass query language developed by Neo4J. Open Exercise_4_Test
and write the Cypher queries that:
- find a commit by its hash
- delete a commit by its hash
- delete commits by their hashes
- find disconnected commits
And finally: implement GC as you want! Craft a new query or re-use previous methods… feel free.
Resources:
- Cypher cheat sheet (Neo4J v1.9): http://docs.neo4j.org/refcard/1.9/
- Cypher reference : http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html