Database Reference
In-Depth Information
TridentTopology topology =
new
TridentTopology();
topology.newStream("lorem",
new
LoremIpsumSpout()
.tuple("first","second","third"))
.each(
new
RandomFunction(),
new
Fields("x"))
.each(
new
Fields("x"),
new
SquareFunction(),
new
Fields("y"))
.each(
new
Fields("x","y"),
new
PrintFunction(),
new
Fields())
;
Running this topology for a bit would produce output that looks like this
(only the
x
and
y
fields are pulled into the
PrintFunction
for brevity):
[0.8185738974522312, 0.6700632255901359]
[0.04147059259035091, 0.0017198100497948677]
[0.5122091469924017, 0.2623582102626838]
[0.032330581404519276, 0.0010452664939542477]
[0.49881777491999457, 0.24881917257613437]
[0.9140296292506043, 0.8354501631479971]
[0.807521215873791, 0.6520905140862857]
[0.03596640476063595, 0.0012935822714058964]
[0.7539011202358764, 0.5683668990929094]
Repartitioning Operations
In Trident, groupings are called repartitioning operations, but remain
essentially unchanged from their equivalent operations in standard
topologies.Theseoperations implyanetworktransfer oftuplesjustlikethey
do in a traditional topology:
• The
shuffle
partitioning evenly distributes tuples across target
partitions.
• The
broadcast
partitioning sends all tuples to all target partitions.
• The
partitionBy
partitioning is equivalent to the
fieldsGrouping
.
It takes a list of fields found in each tuple and uses a hash of their values
to determine a target partition.
• The
global
partition sends all tuples to the same partition. Trident
also adds a
batchGlobal
variant that sends all tuples from the same