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