Handling very large lists of objects without paging?

Posted by user246114 on Stack Overflow See other posts from Stack Overflow or by user246114
Published on 2010-04-23T03:58:29Z Indexed on 2010/04/23 4:03 UTC
Read the original article Hit count: 199

Filed under:

Hi,

I have a class which can contain many small elements in a list. Looks like:

public class Farm {

    private ArrayList<Horse> mHorses;
}

just wondering what will happen if the mHorses array grew to something crazy like 15,000 elements. I'm assuming that trying to write and read this from the datastore would be crazy, because I'd get killed on the serialization process.

It's important that I can get the entire array in one shot without paging, and each Horse element may only have two string properties in it, so they are pretty lightweight:

public class Horse {
    private String mId;
    private String mName;
}

I don't need these horses indexed at all. Does it sound reasonable to just store the mHorse array as a raw Text field, and force my clients to do the deserialization? Something like:

public class Farm {
    private Text mHorsesSerialized;
}

then whenever the client receives a Farm instance, it has to take the raw string of horses, and split it in order to reinstantiate the list, something like:

// GWT client perhaps
Farm farm = rpcCall.getMyFarm();
String horsesSerialized = farm.getHorses();
String[] horseBlocks = horsesSerialized.split(",");
for (int i = 0; i < horseBlocks.length; i++) {
    // .. continue deserializing the individual objects ...
}

yeah...

so hopefully it would be quick to read a Farm instance from the datastore, and the serialization penalty is paid by the client,

Thanks

© Stack Overflow or respective owner

Related posts about google-app-engine