Coherence .NET: Just Works…

It’s been a while since I’ve had a chance to play around with Coherence.NET (mainly because I predominantly been working with Java). However over the weekend I decided it was time to put a .NET and Excel front-end on one of my Coherence demos.  

I essentially have an application that keeps a few hundred thousand financial positions in cache (call it a Data Grid if you like) and would like to run some queries against them from .NET and later Excel.  Even without .NET equivalent classes of my Java object model, it was cool that I could still run a lot of queries out-of-the-box.

eg 1: Getting an .NET INamedCache – the equivalent of a Java NamedCache – was easy;

      INamedCache positionsCache = CacheFactory.GetCache("positions");

eg 2: Determining how many positions I had, also easy;

      int nrPositions = positionsCache.Count();

eg 3: Determining the distinct symbols for the positions (an aggregation);

      Object[] result = (Object[]) positionsCache.Aggregate(AlwaysFilter.Instance, new DistinctValues("getSymbol"));

The AlwaysFilter.Instance specifies that all positions must be considered.  While it’s possible to specify any other filter, in my example I’m looking for distinct symbols across all positions.  The result of the aggregator is an Object[], simply because the result of the DistinctValues aggregator is an Object[].  Note however that the Coherence permits aggregating any type of value (especially non-primitives).  In this case we’re aggregating the result of the “getSymbol” method on the positions class.  This aggregation is performed in parallel across the Data Grid.

More examples in the next few days.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s