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