VortexReadAt

Trait VortexReadAt 

Source
pub trait VortexReadAt:
    Send
    + Sync
    + 'static {
    // Required methods
    fn read_at(
        &self,
        offset: u64,
        length: usize,
        alignment: Alignment,
    ) -> BoxFuture<'static, VortexResult<ByteBuffer>>;
    fn size(&self) -> BoxFuture<'static, VortexResult<u64>>;

    // Provided method
    fn performance_hint(&self) -> PerformanceHint { ... }
}
Expand description

The read trait used within Vortex.

This trait provides async positional reads to underlying storage and is used by the vortex-file crate to read data from files or object stores.

It behaves a little differently from a typical async read trait in order to provide us with some nice additional semantics for use within Vortex. See the VortexReadAt::read_at method for details.

Required Methods§

Source

fn read_at( &self, offset: u64, length: usize, alignment: Alignment, ) -> BoxFuture<'static, VortexResult<ByteBuffer>>

Request an asynchronous positional read. Results will be returned as a ByteBuffer.

If the reader does not have the requested number of bytes, the returned Future will complete with an UnexpectedEof.

This function returns a future with a 'static lifetime. This allows us to define the following semantics:

This function returns a future with a 'static lifetime, allowing us to define the following semantics:

  • Creation of the future hints to the implementation that a read may be required.
  • Polling of the future indicates that the read is now required.
  • Dropping of the future indicates that the read is not required, and may be cancelled.

Implementations may choose to ignore these semantics, but they allow optimizations such as coalescing and cancellation. See crate::file::FileRead for an example of such an implementation.

§For Developers

This trait is left unsealed to provide maximum flexibility for users of the Vortex, however we strongly recommend using the crate::file::FileRead abstraction where possible as we will continue to evolve and optimize its implementation for the best performance across as many filesystems and platforms as possible.

Source

fn size(&self) -> BoxFuture<'static, VortexResult<u64>>

Asynchronously get the number of bytes of the underlying file.

Provided Methods§

Implementations on Foreign Types§

Source§

impl VortexReadAt for ByteBuffer

Source§

fn read_at( &self, offset: u64, length: usize, alignment: Alignment, ) -> BoxFuture<'static, VortexResult<ByteBuffer>>

Source§

fn size(&self) -> BoxFuture<'static, VortexResult<u64>>

Source§

fn performance_hint(&self) -> PerformanceHint

Source§

impl<R: VortexReadAt> VortexReadAt for Arc<R>

Source§

fn read_at( &self, offset: u64, length: usize, alignment: Alignment, ) -> BoxFuture<'static, VortexResult<ByteBuffer>>

Source§

fn size(&self) -> BoxFuture<'static, VortexResult<u64>>

Source§

fn performance_hint(&self) -> PerformanceHint

Implementors§