Learn R Programming

RStorm (version 1.0)

TrackRow: Function to store the value of some object in the stream over time.

Description

Within bolts in a RStorm stream the TrackRow function can be used to store the state of variables at that point during the stream. The TrackRow function will store values incrementally during the stream. Thus, TrackRow enables one to store a set of parameter at each event in a Bolt.

Usage

TrackRow(name, row)

Arguments

name

a string with the name of the object that is stored.

row

a single row data.frame containing the parameters that are supposed to be tracked over time. See example.

Value

TRUE if the row is correctly stored.

See Also

Topology, GetTrack, GetTrackNames

Examples

Run this code
# NOT RUN {
# Create a topology with a simple spout
topology <- Topology(data.frame(x=c(1:10)))

# Define the bolt and add it 
computeSum <- function(x, ...){
	sum <- GetHash("sum")
	if(is.data.frame(sum)){
		x <- sum + (x[1])
	}
	SetHash("sum", x)
	TrackRow("sum", data.frame(x=x))
}
topology <- AddBolt(topology, Bolt(computeSum))

# Run the stream
result <- RStorm(topology)

# Insepct the result over the timepoints in the stream
GetTrack("sum", result)

# }

Run the code above in your browser using DataLab