Bill Roper (billroper) wrote,
Bill Roper

Huge Tracts of Code

I was writing a new interface layer in Java 7 today where I'm being handed a bunch of key/value pairs to use to look up and return various items of data.

So I wrote an immutable class with a constructor that processes the key/value pairs and loads up the keys into the correct locations in the object.

But I need to sort the queries so that all of the Key A queries are grouped together and all of the Key B queries are grouped together within the Key A queries. So I wrote a compareTo method for the immutable class that works through all of the data elements in the class, starting with Key A, then Key B, working down through Key N. Then I tossed the keys into a TreeSet, which happily sorted them so that when I walk through the elements, all of the matching values for Key A come first, all of the matching entries for Key B within Key A come next, and so on.

Then I created a class that would load an instance of the big in-memory dataset that Key A refers to. And I wrote a moderately long switch/case statement for each of the different kinds of data that I might return from the big dataset based on the original class that loaded up all of the key/value pairs.

I think this might work.

Of course, I still have to test it... :)
Tags: computers, java, musings, work

  • Tired

    I hit the wall late this afternoon. Sleep will follow soon now, but I needed to finish going through the APBA cards for next season. In other news,…

  • It Floats!

    I was discussing some of the intricacies of floating point mathematics with Gretchen over lunch today, which eventually led to her saying, "'Field of…

  • The Map of Tiny Perfect Things

    Last night, Gretchen and I watched "The Map of Tiny Perfect Things" on Amazon Prime. We liked it a lot. It owes (and acknowledges) a substantial debt…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded