
I have basic beginning to a parser for the BSON spec: http://www.mongodb.org/display/DOCS/BSON It is basically a binary compressed form of JSON. The usage model should be general, but I intend to read this data over TCP. Currently my system is quite inefficient, I convert leading bytes to Int then switch based on that type that that Int represtents. I was wondering if there is a tool set that exists for this purpose. For instance, should I use Data.Binary and make my Binary instance of get and put use the BSON protocol? Or is that not correct? I also looked at Parsec.ByteString, but that seems to only have a file input mechanism, and tcp buffers may be out of its scope. Are there any other tools that I should look at? I'm sure similar things have been done before. Can anyone point me to some open, successful implementations that I could mimick? -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein

2009/3/11 Rick R
I have basic beginning to a parser for the BSON spec: http://www.mongodb.org/display/DOCS/BSON It is basically a binary compressed form of JSON. The usage model should be general, but I intend to read this data over TCP. [...] I was wondering if there is a tool set that exists for this purpose. For instance, should I use Data.Binary and make my Binary instance of get and put use the BSON protocol? Or is that not correct?
It sounds like this would work well. I just used Data.Binary for the first time yesterday to parse a few several-hundred-megabyte files, and I have no complaints. Its interface allows for testing of nice properties, like that (decode . encode $ x) == x. Along with quickCheck and an Arbitrary instance for your unserialised types, this makes it easy to find problems in your coding. The Data.Binary authors have also gone to some trouble to make it all efficient -- you really should try it out. Denis
participants (2)
-
Denis Bueno
-
Rick R