GetHash: Function to retrieve objects stored locally during the...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hashmap.R

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. The function is overloaded to retrieve the state of the hashmap at the end of a stream from an RStorm result object. See the examples for the two usages.

Usage

1
GetHash(name, object = NULL)

Arguments

name

a string containing the name of the hashmap that is accessed from within the Stream.

object

(optional) the RStorm result object. If used outside of a bolt in a stream the result object needs to be passed in which the end-state of the hashmaps created in the stream are stored.

Value

a dataframe containing whatever was set using the SetHash function.

Author(s)

Maurits Kaptein

See Also

See Also: SetHash, GetHashList, GetHashNames

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Create a topology with a spout:
topology <- Topology(data.frame(x=rnorm(100,0,1)))

# declare a bolt and add it to the topology
computeSum <- function(x, ...){
	sum <- GetHash("sum")  # get from local store
	if(is.data.frame(sum)){
		x <- sum + (x[1])
	}
	SetHash("sum", x)  # add to local store
}
topology <- AddBolt(topology, Bolt(computeSum))

# run the stream
result <- RStorm(topology)

# access the local store
print(GetHash("sum", result))

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

Related to GetHash in RStorm...