/vio

Ruby Vectored I/O

Primary LanguageC

Vectored I/O for Ruby MRI
  (c) 2009 Lourens Naudé (methodmissing) 
 
  http://github.com/methodmissing/vio

Vectored I/O ?

  POSIX 1003.1-2001 introduces reading or writing data into multiple buffers with a single procedure call.See http://en.wikipedia.org/wiki/Vectored_I/O for an overview.

Use cases :

  * Write non-sequentially placed data in memory to disk with a single write operation.This fits very well with custom database/record formats for writing out indexes and data at once.
  * Reducing syscall overheads
  * Reading structured data (protocol dumps,db records) into distinct buffers

Examples :

  8=FIX.4.4�9=45�35=0�49=TW�56=ISLD�34=3�52=20000426-12:05:06�10=220�

  >>io = File.open('/path/to/fix.txt')) 
  => #<File://path/to/fix.txt>
  >>io.read(9, 5, 5, 6, 8, 26, 8) 
  => ["8=FIX.4.4","\x019=45", "\x0135=0", "\x0149=TW", "\x0156=ISLD",
"\x0134=3\x0152=20000426-12:05:06", "\x0110=220\x01"]    

Installation

  sudo gem install methodmissing-vio

Todo :

  * Error handling for rewind + sockets don't support lseek

To run the test suite:

  rake

To run the benchmarks:

  rake bench