hivemall-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From takuti <...@git.apache.org>
Subject [GitHub] incubator-hivemall pull request #107: [HIVEMALL-132] Generalize f1score UDAF...
Date Mon, 21 Aug 2017 08:17:58 GMT
Github user takuti commented on a diff in the pull request:

    https://github.com/apache/incubator-hivemall/pull/107#discussion_r134135290
  
    --- Diff: core/src/main/java/hivemall/UDAFEvaluatorWithOptions.java ---
    @@ -0,0 +1,97 @@
    +package hivemall;
    +
    +import hivemall.utils.lang.CommandLineUtils;
    +import org.apache.commons.cli.CommandLine;
    +import org.apache.commons.cli.HelpFormatter;
    +import org.apache.commons.cli.Options;
    +import org.apache.hadoop.hive.ql.exec.Description;
    +import org.apache.hadoop.hive.ql.exec.MapredContext;
    +import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
    +import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator;
    +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
    +import org.apache.hadoop.mapred.Counters;
    +import org.apache.hadoop.mapred.Reporter;
    +
    +import javax.annotation.Nonnull;
    +import javax.annotation.Nullable;
    +import java.io.PrintWriter;
    +import java.io.StringWriter;
    +
    +public abstract class UDAFEvaluatorWithOptions extends GenericUDAFEvaluator {
    +
    +    @Nullable
    +    protected MapredContext mapredContext;
    +
    +    @Override
    +    public final void configure(MapredContext mapredContext) {
    +        this.mapredContext = mapredContext;
    +    }
    +
    +    @Nullable
    +    protected final Reporter getReporter() {
    +        if (mapredContext == null) {
    +            return null;
    +        }
    +        return mapredContext.getReporter();
    +    }
    +
    +    protected static void reportProgress(@Nullable Reporter reporter) {
    +        if (reporter != null) {
    +            synchronized (reporter) {
    +                reporter.progress();
    +            }
    +        }
    +    }
    +
    +    protected static void setCounterValue(@Nullable Counters.Counter counter, long value)
{
    --- End diff --
    
    Since `org.apache.hadoop.mapred.Counters` is only used for pointing to `org.apache.hadoop.mapred.Counters.Counter`,
you can directly import `org.apache.hadoop.mapred.Counters.Counter` like `UDTFWithOptions`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message