Farmer Brown has a tractor. Farmer Jones has a tractor. Both tractors break down every Monday.
Farmer Brown spends every Monday afternoon fixing his tractor and then gets a good five days of work in before he rests on Sunday.
Farmer Jones spends Monday afternoon evaluating the tractor and Monday evening discussing it with his wife writing up a plan and reviewing that plan for fixing it.
Tuesday morning Farmer Jones goes to the diner for coffee and a donut and to discuss his tractor woes with his pals, showing off his plan for fixing the tractor. One of the pals suggests it might not a problem with the doohickey as Farmer Jones suspects. He recommends that Farmer Brown take the tractor to the mechanic for further diagnosis and discussion. So Farmer Jones spends the rest of the day loading up his tractor onto the trailer and hauling it into town whereupon the mechanic tells him he can get to it first thing in the morning.
On Wednesday morning after coffee at the diner, Farmer Jones ambles on over to the mechanic shop and learns that the problem was indeed what he had suspected all along and that he could have fixed the problem in an hour or two on Monday afternoon. So farmer Jones loads up the tractor and takes it home only to find that his wife has baked a nice apple pie and so he spends a lazy afternoon eating pie and talking with his wife and the neighbor who has come over to gossip. That evening he fixes the tractor.
Now first thing Thursday morning, Farmer Jones gets to work and works through Sunday, making his wife cross with him for not attending Services at the church. Farmer Jones is too tired to listen and flops down in bed in need of rest.
And on Monday morning both tractors break down again.
Farmer Brown gets 20% more work done and rests one day a week.
Farmer Jones later gives up on farming and gets a job managing the parts store at the mechanic shop.
What kind of farmer are you?
A very large portion of my system drive, a 250GB SSD, seemed to be gobbled up with my fresh Windows 8.1 install and after install all my tools, I was fast running out of disk space on the C: drive. A quick search for culprits using Effective Search from SowSoft turned up a 64GB file called hiberfil.sys.
After a little hunting and poking, I found the GUI for power management options and tried to turn off hibernate. But that did not get rid of the file.
Not until I found and used the following in an “as Administrator” cmd window did I recover the 64GB of SSD space:
powercfg -h off
And yes, I have 64GB of RAM. Call me spoiled.
I’m a fan of LINQ and the IQueryable<T> interface power to compose dynamic queries based on input parameters. So when I needed to compose just such a query in a repository for a MongoDB collection, I found that the MongoDB C# 2.0.1 driver is currently missing the AsQueryable method which is slated for 2.1 release of the driver.
After a little searching, I found the Filter Definition Builder documentation and a happy alternative to building up or composing a query based on the presence of query parameters.
And here is a code sample:
public async Task<IEnumerable<MyData>> GetByQuery(MyDataQuery query)
{
var filter = ComposeFilter(query);
if (!query.Ascending)
{
var responses = await _invoiceCollection
.Find(filter)
.SortByDescending(x => x.TransactionDate)
.Skip(query.Index)
.Limit(query.Limit)
.ToListAsync();
return responses;
}
var ascResponses = await _invoiceCollection
.Find(filter)
.SortBy(x => x.TransactionDate)
.Skip(query.Index)
.Limit(query.Limit)
.ToListAsync();
return ascResponses;
}
private FilterDefinition<MyData> ComposeFilter(MyDataQuery query)
{
var builder = Builders<MyData>.Filter;
var filter = builder.Eq(x => x.CustomerId, query.CustomerId);
if (query.StartDate.HasValue)
{
filter = filter & builder.Gte(x => x.TransactionDate, query.StartDate.Value);
}
if (query.EndDate.HasValue)
{
filter = filter & builder.Lt(x => x.TransactionDate, query.EndDate.Value);
}
if (query.InvoiceId != null)
{
filter = filter & builder.Eq(x => x.InvoiceID, query.InvoiceId);
}
if (query.ItemId != null)
{
filter = filter & builder.Eq(x => x.ItemID, query.ItemId);
}
return filter;
}
So now you have a dynamic query based on composition logic. Of course this is a very simple example and there are bound to be far more sophisticated ways of doing the same thing, but I found this one worked very well for me.
This tweet from Scott Hanselman caught my eye because I spent nearly all of 2014 working on a graph solution for my employer that had it’s genesis in my study of Neo4J but primarily in my reading of this Microsoft Research paper (Sakr, Elnikety, and He) produced in 2012.
The essence of the Microsoft Research paper is storing edges (node relationships) in memory. So that’s what I did with unmanaged memory allocated in blocks using the Marshal.AllocHGlobal method. My own efforts were very specific with respect to my employer’s needs at the time and not really useable as a general purpose tool, so I was very pleased to see that Microsoft Research had an ongoing project called Trinity working to produce a more general purpose tool based on many of the same concepts originally explored by Sakr, Elnikety and He.
That tool was recently quietly released as the Microsoft Graph Engine. I’ve only had a little time to explore and understand it and look forward to spending more time using it soon. The essence is the same. Store the data in sequential chunks in raw unmanaged memory. Graph Engine uses Visual Studio to generate code on the fly using a meta language called Trinity Specification Language (TSL). Have a look through the documentation. If you’re considering graph database work, put Microsoft’s Graph Engine on your list of items to evaluate.
It's been seven months and two job changes and crazy busy with family, work and life.
Vacation is over.
List of things to blog about.
So much to say, so little time to say it.