Description Usage Arguments Value Author(s) See Also Examples
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.
1 |
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. |
a dataframe containing whatever was set using the SetHash function.
Maurits Kaptein
See Also: SetHash
, GetHashList
, GetHashNames
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.