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