Learn R Programming

RStorm (version 1.0)

Tuple: Function to create an object of type Tuple to emit down a stream.

Description

A Tuple is the main data object that is passed around in a stream. The spout emits Tuples to the different Bolts, and Bolts can Emit Tuples to one another depending on the Topology. The Emit function checks whether indeed objects of type Tuple are emitted. A Tuple object is a single row data.frame.

Usage

Tuple(x, ...)

Arguments

x

a single row data.frame

any other argument

Value

an object of type Tuple to be used by an RStorm emitter function

Additional Info

The is.Tuple function checks whether an object is of Type Tuple and is used internally.

See Also

Emit, Topology, RStorm

Examples

Run this code
# NOT RUN {
# Example of a simple object emitted down a stream
spout <- data.frame(x=seq(1,4))
topology <- Topology(spout)

# The Emit function will check if the emitted object is indeed a Tuple
bolt.1 <- function(x, ...){
		Emit(Tuple(x), ...)
	}
	
bolt.2 <- function(x, ...){
	x <- as.numeric(x[1])
	print(x^2)
	}
	
topology <- AddBolt(topology, Bolt(bolt.1, listen=0))
topology <- AddBolt(topology, Bolt(bolt.1, listen=1))
topology <- AddBolt(topology, Bolt(bolt.2, listen=2))

result <- RStorm(topology)
#plot(topology)

# }

Run the code above in your browser using DataLab