-Improved bulk stream upsert into playlist performance by 5x.
-Added custom info item type for plain stream entity.
This commit is contained in:
parent
123f606d1e
commit
bd8c116785
7 changed files with 64 additions and 31 deletions
|
|
@ -288,7 +288,7 @@ public class LocalPlaylistFragment extends BaseListFragment<List<StreamEntity>,
|
|||
private List<InfoItem> getStreamItems(final List<StreamEntity> streams) {
|
||||
List<InfoItem> items = new ArrayList<>(streams.size());
|
||||
for (final StreamEntity stream : streams) {
|
||||
items.add(stream.toStreamInfoItem());
|
||||
items.add(stream.toStreamEntityInfoItem());
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,9 @@ public class LocalPlaylistManager {
|
|||
final int indexOffset) {
|
||||
|
||||
List<PlaylistStreamEntity> joinEntities = new ArrayList<>(streams.size());
|
||||
for (int index = 0; index < streams.size(); index++) {
|
||||
// Upsert streams and get their ids
|
||||
final long streamId = streamTable.upsert(streams.get(index));
|
||||
joinEntities.add(new PlaylistStreamEntity(playlistId, streamId,
|
||||
final List<Long> streamIds = streamTable.upsertAll(streams);
|
||||
for (int index = 0; index < streamIds.size(); index++) {
|
||||
joinEntities.add(new PlaylistStreamEntity(playlistId, streamIds.get(index),
|
||||
index + indexOffset));
|
||||
}
|
||||
return playlistStreamTable.insertAll(joinEntities);
|
||||
|
|
@ -76,7 +75,7 @@ public class LocalPlaylistManager {
|
|||
return Completable.fromRunnable(() -> database.runInTransaction(() -> {
|
||||
playlistStreamTable.deleteBatch(playlistId);
|
||||
playlistStreamTable.insertAll(joinEntities);
|
||||
}));
|
||||
})).subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Flowable<List<PlaylistMetadataEntry>> getPlaylists() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue