Fluent.Interface



i4o (Indexed LINQ) adds support for POCO

Aaron Erickson has released a new version of his i4o (Indexed LINQ).  This great open source library dynamically hooks into the statically typed Expression Trees generated when querying with LINQ eg:

  var nonIndexedQuery = from item in list
      where item.DemoStringNonIndexed == nonIndexedString
      select item;
  var resultNonIndexed = nonIndexedQuery.ToList();

The library now supports indexing Plain Old C# objects (POCOs) such as PocoClass in the following example.  Attributes can still be applied to properties, but the new AddIndex method allows indexing objects that have no knowledge of i4o. 

var sampleSize = 1000000;
var list = new IndexableCollection();
for (int i = 0; i < sampleSize; i++) list.Add(new PocoClass() { DemoStringNonIndexed = Guid.NewGuid().ToString(), DemoStringIndexed = Guid.NewGuid().ToString() } ); list.AddIndex("DemoStringIndexed"); [/sourcecode] The biggest hit when using i4o is loading the data into the collection, then applying the index.  After that querying is markedly improved, in this example 85x faster then traditional select.

load 3725ms
index 3754ms
nonIndexedStopwatch 175ms
indexedStopwatch 2ms

This makes this an ideal library to be used in caching scenarios.  I wonder if it could be plugged into Microsoft’s new velocity distributed cache!

Advertisements

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

%d bloggers like this: