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/01/16 09:27:57 UTC

incubator-hivemall git commit: Close #19: Add Java annotations

Repository: incubator-hivemall
Updated Branches:
  refs/heads/master ac4136f82 -> 38224bb23


Close #19: Add Java annotations


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

Branch: refs/heads/master
Commit: 38224bb23bd64ebc5187a1fd506d2031b6d0f446
Parents: ac4136f
Author: myui <yu...@gmail.com>
Authored: Mon Jan 16 18:27:29 2017 +0900
Committer: myui <yu...@gmail.com>
Committed: Mon Jan 16 18:27:29 2017 +0900

----------------------------------------------------------------------
 .../java/hivemall/annotations/Experimental.java | 34 ++++++++++++++++++++
 .../main/java/hivemall/annotations/Issue.java   | 30 +++++++++++++++++
 .../hivemall/annotations/VisibleForTesting.java | 31 ++++++++++++++++++
 .../KernelExpansionPassiveAggressiveUDTF.java   |  7 +++-
 .../main/java/hivemall/fm/FFMPredictUDF.java    |  5 +++
 .../fm/FieldAwareFactorizationMachineUDTF.java  |  1 +
 6 files changed, 107 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/annotations/Experimental.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/annotations/Experimental.java b/core/src/main/java/hivemall/annotations/Experimental.java
new file mode 100644
index 0000000..c4644b9
--- /dev/null
+++ b/core/src/main/java/hivemall/annotations/Experimental.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package hivemall.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotate program elements that might be changed in the future release.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PACKAGE})
+@Documented
+public @interface Experimental {
+}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/annotations/Issue.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/annotations/Issue.java b/core/src/main/java/hivemall/annotations/Issue.java
new file mode 100644
index 0000000..59fe348
--- /dev/null
+++ b/core/src/main/java/hivemall/annotations/Issue.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package hivemall.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Linked to an issue URL.
+ */
+@Retention(RetentionPolicy.SOURCE)
+public @interface Issue {
+    String ref();
+}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/annotations/VisibleForTesting.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/annotations/VisibleForTesting.java b/core/src/main/java/hivemall/annotations/VisibleForTesting.java
new file mode 100644
index 0000000..2337fa2
--- /dev/null
+++ b/core/src/main/java/hivemall/annotations/VisibleForTesting.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package hivemall.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Annotates a program element that is only for use in test codes.
+ */
+@Retention(RetentionPolicy.CLASS)
+@Documented
+public @interface VisibleForTesting {
+}

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTF.java b/core/src/main/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTF.java
index 3e28932..7cb7a58 100644
--- a/core/src/main/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTF.java
+++ b/core/src/main/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTF.java
@@ -18,6 +18,8 @@
  */
 package hivemall.classifier;
 
+import hivemall.annotations.Experimental;
+import hivemall.annotations.VisibleForTesting;
 import hivemall.common.LossFunctions;
 import hivemall.model.FeatureValue;
 import hivemall.model.PredictionModel;
@@ -51,10 +53,13 @@ import org.apache.hadoop.io.IntWritable;
  * <pre>
  * Hideki Isozaki and Hideto Kazawa: Efficient Support Vector Classifiers for Named Entity Recognition, Proc.COLING, 2002
  * </pre>
+ * 
+ * @since v0.5-rc.1
  */
 @Description(name = "train_kpa",
         value = "_FUNC_(array<string|int|bigint> features, int label [, const string options])"
                 + " - returns a relation <h int, hk int, float w0, float w1, float w2, float w3>")
+@Experimental
 public final class KernelExpansionPassiveAggressiveUDTF extends BinaryOnlineClassifierUDTF {
 
     // ------------------------------------
@@ -77,7 +82,7 @@ public final class KernelExpansionPassiveAggressiveUDTF extends BinaryOnlineClas
 
     public KernelExpansionPassiveAggressiveUDTF() {}
 
-    //@VisibleForTesting
+    @VisibleForTesting
     float getLoss() {//only used for testing purposes at the moment
         return _loss;
     }

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/fm/FFMPredictUDF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/fm/FFMPredictUDF.java b/core/src/main/java/hivemall/fm/FFMPredictUDF.java
index e32c61a..2de5170 100644
--- a/core/src/main/java/hivemall/fm/FFMPredictUDF.java
+++ b/core/src/main/java/hivemall/fm/FFMPredictUDF.java
@@ -18,6 +18,7 @@
  */
 package hivemall.fm;
 
+import hivemall.annotations.Experimental;
 import hivemall.utils.hadoop.HiveUtils;
 import hivemall.utils.lang.NumberUtils;
 
@@ -40,10 +41,14 @@ import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectIn
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
 import org.apache.hadoop.io.Text;
 
+/**
+ * @since v0.5-rc.1
+ */
 @Description(name = "ffm_predict",
         value = "_FUNC_(string modelId, string model, array<string> features)"
                 + " returns a prediction result in double from a Field-aware Factorization Machine")
 @UDFType(deterministic = true, stateful = false)
+@Experimental
 public final class FFMPredictUDF extends GenericUDF {
 
     private StringObjectInspector _modelIdOI;

http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/38224bb2/core/src/main/java/hivemall/fm/FieldAwareFactorizationMachineUDTF.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/hivemall/fm/FieldAwareFactorizationMachineUDTF.java b/core/src/main/java/hivemall/fm/FieldAwareFactorizationMachineUDTF.java
index 62fbfa1..fe27269 100644
--- a/core/src/main/java/hivemall/fm/FieldAwareFactorizationMachineUDTF.java
+++ b/core/src/main/java/hivemall/fm/FieldAwareFactorizationMachineUDTF.java
@@ -50,6 +50,7 @@ import org.apache.hadoop.io.Text;
  * Field-aware Factorization Machines.
  * 
  * @link https://www.csie.ntu.edu.tw/~cjlin/libffm/
+ * @since v0.5-rc.1
  */
 @Description(
         name = "train_ffm",