<lambda>null1 import androidx.paging.DataSource
2 import androidx.room.RoomDatabase
3 import androidx.room.RoomSQLiteQuery
4 import androidx.room.RoomSQLiteQuery.Companion.acquire
5 import androidx.room.paging.LimitOffsetDataSource
6 import androidx.room.util.appendPlaceholders
7 import androidx.room.util.getColumnIndex
8 import androidx.room.util.getColumnIndexOrThrow
9 import androidx.room.util.recursiveFetchMap
10 import androidx.room.util.toSQLiteConnection
11 import androidx.sqlite.SQLiteConnection
12 import androidx.sqlite.SQLiteStatement
13 import javax.`annotation`.processing.Generated
14 import kotlin.Int
15 import kotlin.Long
16 import kotlin.String
17 import kotlin.Suppress
18 import kotlin.collections.List
19 import kotlin.collections.MutableList
20 import kotlin.collections.MutableMap
21 import kotlin.collections.Set
22 import kotlin.collections.mutableListOf
23 import kotlin.collections.mutableMapOf
24 import kotlin.reflect.KClass
25 import kotlin.text.StringBuilder
26 
27 @Generated(value = ["androidx.room.RoomProcessor"])
28 @Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
29 public class MyDao_Impl(
30   __db: RoomDatabase,
31 ) : MyDao {
32   private val __db: RoomDatabase
33   init {
34     this.__db = __db
35   }
36 
37   public override fun getSongsWithArtist(): DataSource.Factory<Int, SongWithArtist> {
38     val _sql: String = "SELECT * FROM Song"
39     val _statement: RoomSQLiteQuery = acquire(_sql, 0)
40     return object : DataSource.Factory<Int, SongWithArtist>() {
41       public override fun create(): LimitOffsetDataSource<SongWithArtist> {
42         val _connection: SQLiteConnection = toSQLiteConnection(__db.openHelper.writableDatabase)
43         return object : LimitOffsetDataSource<SongWithArtist>(__db, _statement, false, true, "Artist", "Song") {
44           protected override fun convertRows(statement: SQLiteStatement): List<SongWithArtist> {
45             val _columnIndexOfSongId: Int = getColumnIndexOrThrow(statement, "songId")
46             val _columnIndexOfArtistKey: Int = getColumnIndexOrThrow(statement, "artistKey")
47             val _collectionArtist: MutableMap<Long, Artist?> = mutableMapOf()
48             while (statement.step()) {
49               val _tmpKey: Long
50               _tmpKey = statement.getLong(_columnIndexOfArtistKey)
51               _collectionArtist.put(_tmpKey, null)
52             }
53             statement.reset()
54             __fetchRelationshipArtistAsArtist(_connection, _collectionArtist)
55             val _res: MutableList<SongWithArtist> = mutableListOf()
56             while (statement.step()) {
57               val _item: SongWithArtist
58               val _tmpSong: Song
59               val _tmpSongId: Long
60               _tmpSongId = statement.getLong(_columnIndexOfSongId)
61               val _tmpArtistKey: Long
62               _tmpArtistKey = statement.getLong(_columnIndexOfArtistKey)
63               _tmpSong = Song(_tmpSongId,_tmpArtistKey)
64               val _tmpArtist: Artist?
65               val _tmpKey_1: Long
66               _tmpKey_1 = statement.getLong(_columnIndexOfArtistKey)
67               _tmpArtist = _collectionArtist.get(_tmpKey_1)
68               if (_tmpArtist == null) {
69                 error("Relationship item 'artist' was expected to be NON-NULL but is NULL in @Relation involving a parent column named 'artistKey' and entityColumn named 'artistId'.")
70               }
71               _item = SongWithArtist(_tmpSong,_tmpArtist)
72               _res.add(_item)
73             }
74             return _res
75           }
76         }
77       }
78     }
79   }
80 
81   public override fun getArtistAndSongs(): DataSource.Factory<Int, ArtistAndSongs> {
82     val _sql: String = "SELECT * FROM Artist"
83     val _statement: RoomSQLiteQuery = acquire(_sql, 0)
84     return object : DataSource.Factory<Int, ArtistAndSongs>() {
85       public override fun create(): LimitOffsetDataSource<ArtistAndSongs> {
86         val _connection: SQLiteConnection = toSQLiteConnection(__db.openHelper.writableDatabase)
87         return object : LimitOffsetDataSource<ArtistAndSongs>(__db, _statement, false, true, "Song", "Artist") {
88           protected override fun convertRows(statement: SQLiteStatement): List<ArtistAndSongs> {
89             val _columnIndexOfArtistId: Int = getColumnIndexOrThrow(statement, "artistId")
90             val _collectionSongs: MutableMap<Long, MutableList<Song>> = mutableMapOf()
91             while (statement.step()) {
92               val _tmpKey: Long
93               _tmpKey = statement.getLong(_columnIndexOfArtistId)
94               if (!_collectionSongs.containsKey(_tmpKey)) {
95                 _collectionSongs.put(_tmpKey, mutableListOf())
96               }
97             }
98             statement.reset()
99             __fetchRelationshipSongAsSong(_connection, _collectionSongs)
100             val _res: MutableList<ArtistAndSongs> = mutableListOf()
101             while (statement.step()) {
102               val _item: ArtistAndSongs
103               val _tmpArtist: Artist
104               val _tmpArtistId: Long
105               _tmpArtistId = statement.getLong(_columnIndexOfArtistId)
106               _tmpArtist = Artist(_tmpArtistId)
107               val _tmpSongsCollection: MutableList<Song>
108               val _tmpKey_1: Long
109               _tmpKey_1 = statement.getLong(_columnIndexOfArtistId)
110               _tmpSongsCollection = _collectionSongs.getValue(_tmpKey_1)
111               _item = ArtistAndSongs(_tmpArtist,_tmpSongsCollection)
112               _res.add(_item)
113             }
114             return _res
115           }
116         }
117       }
118     }
119   }
120 
121   public override fun getPlaylistAndSongs(): DataSource.Factory<Int, PlaylistAndSongs> {
122     val _sql: String = "SELECT * FROM Playlist"
123     val _statement: RoomSQLiteQuery = acquire(_sql, 0)
124     return object : DataSource.Factory<Int, PlaylistAndSongs>() {
125       public override fun create(): LimitOffsetDataSource<PlaylistAndSongs> {
126         val _connection: SQLiteConnection = toSQLiteConnection(__db.openHelper.writableDatabase)
127         return object : LimitOffsetDataSource<PlaylistAndSongs>(__db, _statement, false, true, "PlaylistSongXRef", "Song", "Playlist") {
128           protected override fun convertRows(statement: SQLiteStatement): List<PlaylistAndSongs> {
129             val _columnIndexOfPlaylistId: Int = getColumnIndexOrThrow(statement, "playlistId")
130             val _collectionSongs: MutableMap<Long, MutableList<Song>> = mutableMapOf()
131             while (statement.step()) {
132               val _tmpKey: Long
133               _tmpKey = statement.getLong(_columnIndexOfPlaylistId)
134               if (!_collectionSongs.containsKey(_tmpKey)) {
135                 _collectionSongs.put(_tmpKey, mutableListOf())
136               }
137             }
138             statement.reset()
139             __fetchRelationshipSongAsSong_1(_connection, _collectionSongs)
140             val _res: MutableList<PlaylistAndSongs> = mutableListOf()
141             while (statement.step()) {
142               val _item: PlaylistAndSongs
143               val _tmpPlaylist: Playlist
144               val _tmpPlaylistId: Long
145               _tmpPlaylistId = statement.getLong(_columnIndexOfPlaylistId)
146               _tmpPlaylist = Playlist(_tmpPlaylistId)
147               val _tmpSongsCollection: MutableList<Song>
148               val _tmpKey_1: Long
149               _tmpKey_1 = statement.getLong(_columnIndexOfPlaylistId)
150               _tmpSongsCollection = _collectionSongs.getValue(_tmpKey_1)
151               _item = PlaylistAndSongs(_tmpPlaylist,_tmpSongsCollection)
152               _res.add(_item)
153             }
154             return _res
155           }
156         }
157       }
158     }
159   }
160 
161   private fun __fetchRelationshipArtistAsArtist(_connection: SQLiteConnection, _map: MutableMap<Long, Artist?>) {
162     val __mapKeySet: Set<Long> = _map.keys
163     if (__mapKeySet.isEmpty()) {
164       return
165     }
166     if (_map.size > 999) {
167       recursiveFetchMap(_map, false) { _tmpMap ->
168         __fetchRelationshipArtistAsArtist(_connection, _tmpMap)
169       }
170       return
171     }
172     val _stringBuilder: StringBuilder = StringBuilder()
173     _stringBuilder.append("SELECT `artistId` FROM `Artist` WHERE `artistId` IN (")
174     val _inputSize: Int = __mapKeySet.size
175     appendPlaceholders(_stringBuilder, _inputSize)
176     _stringBuilder.append(")")
177     val _sql: String = _stringBuilder.toString()
178     val _stmt: SQLiteStatement = _connection.prepare(_sql)
179     var _argIndex: Int = 1
180     for (_item: Long in __mapKeySet) {
181       _stmt.bindLong(_argIndex, _item)
182       _argIndex++
183     }
184     try {
185       val _itemKeyIndex: Int = getColumnIndex(_stmt, "artistId")
186       if (_itemKeyIndex == -1) {
187         return
188       }
189       val _columnIndexOfArtistId: Int = 0
190       while (_stmt.step()) {
191         val _tmpKey: Long
192         _tmpKey = _stmt.getLong(_itemKeyIndex)
193         if (_map.containsKey(_tmpKey)) {
194           val _item_1: Artist
195           val _tmpArtistId: Long
196           _tmpArtistId = _stmt.getLong(_columnIndexOfArtistId)
197           _item_1 = Artist(_tmpArtistId)
198           _map.put(_tmpKey, _item_1)
199         }
200       }
201     } finally {
202       _stmt.close()
203     }
204   }
205 
206   private fun __fetchRelationshipSongAsSong(_connection: SQLiteConnection, _map: MutableMap<Long, MutableList<Song>>) {
207     val __mapKeySet: Set<Long> = _map.keys
208     if (__mapKeySet.isEmpty()) {
209       return
210     }
211     if (_map.size > 999) {
212       recursiveFetchMap(_map, true) { _tmpMap ->
213         __fetchRelationshipSongAsSong(_connection, _tmpMap)
214       }
215       return
216     }
217     val _stringBuilder: StringBuilder = StringBuilder()
218     _stringBuilder.append("SELECT `songId`,`artistKey` FROM `Song` WHERE `artistKey` IN (")
219     val _inputSize: Int = __mapKeySet.size
220     appendPlaceholders(_stringBuilder, _inputSize)
221     _stringBuilder.append(")")
222     val _sql: String = _stringBuilder.toString()
223     val _stmt: SQLiteStatement = _connection.prepare(_sql)
224     var _argIndex: Int = 1
225     for (_item: Long in __mapKeySet) {
226       _stmt.bindLong(_argIndex, _item)
227       _argIndex++
228     }
229     try {
230       val _itemKeyIndex: Int = getColumnIndex(_stmt, "artistKey")
231       if (_itemKeyIndex == -1) {
232         return
233       }
234       val _columnIndexOfSongId: Int = 0
235       val _columnIndexOfArtistKey: Int = 1
236       while (_stmt.step()) {
237         val _tmpKey: Long
238         _tmpKey = _stmt.getLong(_itemKeyIndex)
239         val _tmpRelation: MutableList<Song>? = _map.get(_tmpKey)
240         if (_tmpRelation != null) {
241           val _item_1: Song
242           val _tmpSongId: Long
243           _tmpSongId = _stmt.getLong(_columnIndexOfSongId)
244           val _tmpArtistKey: Long
245           _tmpArtistKey = _stmt.getLong(_columnIndexOfArtistKey)
246           _item_1 = Song(_tmpSongId,_tmpArtistKey)
247           _tmpRelation.add(_item_1)
248         }
249       }
250     } finally {
251       _stmt.close()
252     }
253   }
254 
255   private fun __fetchRelationshipSongAsSong_1(_connection: SQLiteConnection, _map: MutableMap<Long, MutableList<Song>>) {
256     val __mapKeySet: Set<Long> = _map.keys
257     if (__mapKeySet.isEmpty()) {
258       return
259     }
260     if (_map.size > 999) {
261       recursiveFetchMap(_map, true) { _tmpMap ->
262         __fetchRelationshipSongAsSong_1(_connection, _tmpMap)
263       }
264       return
265     }
266     val _stringBuilder: StringBuilder = StringBuilder()
267     _stringBuilder.append("SELECT `Song`.`songId` AS `songId`,`Song`.`artistKey` AS `artistKey`,_junction.`playlistKey` FROM `PlaylistSongXRef` AS _junction INNER JOIN `Song` ON (_junction.`songKey` = `Song`.`songId`) WHERE _junction.`playlistKey` IN (")
268     val _inputSize: Int = __mapKeySet.size
269     appendPlaceholders(_stringBuilder, _inputSize)
270     _stringBuilder.append(")")
271     val _sql: String = _stringBuilder.toString()
272     val _stmt: SQLiteStatement = _connection.prepare(_sql)
273     var _argIndex: Int = 1
274     for (_item: Long in __mapKeySet) {
275       _stmt.bindLong(_argIndex, _item)
276       _argIndex++
277     }
278     try {
279       // _junction.playlistKey
280       val _itemKeyIndex: Int = 2
281       if (_itemKeyIndex == -1) {
282         return
283       }
284       val _columnIndexOfSongId: Int = 0
285       val _columnIndexOfArtistKey: Int = 1
286       while (_stmt.step()) {
287         val _tmpKey: Long
288         _tmpKey = _stmt.getLong(_itemKeyIndex)
289         val _tmpRelation: MutableList<Song>? = _map.get(_tmpKey)
290         if (_tmpRelation != null) {
291           val _item_1: Song
292           val _tmpSongId: Long
293           _tmpSongId = _stmt.getLong(_columnIndexOfSongId)
294           val _tmpArtistKey: Long
295           _tmpArtistKey = _stmt.getLong(_columnIndexOfArtistKey)
296           _item_1 = Song(_tmpSongId,_tmpArtistKey)
297           _tmpRelation.add(_item_1)
298         }
299       }
300     } finally {
301       _stmt.close()
302     }
303   }
304 
305   public companion object {
306     public fun getRequiredConverters(): List<KClass<*>> = emptyList()
307   }
308 }
309