Fsdb::IO::Writer(3)

NAME
Fsdb::IO::Writer - handle formatting reading from a fsdb file (handle) or queue

  new
    $fsdb = new Fsdb::IO::Writer(-file => $filename);
    $fsdb = new Fsdb::IO::Writer(-header => "#fsdb -F t foo bar",
                                    -fh => $file_handle);
    $fsdb = new Fsdb::IO::Writer(-file => '-',
                                    -fscode => 'S',
                                    -cols => [qw(firstcol second)]);

Creates a new writer object. Always succeeds, but check the "error" method to test for failure.

Options:

other options See also the options in Fsdb::IO, including "-file", "-header".
-file FILENAME Open and write the given filename. Special filename "-" is standard output, and files with hdfs: are written to Hadoop.
-outputheader [now|delay|never|&format_sub]
    If value is "now" (the default), the header is generated after option parsing. If "delay", it is generated on first data record output. If "never", no header is ever output, and output will then not be fsdb format. If it is a perl subroutine, then the format_sub() is called to generate the header on the first data record output (like delay); it should return the string for the header.

  config_one
documented in new

  _enable_compression
    $self->_enable_compression

internal use only: switch from uncompressed to compressed.

  create_io_subs
    $self->create_io_subs($with_compression)

internal use only: create a thunk that writes rowobjs.

  write_headerrow
internal use only; write the header.

As a side-effect, we also instantiate the _write_io_sub.

  write_rowobj
    $fsdb->write_rowobj($rowobj);

Write a "row object" to an outpu stream. Row objects are either a scalar string, for a comment or header, or an array reference for a row. This routine is the fastest way to do full-featured fsdb-formatted IO. (Although see also Fsdb::Writer::fastpath_sub.)

  write_row_from_aref
    $fsdb->write_row_from_aref(\@a);

Write @a.

  write_row
    $fsdb->write_row($a1, $a2...);

Write args out. Less efficient than write_row_from_aref.

  write_row_from_href
    $fsdb->write_row_from_href(\%h);

Write out %h, a hash of the row fields where each key is a field name.

  fastpath_ok
    $fsdb->fastpath_ok();

Check if we can do fast-path IO (header written, no errors).

  fastpath_sub
    $fsdb->fastpath_sub()

Return an anonymous sub that does fast-path rowobj writes when called.

  close
    $fsdb->close;

Close the file and kill the saved writer sub.

  write_comment
    $fsdb->write_comment($c);

Write out $c as a comment. ($c should be just the text, without a "# " header or a newline trailer.

  write_raw
    $fsdb->write_raw($c);

Write out $c as raw output, typically because it's a comment that already has a "#" in front and a newline at the rear.

  format_fsdb_fields
    format_fsdb_fields(\%data, \@fields)

Returns a string representing double-space-separated, formatted version of the hash'ed fields stored in %data, listed in @fields. (This routine is a hack, there needs to be a FsdbWriter to do this properly, but there isn't currently.