<commit_before>//
//  Row.swift
//  SwiftChatSE
//
//  Created by NobodyNada on 5/8/17.
//
//

import Foundation

#if os(Linux)
    import CSQLite
#else
    import SQLite3
#endif

open class Row {
	///The columns of this row.
	open let columns: [DatabaseNativeType?]
	
	///A Dictionary mapping the names of this row's columns to their indices in `columns`.
	open let columnNames: [String:Int]
	
	///Initializes a Row with the results of a prepared statement.
	public init(statement: OpaquePointer) {
		var columns = [DatabaseNativeType?]()
		var columnNames = [String:Int]()
		
		for i in 0..<sqlite3_column_count(statement) {
			let value: DatabaseNativeType?
			let type = sqlite3_column_type(statement, i)
			switch type {
			case SQLITE_INTEGER:
				value = sqlite3_column_int64(statement, i)
			case SQLITE_FLOAT:
				value = sqlite3_column_double(statement, i)
			case SQLITE_TEXT:
				value = String(cString: sqlite3_column_text(statement, i))
			case SQLITE_BLOB:
				let bytes = sqlite3_column_bytes(statement, i)
				if bytes == 0 {
					value = Data()
				} else {
					value = Data(bytes: sqlite3_column_blob(statement, i), count: Int(bytes))
				}
			case SQLITE_NULL:
				value = nil
			default:
				fatalError("unrecognized SQLite type \(type)")
			}
			
			columns.append(value)
			columnNames[String(cString: sqlite3_column_name(statement, i))] = Int(i)
		}
		
		self.columns = columns
		self.columnNames = columnNames
	}
	<commit_msg>add an initializer to Row<commit_after>//
//  Row.swift
//  SwiftChatSE
//
//  Created by NobodyNada on 5/8/17.
//
//

import Foundation

#if os(Linux)
    import CSQLite
#else
    import SQLite3
#endif

open class Row {
	///The columns of this row.
	open let columns: [DatabaseNativeType?]
	
	///A Dictionary mapping the names of this row's columns to their indices in `columns`.
	open let columnNames: [String:Int]
	
	///Initializes a Row with the results of a prepared statement.
	public init(statement: OpaquePointer) {
		var columns = [DatabaseNativeType?]()
		var columnNames = [String:Int]()
		
		for i in 0..<sqlite3_column_count(statement) {
			let value: DatabaseNativeType?
			let type = sqlite3_column_type(statement, i)
			switch type {
			case SQLITE_INTEGER:
				value = sqlite3_column_int64(statement, i)
			case SQLITE_FLOAT:
				value = sqlite3_column_double(statement, i)
			case SQLITE_TEXT:
				value = String(cString: sqlite3_column_text(statement, i))
			case SQLITE_BLOB:
				let bytes = sqlite3_column_bytes(statement, i)
				if bytes == 0 {
					value = Data()
				} else {
					value = Data(bytes: sqlite3_column_blob(statement, i), count: Int(bytes))
				}
			case SQLITE_NULL:
				value = nil
			default:
				fatalError("unrecognized SQLite type \(type)")
			}
			
			columns.append(value)
			columnNames[String(cString: sqlite3_column_name(statement, i))] = Int(i)
		}
		
		self.columns = columns
		self.columnNames = columnNames
	}
    
    ///Initializes a Row with the specified columns.
    public init(columns: [DatabaseType?], columnNames: [String:Int]) {
        self.columns = columns
        self.columnNames = columnNames
    }
	
{'fraction_non_alphanumeric': 0.10477411086190323, 'fraction_numerical': 0.010893944248638257, 'mean_word_length': 3.3240997229916895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4012961', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1004, 'n_words': 284}