Home » Archives for Mark Needham » Page 10

Author Archives: Mark Needham

Java 8: Sorting values in collections

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

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

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

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

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

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 »

RxJava: From Future to Observable

I first came across Reactive Extensions about 4 years ago on Matthew Podwysocki’s blog but then haven’t heard much about it until I saw Matthew give a talk at Code Mesh a few weeks ago. It seems to have grown in popularity recently and I noticed that’s there’s now a Java version called RxJava written by Netflix. I thought I’d ...

Read More »

Java: Schedule a job to run on a time interval

Recently I’ve spent some time building a set of tests around rolling upgrades between Neo4j versions and as part of that I wanted to log the state of the cluster as the upgrade was happening. The main thread of the test blocks waiting until the upgrade is done so I wanted to log on another thread every few seconds. Alistair ...

Read More »

Neo4j: Making implicit relationships explicit & bidirectional relationships

I recently read Michal Bachman’s post about bidirectional relationships in Neo4j in which he suggests that for some relationship types we’re not that interested in the relationship’s direction and can therefore ignore it when querying. He uses the following example showing the partnership between Neo Technology and GraphAware: Both companies are partners with each other but since we can just ...

Read More »