Saturday, December 15, 2007

OpenAniDB: Reinventing the Wheel

Hey, guys. In a lot of ways, the code I've been writing is fundamentally different than Python, and I keep finding myself writing code to do things that wx can do natively. (Would you believe I reinvented the hash map for strings before learning about wxHashMap?)

So, the state of things. UDP is pretty solid. It currently blocks on I/O. Ideally, we would select() and re-enter the code path once we get a response, but this is pretty good considering we are single-threaded. Also, instead of small nonce functions for each response/error code, I'm now letting each part of the app just switch{} between each code, and then the UDP object cleans up and handles any errors received. I'm sure there will be more tweaking, but I think it's pretty cool to be able to just "have things work" in regards to network errors. For example, if you receive a 555 ("Banned!") at any point during execution, the UDP object will pop up a box letting the user know, without bothering the main code.

The DB is, well, the DB. There's a lot of things unimplemented that the old DB system had; in particular, I have ditched the old per-table functions for a nice, generic Put() and Get(), which handle raw SQL statements. There's also PutRaw() and GetOne(), which wrap those into functions that are much more palatable. There's still a lot of app code which is missing. I haven't rebuilt the morass of code that drives the DB browser. I'm looking forward to it, though. It will be quite cool, I hope.

Hashing works. So does adding to the mylist. Hell, if that's all you really want, then it's done. Finished. The ability to load files into the hasher, hash 'em, and then send the hashes to AniDB is all there. However, renaming/moving hasn't been reimplemented, so if you need that, you're out of luck. Also, the whole thing with DB caching isn't quite working (and there's no way to test it without the DB browser,) so more code must be written.

Good news, though. Hashing is fast. I'm using a builtin MD4 instead of external libs, and frankly, it's ridiculously fast. 10-15 seconds to hash 170 MB. On Linux, at least, I can cache the entire file in memory after hashing, and then just do additional hashes from RAM, which is impressively speedy. On Windows, eh, not so much.

~C.

No comments: