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 2017/06/06 06:25:37 UTC

[2/2] incubator-hivemall git commit: Applied refactoring to the previous commit

Applied refactoring to the previous commit


Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/609e4801
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/609e4801
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/609e4801

Branch: refs/heads/master
Commit: 609e48016e0b83f76b15b089cb1045bbbd7ad132
Parents: 92e85ad
Author: myui <yu...@gmail.com>
Authored: Tue Jun 6 15:24:38 2017 +0900
Committer: myui <yu...@gmail.com>
Committed: Tue Jun 6 15:24:38 2017 +0900

----------------------------------------------------------------------
 .../main/java/hivemall/fm/FactorizationMachineUDTF.java | 12 ++++++------
 core/src/main/java/hivemall/topicmodel/LDAUDTF.java     |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/609e4801/core/src/main/java/hivemall/fm/FactorizationMachineUDTF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/fm/FactorizationMachineUDTF.java b/core/src/main/java/hivemall/fm/FactorizationMachineUDTF.java
index d263cbc..3fadc38 100644
--- a/core/src/main/java/hivemall/fm/FactorizationMachineUDTF.java
+++ b/core/src/main/java/hivemall/fm/FactorizationMachineUDTF.java
@@ -30,6 +30,7 @@ import hivemall.utils.hadoop.HiveUtils;
 import hivemall.utils.io.FileUtils;
 import hivemall.utils.io.NioStatefullSegment;
 import hivemall.utils.lang.NumberUtils;
+import hivemall.utils.lang.SizeOf;
 import hivemall.utils.math.MathUtils;
 
 import java.io.File;
@@ -67,7 +68,6 @@ import org.apache.hadoop.mapred.Reporter;
         value = "_FUNC_(array<string> x, double y [, const string options]) - Returns a prediction model")
 public class FactorizationMachineUDTF extends UDTFWithOptions {
     private static final Log LOG = LogFactory.getLog(FactorizationMachineUDTF.class);
-    private static final int INT_BYTES = Integer.SIZE / 8;
 
     protected ListObjectInspector _xOI;
     protected PrimitiveObjectInspector _yOI;
@@ -318,8 +318,8 @@ public class FactorizationMachineUDTF extends UDTFWithOptions {
         }
 
         int xBytes = Feature.requiredBytes(x);
-        int recordBytes = (Integer.SIZE + Double.SIZE) / 8 + xBytes;
-        int requiredBytes = (Integer.SIZE / 8) + recordBytes;
+        int recordBytes = SizeOf.INT + SizeOf.DOUBLE + xBytes;
+        int requiredBytes = SizeOf.INT + recordBytes;
         int remain = inputBuf.remaining();
         if (remain < requiredBytes) {
             writeBuffer(inputBuf, dst);
@@ -612,13 +612,13 @@ public class FactorizationMachineUDTF extends UDTFWithOptions {
                         // reads training examples from a buffer
                         inputBuf.flip();
                         int remain = inputBuf.remaining();
-                        if (remain < INT_BYTES) {
+                        if (remain < SizeOf.INT) {
                             throw new HiveException("Illegal file format was detected");
                         }
-                        while (remain >= INT_BYTES) {
+                        while (remain >= SizeOf.INT) {
                             int pos = inputBuf.position();
                             int recordBytes = inputBuf.getInt();
-                            remain -= INT_BYTES;
+                            remain -= SizeOf.INT;
                             if (remain < recordBytes) {
                                 inputBuf.position(pos);
                                 break;

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/609e4801/core/src/main/java/hivemall/topicmodel/LDAUDTF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/topicmodel/LDAUDTF.java b/core/src/main/java/hivemall/topicmodel/LDAUDTF.java
index daec7ea..de57518 100644
--- a/core/src/main/java/hivemall/topicmodel/LDAUDTF.java
+++ b/core/src/main/java/hivemall/topicmodel/LDAUDTF.java
@@ -546,7 +546,7 @@ public class LDAUDTF extends UDTFWithOptions {
      */
 
     @VisibleForTesting
-    public void closeWithoutModelReset() throws HiveException {
+    void closeWithoutModelReset() throws HiveException {
         // launch close(), but not forward & clear model
         if (count == 0) {
             this.model = null;