| DSlib documentation | Contained in the DSlib distribution. |
DS::Importer - component that retrieves data from outside DS and passes it down a processing chain.
This is the base class of any component that is supposed to retrieve data from outside a processing chain and pass it on as rows. The name refers to a component that imports data into a chain.
Will call fetch pass the results on by calling pass_row with the result,
stopping after fetching $num_rows or passing on end of stream (whichever
comes first).
This method is supposed to retrieve a row from the underlying data source and return it. Must return undef to indicate end of stream. Multiple calls after end of stream should still result in returning undef.
Constructor. Instantiates an object of class $class, returning the type
$out_type, attaced to the target $target. Besides $class,
any of the parameters can be left out.
Methods inherited from DS::Source:
Written by Michael Zedeler.
| DSlib documentation | Contained in the DSlib distribution. |
#!perl # ########################################################################## # # Title: Data stream importer # Creation date: 2007-03-05 # Author: Michael Zedeler # Description: Generates data stream data # Data Stream class # File: $Source: /data/cvs/lib/DSlib/lib/DS/Importer.pm,v $ # Repository: kronhjorten # State: $State: Exp $ # Documentation: inline # Recepient: - # #TODO Importers should not by default be constructed with an explicit typespec, since this may be derived from the data source # ########################################################################## # package DS::Importer; use base qw{ DS::Source }; use strict; use Carp qw{ croak cluck }; require Carp::Assert; our ($VERSION) = $DS::VERSION; our ($REVISION) = '$Revision: 1.2 $' =~ /(\d+\.\d+)/; #TODO Add $row to to constructor # This method fetches sub execute { my( $self, $rows ) = @_; $rows = -1 unless $rows; while( $rows-- != 0 ) { my $result = $self->_fetch(); $self->pass_row( $result ); # Exit if we just passed end of stream. last if not defined( $result ); } } # Fetches one row from underlying data source and returns it to caller. # When end of data source has been reached, this method MUST return undef on # all subsequent calls. # Note that this method doesn't pass anything on to any attached # target. # When writing importers, this is the method you will want to override. # This method is private. sub _fetch { croak("This method must be overridden."); } 1; __END__