in src/main/java/org/apache/datasketches/pig/frequencies/UnionFrequentItemsSketch.java [71:100]
public void accumulate(final Tuple inputTuple) throws IOException {
if (this.isFirstCall_) {
// this is to see in the log which way was used by Pig
Logger.getLogger(getClass()).info("accumulator is used");
this.isFirstCall_ = false;
}
if ((inputTuple == null) || (inputTuple.size() != 1)) {
return;
}
final Object obj = inputTuple.get(0);
if (!(obj instanceof DataBag)) {
return;
}
final DataBag bag = (DataBag) inputTuple.get(0);
if (bag.size() == 0) {
return;
}
if (this.sketch_ == null) {
this.sketch_ = new ItemsSketch<>(this.sketchSize_);
}
for (final Tuple innerTuple: bag) {
final int sz = innerTuple.size();
if ((sz != 1) || (innerTuple.get(0) == null)) {
continue;
}
final ItemsSketch<T> incomingSketch = Util.deserializeSketchFromTuple(innerTuple, this.serDe_);
this.sketch_.merge(incomingSketch);
}
}