ChangeSpout: Function to change the Spout of a Topology

Description Usage Arguments Value Warning Additional Info Author(s) See Also Examples

View source: R/topology.R

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

1
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.

Author(s)

Maurits Kaptein

See Also

See Also: Topology, AddBolt, RStorm

Examples

 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))

RStorm documentation built on May 2, 2019, 9:14 a.m.

Related to ChangeSpout in RStorm...