|
1 | 1 | // SPDX-License-Identifier: Apache-2.0 |
2 | 2 | // SPDX-FileCopyrightText: Copyright the Vortex contributors |
3 | 3 |
|
4 | | -use std::sync::LazyLock; |
5 | | - |
6 | 4 | use anyhow::Result; |
7 | 5 | use arrow_array::RecordBatchReader; |
8 | 6 | use arrow_array::ffi_stream::{ArrowArrayStreamReader, FFI_ArrowArrayStream}; |
9 | | -use tokio::runtime::Runtime; |
10 | 7 | use vortex::ArrayRef; |
11 | 8 | use vortex::arrow::FromArrowArray; |
12 | 9 | use vortex::dtype::DType; |
13 | 10 | use vortex::dtype::arrow::FromArrowType; |
14 | | -use vortex::error::{VortexError, VortexExpect}; |
| 11 | +use vortex::error::VortexError; |
15 | 12 | use vortex::file::{VortexWriteOptions as WriteOptions, WriteOptionsSessionExt}; |
16 | 13 | use vortex::io::VortexWrite; |
| 14 | +use vortex::io::runtime::BlockingRuntime; |
17 | 15 | use vortex::iter::{ArrayIteratorAdapter, ArrayIteratorExt}; |
18 | 16 | use vortex::stream::ArrayStream; |
19 | 17 |
|
20 | | -use crate::SESSION; |
21 | | - |
22 | | -/// The tokio runtime for the write-side. |
23 | | -static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| { |
24 | | - Runtime::new() |
25 | | - .map_err(VortexError::from) |
26 | | - .vortex_expect("Failed to create tokio runtime") |
27 | | -}); |
| 18 | +use crate::{RUNTIME, SESSION}; |
28 | 19 |
|
29 | 20 | pub(crate) struct VortexWriteOptions { |
30 | 21 | inner: WriteOptions, |
@@ -67,7 +58,7 @@ pub(crate) unsafe fn write_array_stream( |
67 | 58 | let vortex_stream = arrow_stream_to_vortex_stream(stream_reader)?; |
68 | 59 |
|
69 | 60 | RUNTIME.block_on(async { |
70 | | - let mut file = tokio::fs::File::create(path).await?; |
| 61 | + let mut file = async_fs::File::create(path).await?; |
71 | 62 | options.inner.write(&mut file, vortex_stream).await?; |
72 | 63 | file.shutdown().await?; |
73 | 64 | Ok(()) |
|
0 commit comments