(response: hypersync_client::ArrowResponse)
| 14 | }; |
| 15 | |
| 16 | pub fn response_to_pyarrow(response: hypersync_client::ArrowResponse) -> Result<ArrowResponse> { |
| 17 | let data = Python::attach(|py| { |
| 18 | let pyarrow = py.import("pyarrow")?; |
| 19 | Ok::<_, PyErr>(ArrowResponseData { |
| 20 | blocks: convert_batches_to_pyarrow_table(py, &pyarrow, response.data.blocks)?, |
| 21 | transactions: convert_batches_to_pyarrow_table( |
| 22 | py, |
| 23 | &pyarrow, |
| 24 | response.data.transactions, |
| 25 | )?, |
| 26 | logs: convert_batches_to_pyarrow_table(py, &pyarrow, response.data.logs)?, |
| 27 | traces: convert_batches_to_pyarrow_table(py, &pyarrow, response.data.traces)?, |
| 28 | decoded_logs: convert_batches_to_pyarrow_table( |
| 29 | py, |
| 30 | &pyarrow, |
| 31 | response.data.decoded_logs, |
| 32 | )?, |
| 33 | }) |
| 34 | })?; |
| 35 | |
| 36 | Ok(ArrowResponse { |
| 37 | archive_height: response.archive_height, |
| 38 | next_block: response.next_block, |
| 39 | total_execution_time: response.total_execution_time, |
| 40 | data, |
| 41 | rollback_guard: response |
| 42 | .rollback_guard |
| 43 | .map(|rg| RollbackGuard::try_convert(rg).context("convert rollback guard")) |
| 44 | .transpose()?, |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | fn convert_batches_to_pyarrow_table<'py>( |
| 49 | py: Python<'py>, |
no test coverage detected