Learn R Programming

RStorm (version 1.0)

ChangeSpout: Function to change the Spout of a Topology

Description

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.

Usage

ChangeSpout(topology, spout)

Arguments

topology

a RStorm Topology object.

spout

a new spout. E.g., a new codedata.frame.

Value

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 Bolt

finailze

the finalize function to be used for the stream

Warning

Functions used as bolt in a stream should always use the dots argument (...) to facilitate the internal working of RStorm.

Additional Info

The is.Bolt function checks whether an object is of Type Bolt and is used internally.

See Also

See Also: Topology, AddBolt, RStorm

Examples

Run this code
# NOT RUN {
# 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))

# }

Run the code above in your browser using DataLab