Posts

Showing posts from September, 2013

Append-only files

I need to implement an append-only persistent data structure for a project using CQRS (I will use it for the event store). The records will be variable in length (a string serialization of the events using either XML, JSON or YAML - I haven't decided yet). Now, appending to a text file is easy in Windows; just open the file for append. However, I will also need to read the events, starting with a given Id ; that's harder to do with a text file. Given that I'm in a "designing algorithms" mood lately (see my first Coursera certificate ) and that I haven't been able to find a satisfactory library written by someone else, here's what I came up with. The data file Given that the records in the data file will have different lengths, I could use an end-of-record character as a delimiter; however, finding the next record would require a full record scan in that case. (Plus, I am not 100% sure that I want to use text serialization - maybe I'll switch to b