diff --git a/GRDB Tests/Performance/FetchPerformanceTests.swift b/GRDB Tests/Performance/FetchPerformanceTests.swift index 80e29ca9b..3f957113f 100644 --- a/GRDB Tests/Performance/FetchPerformanceTests.swift +++ b/GRDB Tests/Performance/FetchPerformanceTests.swift @@ -18,27 +18,7 @@ class FetchPerformanceTests: XCTestCase { // // } - func testMetalRowFetchPerformance() { - let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")! - let dbQueue = try! DatabaseQueue(path: databasePath) - - var sum: Int64 = 0 - self.measureBlock { - dbQueue.inDatabase { db in - for row in MetalRow.fetch(db, "SELECT * FROM items") { - let i0: Int64 = row.value(atIndex: 0) - let i1: Int64 = row.value(atIndex: 1) - let i2: Int64 = row.value(atIndex: 2) - let i3: Int64 = row.value(atIndex: 3) - let i4: Int64 = row.value(atIndex: 4) - sum += i0 + i1 + i2 + i3 + i4 - } - } - } - XCTAssertEqual(sum, 4999990) - } - - func testRowMetalFetchPerformance() { + func testMetalFetchPerformance() { let databasePath = NSBundle(forClass: self.dynamicType).pathForResource("FetchPerformanceTests", ofType: "sqlite")! let dbQueue = try! DatabaseQueue(path: databasePath) diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 2d316e787..0f663f9da 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -343,8 +343,6 @@ public struct Row: CollectionType { The returned generator is *unsafe* because it must be used with extra care, and GRDB.swift will not prevent invalid usage. - - It MUST be generated and iterated in the database queue. - - It MUST be iterated right away. Do not reserve it, do not wrap it in an Array. @@ -598,74 +596,3 @@ public struct RowIndex: ForwardIndexType, BidirectionalIndexType, RandomAccessIn public func ==(lhs: RowIndex, rhs: RowIndex) -> Bool { return lhs.index == rhs.index } - - -// MARK: - MetalRow - -public struct MetalRow { - let sqliteStatement: SQLiteStatement - - init(sqliteStatement: SQLiteStatement) { - self.sqliteStatement = sqliteStatement - } - - - // MARK: - Fetching From Database - - /** - Returns a row generator that provides fast but unsafe access to database - values: - - for row in MetalRow.fetch(db, "SELECT id, name FROM persons") { - let id = row.int64(atIndex: 0) - let name = row.string(atIndex: 1) - } - - The returned generator is *unsafe* because it must be used with extra care, - and GRDB.swift will not prevent invalid usage. - - - It MUST be generated and iterated in the database queue. - - - It MUST be iterated right away. Do not reserve it, do not wrap it in an - Array. - - Granted with those constraints, the unsafe generator grants extra speed for - the typed row accessors Row.int64(atIndex:), Row.string(atIndex:), etc. - - - parameter db: A Database. - - parameter sql: An SQL query. - - parameter arguments: Optional statement arguments. - - returns: A lazy sequence of rows. - */ - public static func fetch(db: Database, _ sql: String, arguments: StatementArguments? = nil) -> AnyGenerator { - let statement = db.selectStatement(sql) - return statement.metalGenerate(arguments: arguments) { - MetalRow(sqliteStatement: statement.sqliteStatement) - } - } - - // MARK: - Metal Row Values - - public func value(atIndex index: Int) -> Value? { - return Value.fromDatabaseValue(databaseValue(atIndex: index)) - } - - public func value>(atIndex index: Int) -> Value? { - if sqlite3_column_type(sqliteStatement, Int32(index)) == SQLITE_NULL { - return nil - } - return Value(sqliteStatement: sqliteStatement, index: Int32(index)) - } - - public func value(atIndex index: Int) -> Value { - return Value.fromDatabaseValue(databaseValue(atIndex: index))! - } - - public func value>(atIndex index: Int) -> Value { - return Value(sqliteStatement: sqliteStatement, index: Int32(index)) - } - - func databaseValue(atIndex index: Int) -> DatabaseValue { - return DatabaseValue(sqliteStatement: sqliteStatement, index: index) - } -}