Learn R Programming

RStorm (version 1.0)

SetHash: Function to store a data.frame during a stream.

Description

Within bolts in used in a RStorm the GetHash and SetHash functions can be used to access a local store (or hashmap) during the stream. This corresponds to the ability of tracking parameters over the stream using a hashmap or database system as implemented in production streaming software.

Usage

SetHash(name, data, ...)

Arguments

name

a string containing the name of the stored object

data

a data.frame (or scalar) to be stored

Value

If storing the value is successful returns TRUE.

See Also

See Also: TrackRow, SetHash, GetHash, GetTrack

Examples

Run this code
# NOT RUN {
topology <- Topology(data.frame(x=rnorm(100,0,1)))
computeSum <- function(x, ...){
	sum <- GetHash("sum")
	if(is.data.frame(sum)){
		x <- sum + (x[1])
	}
	SetHash("sum", x)
}
topology <- AddBolt(topology, Bolt(computeSum))
result <- RStorm(topology)
print(GetHash("sum", result))


# }

Run the code above in your browser using DataLab