64bit/Database/Stores

From kJams Wiki
Jump to navigation Jump to search

goal: to have downloading and installing each music store database be very fast

Note: store songs are marked as such in the Library database (.ksql file). That way, when we load the database, if the user has "turned off" a particular store, we can just purge all song entries associated with that store

current design:

  1. kjams downloads an xml / json file for a particular store
  2. kjams parses each song in the downloaded.
  3. for each song, create a brand new song ID, start a transaction, then parse each bit of metadata (table colums) and add each bit of data to the DB as an individual call to sql, then when the song is completed, checkpoint the transaction. this is an extremely slow process. checkpointing may happen every 5 seconds instead of after every song. note this may be happening for up to N stores at once, each on a different thread, and gets slower as more stores are parsed at once due to database locking
  4. when entire store has completed parsing, we then associate each song with an existing song (swap the newly created ID of the song with the existing song ID) that way any playlists that already have that song in it will now reference the new song with possibly updated meta data. after all songs are done, purge all NEW song IDs (since they were swapped with old song IDs, we're actually purging the old songs, keeping the new ones with the old IDs) see function PreserveOldSongIDs() to understand what is happening

new design:

  1. see if sqlite file is available for download, if so, download THAT instead of xml / json, then skip to step 5 below
  2. do steps 1 and 2 from above
  3. ensure the store song data (running on separate thread) is stored in a new, separate database file, unreleated to the existing DB
  4. do step 3 above. it's OKAY if this part is slow
  5. kJams loads the store sqlite file and merges it into the existing Library.
  6. note the SongID stored per song in the store is ONLY unique within each store, and may conflict with SongID of Library once loaded: while loading we must give each record a new ID, then do something similar to PreserveOldSongIDs()