• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16565510329

28 Jul 2025 09:34AM UTC coverage: 81.812% (+0.02%) from 81.789%
16565510329

Pull #4019

github

web-flow
Merge 0c114cac4 into 3d13d2ec0
Pull Request #4019: Refactor read I/O

389 of 429 new or added lines in 17 files covered. (90.68%)

68 existing lines in 5 files now uncovered.

43096 of 52677 relevant lines covered (81.81%)

171076.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/vortex-io/src/std.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
// Currently, our support for std I/O depends on Tokio.
5
// We should provide alternative implementations for other runtimes in the future.
6
#![cfg(feature = "tokio")]
7

8
use std::os::unix::prelude::FileExt;
9
use std::sync::Arc;
10

11
use vortex_buffer::{Alignment, ByteBuffer, ByteBufferMut};
12
use vortex_error::{ResultExt, VortexResult, vortex_err};
13

14
use crate::tokio::{TokioDispatchedIo, TokioReadAt};
15
use crate::{PerformanceHint, ReadAt, VortexIO};
16

17
/// Opens a `std::fs::File` as a Vortex I/O object.
18
///
19
/// Currently, std I/O internally dispatches blocking I/O tasks onto a Tokio runtime.
20
impl VortexIO for std::fs::File {
NEW
21
    fn performance_hint(&self) -> PerformanceHint {
×
NEW
22
        PerformanceHint::local()
×
NEW
23
    }
×
24

25
    fn into_read_at(self) -> VortexResult<Arc<dyn ReadAt>> {
1,108✔
26
        Ok(Arc::new(TokioDispatchedIo::new(Arc::new(self))))
1,108✔
27
    }
1,108✔
28
}
29

30
impl VortexIO for &std::path::Path {
31
    fn performance_hint(&self) -> PerformanceHint {
458✔
32
        PerformanceHint::local()
458✔
33
    }
458✔
34

35
    fn into_read_at(self) -> VortexResult<Arc<dyn ReadAt>> {
458✔
36
        std::fs::File::open(self)
458✔
37
            .map_err(|e| vortex_err!("Failed to open file {e}"))?
458✔
38
            .into_read_at()
458✔
39
    }
458✔
40
}
41

42
impl TokioReadAt for Arc<std::fs::File> {
43
    async fn read_at(
2,324✔
44
        &self,
2,324✔
45
        offset: u64,
2,324✔
46
        len: usize,
2,324✔
47
        alignment: Alignment,
2,324✔
48
    ) -> VortexResult<ByteBuffer> {
2,324✔
49
        let this = self.clone();
2,324✔
50

51
        tokio::task::spawn_blocking(move || {
2,324✔
52
            let mut buffer = ByteBufferMut::with_capacity_aligned(len, alignment);
2,324✔
53
            unsafe { buffer.set_len(len) };
2,324✔
54
            this.read_exact_at(&mut buffer, offset)?;
2,324✔
55
            Ok(buffer.freeze())
2,324✔
56
        })
2,324✔
57
        .await
2,324✔
58
        .map_err(|e| vortex_err!("Failed to spawn blocking task: {e}"))
2,324✔
59
        .unnest()
2,324✔
60
    }
2,324✔
61

62
    async fn size(&self) -> VortexResult<u64> {
458✔
63
        let this = self.clone();
458✔
64

65
        tokio::task::spawn_blocking(move || {
458✔
66
            Ok(this
458✔
67
                .metadata()
458✔
68
                .map_err(|e| vortex_err!("Failed to get file metadata: {e}"))?
458✔
69
                .len())
458✔
70
        })
458✔
71
        .await
458✔
72
        .map_err(|e| vortex_err!("Failed to spawn blocking task: {e}"))
458✔
73
        .unnest()
458✔
74
    }
458✔
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc