use of org.apache.beam.sdk.nexmark.model.BidsPerSession in project beam by apache.
the class Query11 method expand.
@Override
public PCollection<BidsPerSession> expand(PCollection<Event> events) {
PCollection<Long> bidders = events.apply(NexmarkQueryUtil.JUST_BIDS).apply(name + ".Rekey", ParDo.of(new DoFn<Bid, Long>() {
@ProcessElement
public void processElement(ProcessContext c) {
Bid bid = c.element();
c.output(bid.bidder);
}
}));
PCollection<Long> biddersWindowed = bidders.apply(Window.<Long>into(Sessions.withGapDuration(Duration.standardSeconds(configuration.windowSizeSec))).triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(configuration.maxLogEvents))).discardingFiredPanes().withAllowedLateness(Duration.standardSeconds(configuration.occasionalDelaySec / 2)));
return biddersWindowed.apply(Count.perElement()).apply(name + ".ToResult", ParDo.of(new DoFn<KV<Long, Long>, BidsPerSession>() {
@ProcessElement
public void processElement(ProcessContext c) {
c.output(new BidsPerSession(c.element().getKey(), c.element().getValue()));
}
}));
}
Aggregations