I need people opinions on how to improve a code I've written. Let's assume we have an application cataloging movies (~3500 of them) and actors (~1000, but I need to double-check this).
Both actors and movies are POJOs. An actor has a picture, stored on disk and its path in a database, along with the person others attributes. A movie has a set of actors and other POJOs attributes.
Given a movie, I need to be able to select the actors playing in it. I've therefore built a jlist with a scaled down buffered image of actors image. This jlist is heavily used through out the app. And the problems are with the performances of populating this jlist. It takes quite some time to create all the person objects and load their images (~2 mins) and this destroys usability. The bottleneck currently is the disk IO on the image reading. I have been through several iterations, but the latest is as follow:
- On start-up, loop through the person table, and create all the person objects with attributes accessible directly in the DB.
- Loop through the above collection of person objects, and for each one, go get its image and its buffered images (which are used in different contexts, the buffered image being used a lot more often) and add them as attributes. The images are on disk.
- Return the above synchronized arraylist to the application layer, and use it as a cache.
There is little differences between getting the attributes and the images in the same loop (in terms of performances at least). With this approach, I have to wait for the full 2 mins to create all the objects before starting to use the app. But using the jlist is super fast as I just need access to the cache. But I'd like to reduce the waiting time to load the app. I understand there is not much that can be done to improve the disk access, but maybe a better approach is possible.
This is a java application with swing and sqlite. I can share some part of the code if it helps clarify the question.