Description Usage Arguments Constructors Methods Internal Class Fields and Methods Author(s) See Also Examples
An ordered collection of Consumer and Producer
components combined into a single entity. Applying a method such as
yield to Stream invokes yield on the terminal
Consumer component of the stream, yielding one batch from the
stream. The result of yield is defined by the Producer
and Consumer components of the stream.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
x, X |
For |
FUN |
A function to be applied to each successful |
i, j |
Numeric index of the ith stream element ( |
... |
For |
simplify |
See |
USE.NAMES |
See |
verbose |
A |
Arguments to Stream must consist of a single Producer
and zero or more Consumer components.
When invoked with the Producer as the first argument,
Stream(P, C1, C2) produces a stream in which the data is read
by P, then processed by C1, then processed by C2.
When invoked with the Consumer as the first argument, the
... must include a Producer as the last
argument. Stream(C1, C2, P) produces a stream in which the data
is read by P, then processed by C2, then processed by
C1.
Methods defined on this class include:
The number of components in this stream.
The ith component (including inputs) of this
stream.
Yield a single result (e.g., data.frame) from
the stream.
Reset, if possible, each component of the stream.
Apply FUN to each result applied to
yield(), simplifying (using simplify2array) if
possible for sapply. Partial results on error can be
recovered using tryCatch, as illustrated
on the help page Producer.
Internal fields of this class are are described with, e.g.,
getRefClass("FunctionProducer")$fields.
Internal methods of this class are described with
getRefClass("FunctionProducer")$methods() and
getRefClass("FunctionProducer")$help().
Martin Morgan mtmorgan@fhcrc.org
Streamer-package, Consumer-class,
Producer-class.
1 2 3 4 5 6 7 8 9 10 11 | fl <- system.file("extdata", "s_1_sequence.txt", package="Streamer")
b <- RawInput(fl, 100L, reader=rawReaderFactory(1e4))
s <- Stream(b, Rev(), RawToChar())
s
yield(s)
reset(s)
while (length(yield(s))) cat("tick\n")
close(b)
strm <- Stream(Seq(to=10), FunctionConsumer(function(y) 1/y))
sapply(strm, c)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.