Database Reference
In-Depth Information
PowerBolt()).shuffleGrouping("split");
builder.setBolt("return",
new
ReturnResults()).shuffleGrouping("power");
The
SplitBolt
implementation splits the input comma-separated list into
two
Double
values. It also passes along the
return-info
element of the
tuple, which is used by
ReturnResults
to submit the result back to the
DRPC server:
public class
SplitBolt
extends
BaseBasicBolt {
private static final long
serialVersionUID
=
-3681655596236684743L;
public void
execute(Tuple input,
BasicOutputCollector collector) {
String[] p = input.getString(0).split(",");
collector.emit(
new
Values(
Double.
parseDouble
(p[0]),
Double.
parseDouble
(p[1]),
input.getValue(1)
)
);
}
public void
declareOutputFields(OutputFieldsDeclarer
declarer) {
declarer.declare(
new
Fields("x","y","return-info"));
}
}
The
PowerBolt
implementation takes the
x
and
y
values and computes the
power function. It returns this value as a
String
as required by the DRPC
power and also makes sure to transfer the
return-info
object:
public class
PowerBolt
extends
BaseBasicBolt {
private static final long
serialVersionUID
= 1L;
public void
execute(Tuple input,
BasicOutputCollector collector) {
collector.emit(