Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 1 | import android.database.Cursor |
| 2 | import androidx.room.RoomDatabase |
| 3 | import androidx.room.RoomSQLiteQuery |
| 4 | import androidx.room.RoomSQLiteQuery.Companion.acquire |
| 5 | import androidx.room.util.appendPlaceholders |
| 6 | import androidx.room.util.getColumnIndex |
| 7 | import androidx.room.util.getColumnIndexOrThrow |
| 8 | import androidx.room.util.newStringBuilder |
| 9 | import androidx.room.util.query |
| 10 | import androidx.room.util.recursiveFetchHashMap |
| 11 | import java.lang.Class |
| 12 | import java.lang.StringBuilder |
| 13 | import java.nio.ByteBuffer |
| 14 | import java.util.HashMap |
| 15 | import javax.`annotation`.processing.Generated |
| 16 | import kotlin.ByteArray |
| 17 | import kotlin.Int |
| 18 | import kotlin.Long |
| 19 | import kotlin.String |
| 20 | import kotlin.Suppress |
Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 21 | import kotlin.collections.List |
| 22 | import kotlin.collections.Set |
| 23 | import kotlin.jvm.JvmStatic |
| 24 | |
| 25 | @Generated(value = ["androidx.room.RoomProcessor"]) |
elifbilgin | d46e8c1 | 2023-01-17 09:32:11 -0800 | [diff] [blame] | 26 | @Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION"]) |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 27 | public class MyDao_Impl( |
| 28 | __db: RoomDatabase, |
| 29 | ) : MyDao { |
Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 30 | private val __db: RoomDatabase |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 31 | init { |
Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 32 | 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) { |
elifbilgin | 22935ce | 2023-07-25 14:14:10 -0700 | [diff] [blame^] | 64 | 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 Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 65 | } |
| 66 | _result = SongWithArtist(_tmpSong,_tmpArtist) |
| 67 | } else { |
elifbilgin | 22935ce | 2023-07-25 14:14:10 -0700 | [diff] [blame^] | 68 | error("The query result was empty, but expected a single row to return a NON-NULL object of type <SongWithArtist>.") |
Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 69 | } |
| 70 | return _result |
| 71 | } finally { |
| 72 | _cursor.close() |
| 73 | _statement.release() |
| 74 | } |
| 75 | } |
| 76 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 77 | private fun __fetchRelationshipArtistAsArtist(_map: HashMap<ByteBuffer, Artist?>) { |
Daniel Santiago Rivera | 8aab02df | 2022-11-03 11:12:49 -0400 | [diff] [blame] | 78 | 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 | } |