[KPhotoAlbum] Very experimental image-grouping patch

Paul Fleischer paul at xpg.dk
Wed Nov 28 13:21:46 GMT 2007


2007/11/28, Robert Krawitz <rlk at alum.mit.edu>:
> It depends upon what you're doing with those 50,000 images.  If you're
> looking at a large number of other images for each of those images,
> it's going to be slow.  If you're going to hit the disk for each of
> those images (check if it's present), it's going to be very slow
> indeed.  If you're just checking an in-memory flag, it might not be so
> bad.
>
> Can you write out the algorithm in pseudo-code?

Sure:

images = loadImagesFromXML();
foreach img in images {
  if( images->parent() != null ) {
     DB::ImageDB::instance()->info( img->parent() )->addChildImage(
img->fileName() );
  }
}

So, basically, we just do in-memory modifications. A more efficient
algorithm would be, if
loadImagesFromXML() builds a list of images that have parents:

(images, childImages) = loadImagesFromXML();
foreach img in childImages {
  if( images->parent() != null ) {
     DB::ImageDB::instance()->info( img->parent() )->addChildImage(
img->fileName() );
  }
}

(where childImages is a subset of images).

As far as I see it, there is a small gain in the second algorithm,
especially if no grouping is not used. But as far as I see it, all
four calls (parent(), info(), fileName() and addChildImage()) that are
made in each iteration of the loop are fairly cheap.

/Paul



More information about the Kphotoalbum mailing list