You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemall.apache.org by my...@apache.org on 2020/07/27 06:36:56 UTC
[incubator-hivemall] branch master updated: [HIVEMALL-296][BUGFIX]
Fixed corner case NPE bug when count is zero
This is an automated email from the ASF dual-hosted git repository.
myui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hivemall.git
The following commit(s) were added to refs/heads/master by this push:
new e86815a [HIVEMALL-296][BUGFIX] Fixed corner case NPE bug when count is zero
e86815a is described below
commit e86815a5e88a161803a62c70ebbd00d5d688be2c
Author: Makoto Yui <my...@apache.org>
AuthorDate: Mon Jul 27 15:36:48 2020 +0900
[HIVEMALL-296][BUGFIX] Fixed corner case NPE bug when count is zero
## What changes were proposed in this pull request?
Fixed corner case NPE bug when count is zero.
```
Caused by: java.lang.NullPointerException
at hivemall.GeneralLearnerBaseUDTF.forwardModel(GeneralLearnerBaseUDTF.java:763)
at hivemall.GeneralLearnerBaseUDTF.close(GeneralLearnerBaseUDTF.java:560)
at org.apache.hadoop.hive.ql.exec.UDTFOperator.closeOp(UDTFOperator.java:152)
at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:697)
at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:711)
at org.apache.hadoop.hive.ql.exec.mr.ExecReducer.close(ExecReducer.java:279)
```
## What type of PR is it?
Bug Fix
## What is the Jira issue?
https://issues.apache.org/jira/browse/HIVEMALL-296
## How was this patch tested?
unit tests
## Checklist
- [x] Did you apply source code formatter, i.e., `./bin/format_code.sh`, for your commit?
- [ ] Did you run system tests on Hive (or Spark)?
Author: Makoto Yui <my...@apache.org>
Closes #230 from myui/HIVEMALL-296.
---
.../main/java/hivemall/GeneralLearnerBaseUDTF.java | 1 -
.../classifier/GeneralClassifierUDTFTest.java | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/hivemall/GeneralLearnerBaseUDTF.java b/core/src/main/java/hivemall/GeneralLearnerBaseUDTF.java
index 04f65e8..8400a2c 100644
--- a/core/src/main/java/hivemall/GeneralLearnerBaseUDTF.java
+++ b/core/src/main/java/hivemall/GeneralLearnerBaseUDTF.java
@@ -565,7 +565,6 @@ public abstract class GeneralLearnerBaseUDTF extends LearnerBaseUDTF {
@VisibleForTesting
public void finalizeTraining() throws HiveException {
if (count == 0L) {
- this.model = null;
return;
}
if (is_mini_batch) { // Update model with accumulated delta
diff --git a/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java b/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java
index 39c6db1..92964de 100644
--- a/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java
+++ b/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java
@@ -950,6 +950,26 @@ public class GeneralClassifierUDTFTest {
udtf.getCumulativeLoss() < 900);
}
+ @Test
+ public void testNPE_HIVEMALL296() throws IOException, HiveException {
+ String options =
+ "-loss logloss -opt sgd -reg l1 -lambda 0.0001 -iter 10 -mini_batch 1 -cv_rate 0.00005";
+
+ GeneralClassifierUDTF udtf = new GeneralClassifierUDTF();
+
+ ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(
+ PrimitiveObjectInspectorFactory.javaStringObjectInspector);
+ ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector(
+ PrimitiveObjectInspectorFactory.javaStringObjectInspector, options);
+
+ udtf.initialize(new ObjectInspector[] {stringListOI,
+ PrimitiveObjectInspectorFactory.javaIntObjectInspector, params});
+
+ udtf.close();
+
+ Assert.assertTrue("NPE should not occour", true);
+ }
+
private static void println(String msg) {
if (DEBUG) {
System.out.println(msg);