Class: ADBC::Statement
- Inherits:
-
Object
- Object
- ADBC::Statement
- Extended by:
- StatementOpenable
- Includes:
- StatementOperations
- Defined in:
- lib/adbc/statement.rb
Instance Method Summary collapse
Methods included from StatementOpenable
Methods included from StatementOperations
Instance Method Details
#bind(*args) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/adbc/statement.rb', line 54 def bind(*args) n_args = args.size if block_given? = "wrong number of arguments (given #{n_args}, expected 1 with block)" raise ArgumentError, unless n_args == 1 values = args[0] if values.is_a?(Arrow::Table) values = Arrow::TableBatchReader.new(values) end if values.is_a?(Arrow::RecordBatchReader) c_abi_array_stream = values.export begin bind_stream(c_abi_array_stream) yield ensure GLib.free(c_abi_array_stream) end else _, c_abi_array, c_abi_schema = values.export begin bind_raw(c_abi_array, c_abi_schema) yield ensure begin GLib.free(c_abi_array) ensure GLib.free(c_abi_schema) end end end else bind_raw(*args) end end |
#bind_raw ⇒ Object
53 |
# File 'lib/adbc/statement.rb', line 53 alias_method :bind_raw, :bind |
#execute(need_result: true) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/adbc/statement.rb', line 27 def execute(need_result: true) _, c_abi_array_stream, n_rows_affected = execute_raw(need_result) if need_result begin reader = Arrow::RecordBatchReader.import(c_abi_array_stream) begin if block_given? yield(reader, n_rows_affected) else [reader.read_all, n_rows_affected] end ensure reader.unref end ensure GLib.free(c_abi_array_stream) end else if block_given? yield(n_rows_affected) else n_rows_affected end end end |
#execute_raw ⇒ Object
26 |
# File 'lib/adbc/statement.rb', line 26 alias_method :execute_raw, :execute |