Repository: incubator-hivemall Updated Branches: refs/heads/master 49441baf0 -> 912010305
[HIVEMALL-219][BUGFIX] Fixed NPE in finalizeTraining() ## What changes were proposed in this pull request? Fixed NPE in finalizeTraining() where there are no training example ## What type of PR is it? Bug Fix ## What is the Jira issue? https://issues.apache.org/jira/browse/HIVEMALL-219 ## How was this patch tested? to appear ## Checklist (Please remove this section if not needed; check `x` for YES, blank for NO) - [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 <[email protected]> Closes #165 from myui/HIVEMALL-219. Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/91201030 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/91201030 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/91201030 Branch: refs/heads/master Commit: 912010305286f673cc7e8bcbdf1555be4a38921a Parents: 49441ba Author: Makoto Yui <[email protected]> Authored: Tue Sep 18 18:51:33 2018 +0900 Committer: Makoto Yui <[email protected]> Committed: Tue Sep 18 18:51:33 2018 +0900 ---------------------------------------------------------------------- .../topicmodel/ProbabilisticTopicModelBaseUDTF.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/91201030/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java b/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java index 23a021d..5a5fbce 100644 --- a/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java +++ b/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java @@ -276,10 +276,17 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { @Override public void close() throws HiveException { - if (model.getDocCount() == 0L) { + if (model == null) { + logger.warn( + "Model is not initialized bacause no training exmples to learn. Better to revise input data."); + return; + } else if (model.getDocCount() == 0L) { + logger.warn( + "model.getDocCount() is zero because no training exmples to learn. Better to revise input data."); this.model = null; - throw new HiveException("No training exmples to learn. Please revise input data."); + return; } + finalizeTraining(); forwardModel(); this.model = null;
