public static int purge(AlbumEntryDatabase db, Long albumId, Long photoId)
  {
    // purge 1 entry
    if (albumId != null && photoId != null)
    {
      CompoundKey key = new CompoundKey().append("photoId", photoId).append("albumId", albumId);
      final boolean isRemoved = (db.getData().remove(key) != null);
      return isRemoved ? 1 : 0;
    }

    // purge all
    if (albumId == null && photoId == null)
    {
      final int numPurged = db.getData().size();
      db.getData().clear();
      return numPurged;
    }

    // purge all matching one of key id, photo id
    Iterator<CompoundKey> it = db.getData().keySet().iterator();
    String partName;
    long compareId;
    if (albumId != null)
    {
      partName = "albumId";
      compareId = albumId;
    }
    else if (photoId != null)
    {
      partName = "photoId";
      compareId = photoId;
    }
    else
      throw new AssertionError();

    int numPurged = 0;
    while (it.hasNext())
    {
      CompoundKey key = it.next();
      if (key.getPart(partName).equals(compareId))
      {
        it.remove();
        numPurged++;
      }
    }
    return numPurged;
  }
@Test
  public void testResourcePurge()
  {
    // we put 2 photos in album 2; delete them
    Assert.assertEquals(_entryRes.purge(Long.valueOf(2), null), 2);
  }