blob: 0ca1624411233dd1e427904fdbfc2b7719c7ea29 [file] [log] [blame]
/*
* Copyright 2016, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.sketches.hive.tuple;
import com.yahoo.sketches.tuple.Sketch;
import com.yahoo.sketches.tuple.Summary;
import com.yahoo.sketches.tuple.SummarySetOperations;
import com.yahoo.sketches.tuple.Union;
class UnionState<S extends Summary> extends State<S> {
private Union<S> union_;
boolean isInitialized() {
return union_ != null;
}
void init(final int nominalNumEntries, final SummarySetOperations<S> summarySetOps) {
super.init(nominalNumEntries);
union_ = new Union<S>(nominalNumEntries, summarySetOps);
}
void update(final Sketch<S> sketch) {
union_.update(sketch);
}
@Override
Sketch<S> getResult() {
if (union_ == null) { return null; }
return union_.getResult();
}
@Override
void reset() {
union_ = null;
}
}