blob: 56c0b4e8a62ffa3ef229bdb1f237daeff0947a1b [file] [log] [blame]
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -04001import android.database.Cursor
2import androidx.room.RoomDatabase
3import androidx.room.RoomSQLiteQuery
4import androidx.room.RoomSQLiteQuery.Companion.acquire
5import androidx.room.util.appendPlaceholders
6import androidx.room.util.getColumnIndex
7import androidx.room.util.getColumnIndexOrThrow
8import androidx.room.util.newStringBuilder
9import androidx.room.util.query
10import androidx.room.util.recursiveFetchHashMap
11import java.lang.Class
12import java.lang.StringBuilder
13import java.nio.ByteBuffer
14import java.util.HashMap
15import javax.`annotation`.processing.Generated
16import kotlin.ByteArray
17import kotlin.Int
18import kotlin.Long
19import kotlin.String
20import kotlin.Suppress
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040021import kotlin.collections.List
22import kotlin.collections.Set
23import kotlin.jvm.JvmStatic
24
25@Generated(value = ["androidx.room.RoomProcessor"])
elifbilgind46e8c12023-01-17 09:32:11 -080026@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION"])
Daniel Santiago Riverae695d182022-11-08 21:12:14 -050027public class MyDao_Impl(
28 __db: RoomDatabase,
29) : MyDao {
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040030 private val __db: RoomDatabase
Daniel Santiago Riverae695d182022-11-08 21:12:14 -050031 init {
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040032 this.__db = __db
33 }
34
35 public override fun getSongsWithArtist(): SongWithArtist {
36 val _sql: String = "SELECT * FROM Song"
37 val _statement: RoomSQLiteQuery = acquire(_sql, 0)
38 __db.assertNotSuspendingTransaction()
39 val _cursor: Cursor = query(__db, _statement, true, null)
40 try {
41 val _cursorIndexOfSongId: Int = getColumnIndexOrThrow(_cursor, "songId")
42 val _cursorIndexOfArtistKey: Int = getColumnIndexOrThrow(_cursor, "artistKey")
43 val _collectionArtist: HashMap<ByteBuffer, Artist?> = HashMap<ByteBuffer, Artist?>()
44 while (_cursor.moveToNext()) {
45 val _tmpKey: ByteBuffer
46 _tmpKey = ByteBuffer.wrap(_cursor.getBlob(_cursorIndexOfArtistKey))
47 _collectionArtist.put(_tmpKey, null)
48 }
49 _cursor.moveToPosition(-1)
50 __fetchRelationshipArtistAsArtist(_collectionArtist)
51 val _result: SongWithArtist
52 if (_cursor.moveToFirst()) {
53 val _tmpSong: Song
54 val _tmpSongId: Long
55 _tmpSongId = _cursor.getLong(_cursorIndexOfSongId)
56 val _tmpArtistKey: ByteArray
57 _tmpArtistKey = _cursor.getBlob(_cursorIndexOfArtistKey)
58 _tmpSong = Song(_tmpSongId,_tmpArtistKey)
59 val _tmpArtist: Artist?
60 val _tmpKey_1: ByteBuffer
61 _tmpKey_1 = ByteBuffer.wrap(_cursor.getBlob(_cursorIndexOfArtistKey))
62 _tmpArtist = _collectionArtist.get(_tmpKey_1)
63 if (_tmpArtist == null) {
elifbilgin22935ce2023-07-25 14:14:10 -070064 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'.")
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040065 }
66 _result = SongWithArtist(_tmpSong,_tmpArtist)
67 } else {
elifbilgin22935ce2023-07-25 14:14:10 -070068 error("The query result was empty, but expected a single row to return a NON-NULL object of type <SongWithArtist>.")
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040069 }
70 return _result
71 } finally {
72 _cursor.close()
73 _statement.release()
74 }
75 }
76
Daniel Santiago Riveraa6dec5a2023-05-02 15:09:07 -040077 private fun __fetchRelationshipArtistAsArtist(_map: HashMap<ByteBuffer, Artist?>) {
Daniel Santiago Rivera8aab02df2022-11-03 11:12:49 -040078 val __mapKeySet: Set<ByteBuffer> = _map.keys
79 if (__mapKeySet.isEmpty()) {
80 return
81 }
82 if (_map.size > RoomDatabase.MAX_BIND_PARAMETER_CNT) {
83 recursiveFetchHashMap(_map, false) {
84 __fetchRelationshipArtistAsArtist(it)
85 }
86 return
87 }
88 val _stringBuilder: StringBuilder = newStringBuilder()
89 _stringBuilder.append("SELECT `artistId` FROM `Artist` WHERE `artistId` IN (")
90 val _inputSize: Int = __mapKeySet.size
91 appendPlaceholders(_stringBuilder, _inputSize)
92 _stringBuilder.append(")")
93 val _sql: String = _stringBuilder.toString()
94 val _argCount: Int = 0 + _inputSize
95 val _stmt: RoomSQLiteQuery = acquire(_sql, _argCount)
96 var _argIndex: Int = 1
97 for (_item: ByteBuffer in __mapKeySet) {
98 _stmt.bindBlob(_argIndex, _item.array())
99 _argIndex++
100 }
101 val _cursor: Cursor = query(__db, _stmt, false, null)
102 try {
103 val _itemKeyIndex: Int = getColumnIndex(_cursor, "artistId")
104 if (_itemKeyIndex == -1) {
105 return
106 }
107 val _cursorIndexOfArtistId: Int = 0
108 while (_cursor.moveToNext()) {
109 val _tmpKey: ByteBuffer
110 _tmpKey = ByteBuffer.wrap(_cursor.getBlob(_itemKeyIndex))
111 if (_map.containsKey(_tmpKey)) {
112 val _item_1: Artist
113 val _tmpArtistId: ByteArray
114 _tmpArtistId = _cursor.getBlob(_cursorIndexOfArtistId)
115 _item_1 = Artist(_tmpArtistId)
116 _map.put(_tmpKey, _item_1)
117 }
118 }
119 } finally {
120 _cursor.close()
121 }
122 }
123
124 public companion object {
125 @JvmStatic
126 public fun getRequiredConverters(): List<Class<*>> = emptyList()
127 }
128}