Home » Author Archives: Mark Needham (page 3)

Author Archives: Mark Needham

Neo4j 2.1: Passing around node ids vs UNWIND

neo4j-logo

When Neo4j 2.1 is released we’ll have the UNWIND clause which makes working with collections of things easier. In my blog post about creating adjacency matrices we wanted to show how many people were members of the first 5 meetup groups ordered alphabetically and then check how many were members of each of the other groups.         ...

Read More »

Jersey/Jax RS: Streaming JSON

json-logo

About a year ago I wrote a blog post showing how to stream a HTTP response using Jersey/Jax RS and I recently wanted to do the same thing but this time using JSON. A common pattern is to take our Java object and get a JSON string representation of that but that isn’t the most efficient use of memory because ...

Read More »

Java 8: Lambda Expressions vs Auto Closeable

java-logo

If you used earlier versions of Neo4j via its Java API with Java 6 you probably have code similar to the following to ensure write operations happen within a transaction:                   public class StylesOfTx { public static void main( String[] args ) throws IOException { String path = "/tmp/tx-style-test"; FileUtils.deleteRecursively(new File(path)); GraphDatabaseService ...

Read More »

Java 8: Sorting values in collections

java-logo

Having realised that Java 8 is due for its GA release within the next few weeks I thought it was about time I had a look at it and over the last week have been reading Venkat Subramaniam’s book. I’m up to chapter 3 which covers sorting a collection of people. The Person class is defined roughly like so:   ...

Read More »

Java 8: Group by with collections

java-logo

In my continued reading of Venkat Subramaniam’s ‘Functional Programming in Java‘ I’ve reached the part of the book where the Stream#collect function is introduced. We want to take a collection of people, group them by age and return a map of (age -> people’s names) for which this comes in handy. To refresh, this is what the Person class looks ...

Read More »

Java: Handling a RuntimeException in a Runnable

java-logo

At the end of last year I was playing around with running scheduled tasks to monitor a Neo4j cluster and one of the problems I ran into was that the monitoring would sometimes exit. I eventually realised that this was because a RuntimeException was being thrown inside the Runnable method and I wasn’t handling it. The following code demonstrates the ...

Read More »

Java: Work out the serialVersionUID of a class

java-logo

Earlier in the week I wanted to work out the serialVersionUID of a serializable class so that I could override its toString method without breaking everything. I came across Frank Kim’s blog post which suggested using the serialver tool which comes with the JDK. I created a little Maven project to test this tool out on a very simple class: ...

Read More »

Neo4j Backup: Store copy and consistency check at Mark Needham

neo4j-logo

One of the lesser known things about the Neo4j online backup tool, which I wrote about last week, is that conceptually there are two parts to it: Copying the store files to a location of your choice Verifying that those store files are consistent. By default both of these run when you run the ‘neo4j-backup’ script but sometimes it’s useful ...

Read More »

Learning about bitmaps

java-logo

A few weeks ago Alistair and I were working on the code used to model the labels that a node has attached to it in a Neo4j database. The way this works is that chunks of 32 nodes ids are represented as a 32 bit bitmap for each label where a 1 for a bit means that a node has ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close