Description Usage Arguments Value Warning Additional Info Author(s) See Also Examples
The ChangeSpout
function is used to change the spout of an topology that was already defined. It can be used (e.g) for the simulation of a data stream process on multiple data-sets.
1 | ChangeSpout(topology, spout)
|
topology |
a RStorm Topology object. |
spout |
a new spout. E.g., a new codedata.frame. |
An object of class Topology
which is a list containing the following elements:
spout |
the data.frame passed as a spout |
bolts |
a list of bolts, see |
finailze |
the finalize function to be used for the stream |
Functions used as bolt in a stream should always use the dots argument (...) to facilitate the internal working of RStorm
.
The is.Bolt
function checks whether an object is of Type Bolt and is used internally.
Maurits Kaptein
See Also: Topology
, AddBolt
, RStorm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # create a data set.
x <- seq(1, 100)
topology <- Topology(data.frame(x=x))
# Setup a simple topology to compute a sum
computeSum <- function(x, ...){
sum <- GetHash("sum")
if(is.data.frame(sum)){
x <- sum + (x[1])
}
SetHash("sum", x)
}
# Run the stream
topology <- AddBolt(topology, Bolt(computeSum))
result <- RStorm(topology)
print(GetHash("sum", result))
# Create an alternative dataset
x2 <- seq(2, 100)
# Change the dataset in the existing topology
topology <- ChangeSpout(topology, data.frame(x=x2))
# Run the new dataset
result <- RStorm(topology)
print(GetHash("sum", result))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.