Data::Stream::Bulk(3pm) | User Contributed Perl Documentation | Data::Stream::Bulk(3pm) |
Data::Stream::Bulk - N at a time iteration API
version 0.11
# get a bulk stream from somewere my $s = Data::Stream::Bulk::Foo->new( ... ); # can be used like this: until ( $s->is_done ) { foreach my $item ( $s->items ) { process($item); } } # or like this: while( my $block = $s->next ) { foreach my $item ( @$block ) { process($item); } }
This module tries to find middle ground between one at a time and all at once processing of data sets.
The purpose of this module is to avoid the overhead of implementing an iterative api when this isn't necessary, without breaking forward compatibility in case that becomes necessary later on.
The API optimizes for when a data set typically fits in memory and is returned as an array, but the consumer cannot assume that the data set is bounded.
The API is destructive in order to minimize the chance that resultsets are leaked due to improper usage.
The API requires two methods to be implemented:
As long as this method returns a false value (not done) "next" could potentially return another block.
Note that "next" is not guaranteed to return an array reference, even if "is_done" returned false prior to calling it.
Note that for large data sets this might cause swap thrashing of various other undesired effects. Use with caution.
Used by "cat".
Overridden by Data::Stream::Bulk::Array, Data::Stream::Bulk::Cat and Data::Stream::Bulk::Nil to implement some simple short circuiting.
Returns a possibly new stream with the filtering layered.
$filter is invoked once per block and should return an array reference to the filtered block.
Returns false by default.
When true calling "all" is supposed to be safe (memory usage should be in the same order of magnitude as stream's own usage).
This is typically useful when tranforming an array is easier than transorming a stream (e.g. optional duplicate filtering).
HOP::Stream, Iterator, Class::Iterator etc for one by one iteration
DBI, DBIx::Class::ResultSet
POE::Filter
Data::Page
Parallel::Iterator
<http://en.wikipedia.org/wiki/MapReduce>, LISP, and all that other kool aid
Introduce a "merge" operation for merging of sorted streams.
Optimize "unique" to make use of sorting hints for constant space uniquing.
This module is maintained using git. You can get the latest version from <http://github.com/nothingmuch/data-stream-bulk/>.
Yuval Kogman <nothingmuch@woobling.org>
This software is copyright (c) 2012 by Yuval Kogman.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2021-01-01 | perl v5.32.0 |