Bytesrw adapter for Eio
ocaml codec
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use pread for pack file access instead of loading into memory

Pack files are now opened with Eio.Path.open_in and read via
Bytesrw_eio.pread_reader, which uses kernel pread for random access.
This avoids loading potentially large pack files entirely into memory.

+9 -9
+9 -9
src/bytesrw_eio.ml
··· 33 33 in 34 34 Bytes.Reader.make ~slice_length read 35 35 36 - (** Create a [Bytes.Writer.t] from an Eio sink flow. 37 - 38 - Writes directly to the flow without intermediate buffering. 39 - 40 - @param slice_length 41 - Suggested slice length for upstream (default: 65536, which is 42 - {!Bytes.Slice.unix_io_buffer_size}) *) 43 36 (** Create a [Bytes.Reader.t] from an Eio file at [offset]. 44 37 45 38 Uses pread for random-access reading without loading the whole file. 46 39 47 40 @param slice_length Maximum bytes per slice (default: 65536). 48 41 @param length Number of bytes to read (default: to end of file). *) 49 - let pread_reader ?(slice_length = Bytes.Slice.unix_io_buffer_size) 50 - ?length ~offset (file : _ Eio.File.ro) : Bytes.Reader.t = 42 + let pread_reader ?(slice_length = Bytes.Slice.unix_io_buffer_size) ?length 43 + ~offset (file : _ Eio.File.ro) : Bytes.Reader.t = 51 44 let stat = Eio.File.stat file in 52 45 let file_length = Optint.Int63.to_int stat.size in 53 46 let total = match length with Some n -> n | None -> file_length - offset in ··· 68 61 in 69 62 Bytes.Reader.make ~slice_length read 70 63 64 + (** Create a [Bytes.Writer.t] from an Eio sink flow. 65 + 66 + Writes directly to the flow without intermediate buffering. 67 + 68 + @param slice_length 69 + Suggested slice length for upstream (default: 65536, which is 70 + {!Bytes.Slice.unix_io_buffer_size}) *) 71 71 let bytes_writer_of_flow ?(slice_length = Bytes.Slice.unix_io_buffer_size) 72 72 (flow : _ Eio.Flow.sink) : Bytes.Writer.t = 73 73 let rec write slice =