http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/json/ToJsonUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/json/ToJsonUDF.java b/core/src/main/java/hivemall/tools/json/ToJsonUDF.java index 416d0c9..70c62b9 100644 --- a/core/src/main/java/hivemall/tools/json/ToJsonUDF.java +++ b/core/src/main/java/hivemall/tools/json/ToJsonUDF.java @@ -37,8 +37,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; import org.apache.hadoop.io.Text; -@Description( - name = "to_json", +@Description(name = "to_json", value = "_FUNC_(ANY object [, const array<string>|const string columnNames]) - Returns Json string") @UDFType(deterministic = true, stateful = false) public final class ToJsonUDF extends GenericUDF { @@ -51,7 +50,8 @@ public final class ToJsonUDF extends GenericUDF { @Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length != 1 && argOIs.length != 2) { - throw new UDFArgumentException("from_json takes one or two arguments: " + argOIs.length); + throw new UDFArgumentException( + "from_json takes one or two arguments: " + argOIs.length); } this.objOI = argOIs[0]; @@ -81,8 +81,8 @@ public final class ToJsonUDF extends GenericUDF { try { return JsonSerdeUtils.serialize(obj, objOI, columnNames); } catch (Throwable e) { - throw new HiveException("Failed to serialize: " + obj + '\n' - + ExceptionUtils.prettyPrintStackTrace(e), e); + throw new HiveException( + "Failed to serialize: " + obj + '\n' + ExceptionUtils.prettyPrintStackTrace(e), e); } }
http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/list/UDAFToOrderedList.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/list/UDAFToOrderedList.java b/core/src/main/java/hivemall/tools/list/UDAFToOrderedList.java index 37b33c4..5ef6ddb 100644 --- a/core/src/main/java/hivemall/tools/list/UDAFToOrderedList.java +++ b/core/src/main/java/hivemall/tools/list/UDAFToOrderedList.java @@ -66,21 +66,14 @@ import org.apache.hadoop.io.IntWritable; /** * Return list of values sorted by value itself or specific key. */ -@Description( - name = "to_ordered_list", +@Description(name = "to_ordered_list", value = "_FUNC_(PRIMITIVE value [, PRIMITIVE key, const string options])" + " - Return list of values sorted by value itself or specific key", - extended = "with t as (\n" - + " select 5 as key, 'apple' as value\n" - + " union all\n" - + " select 3 as key, 'banana' as value\n" - + " union all\n" - + " select 4 as key, 'candy' as value\n" - + " union all\n" - + " select 2 as key, 'donut' as value\n" - + " union all\n" - + " select 3 as key, 'egg' as value\n" - + ")\n" + extended = "with t as (\n" + " select 5 as key, 'apple' as value\n" + " union all\n" + + " select 3 as key, 'banana' as value\n" + " union all\n" + + " select 4 as key, 'candy' as value\n" + " union all\n" + + " select 2 as key, 'donut' as value\n" + " union all\n" + + " select 3 as key, 'egg' as value\n" + ")\n" + "select -- expected output\n" + " to_ordered_list(value, key, '-reverse'), -- [apple, candy, (banana, egg | egg, banana), donut] (reverse order)\n" + " to_ordered_list(value, key, '-k 2'), -- [apple, candy] (top-k)\n" @@ -102,7 +95,8 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { @SuppressWarnings("deprecation") TypeInfo[] typeInfo = info.getParameters(); ObjectInspector[] argOIs = info.getParameterObjectInspectors(); - if ((typeInfo.length == 1) || (typeInfo.length == 2 && HiveUtils.isConstString(argOIs[1]))) { + if ((typeInfo.length == 1) + || (typeInfo.length == 2 && HiveUtils.isConstString(argOIs[1]))) { // sort values by value itself w/o key if (typeInfo[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, @@ -247,14 +241,17 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { // re-extract input value OI this.valueListField = soi.getStructFieldRef("valueList"); - StandardListObjectInspector valueListOI = (StandardListObjectInspector) valueListField.getFieldObjectInspector(); + StandardListObjectInspector valueListOI = + (StandardListObjectInspector) valueListField.getFieldObjectInspector(); this.valueOI = valueListOI.getListElementObjectInspector(); this.valueListOI = ObjectInspectorFactory.getStandardListObjectInspector(valueOI); // re-extract input key OI this.keyListField = soi.getStructFieldRef("keyList"); - StandardListObjectInspector keyListOI = (StandardListObjectInspector) keyListField.getFieldObjectInspector(); - this.keyOI = HiveUtils.asPrimitiveObjectInspector(keyListOI.getListElementObjectInspector()); + StandardListObjectInspector keyListOI = + (StandardListObjectInspector) keyListField.getFieldObjectInspector(); + this.keyOI = HiveUtils.asPrimitiveObjectInspector( + keyListOI.getListElementObjectInspector()); this.keyListOI = ObjectInspectorFactory.getStandardListObjectInspector(keyOI); this.sizeField = soi.getStructFieldRef("size"); @@ -266,7 +263,8 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {// terminatePartial outputOI = internalMergeOI(valueOI, keyOI); } else {// terminate - outputOI = ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorUtils.getStandardObjectInspector(valueOI)); + outputOI = ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorUtils.getStandardObjectInspector(valueOI)); } return outputOI; @@ -279,9 +277,11 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { List<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); fieldNames.add("valueList"); - fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorUtils.getStandardObjectInspector(valueOI))); + fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorUtils.getStandardObjectInspector(valueOI))); fieldNames.add("keyList"); - fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorUtils.getStandardObjectInspector(keyOI))); + fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorUtils.getStandardObjectInspector(keyOI))); fieldNames.add("size"); fieldOIs.add(PrimitiveObjectInspectorFactory.writableIntObjectInspector); fieldNames.add("reverseOrder"); @@ -358,15 +358,17 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { } Object valueListObj = internalMergeOI.getStructFieldData(partial, valueListField); - final List<?> valueListRaw = valueListOI.getList(HiveUtils.castLazyBinaryObject(valueListObj)); + final List<?> valueListRaw = + valueListOI.getList(HiveUtils.castLazyBinaryObject(valueListObj)); final List<Object> valueList = new ArrayList<Object>(); for (int i = 0, n = valueListRaw.size(); i < n; i++) { - valueList.add(ObjectInspectorUtils.copyToStandardObject(valueListRaw.get(i), - valueOI)); + valueList.add( + ObjectInspectorUtils.copyToStandardObject(valueListRaw.get(i), valueOI)); } Object keyListObj = internalMergeOI.getStructFieldData(partial, keyListField); - final List<?> keyListRaw = keyListOI.getList(HiveUtils.castLazyBinaryObject(keyListObj)); + final List<?> keyListRaw = + keyListOI.getList(HiveUtils.castLazyBinaryObject(keyListObj)); final List<Object> keyList = new ArrayList<Object>(); for (int i = 0, n = keyListRaw.size(); i < n; i++) { keyList.add(ObjectInspectorUtils.copyToStandardObject(keyListRaw.get(i), keyOI)); @@ -376,7 +378,9 @@ public final class UDAFToOrderedList extends AbstractGenericUDAFResolver { int size = PrimitiveObjectInspectorFactory.writableIntObjectInspector.get(sizeObj); Object reverseOrderObj = internalMergeOI.getStructFieldData(partial, reverseOrderField); - boolean reverseOrder = PrimitiveObjectInspectorFactory.writableBooleanObjectInspector.get(reverseOrderObj); + boolean reverseOrder = + PrimitiveObjectInspectorFactory.writableBooleanObjectInspector.get( + reverseOrderObj); QueueAggregationBuffer myagg = (QueueAggregationBuffer) agg; myagg.setOptions(size, reverseOrder); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/map/MapTailNUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/map/MapTailNUDF.java b/core/src/main/java/hivemall/tools/map/MapTailNUDF.java index f2da8b8..d8163f6 100644 --- a/core/src/main/java/hivemall/tools/map/MapTailNUDF.java +++ b/core/src/main/java/hivemall/tools/map/MapTailNUDF.java @@ -57,7 +57,8 @@ public class MapTailNUDF extends GenericUDF { } this.intObjectInspector = (IntObjectInspector) arguments[1]; - ObjectInspector keyOI = ObjectInspectorUtils.getStandardObjectInspector(mapObjectInspector.getMapKeyObjectInspector()); + ObjectInspector keyOI = ObjectInspectorUtils.getStandardObjectInspector( + mapObjectInspector.getMapKeyObjectInspector()); ObjectInspector valueOI = mapObjectInspector.getMapValueObjectInspector(); return ObjectInspectorFactory.getStandardMapObjectInspector(keyOI, valueOI); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/map/UDAFToMap.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/map/UDAFToMap.java b/core/src/main/java/hivemall/tools/map/UDAFToMap.java index e4d42d9..b203909 100644 --- a/core/src/main/java/hivemall/tools/map/UDAFToMap.java +++ b/core/src/main/java/hivemall/tools/map/UDAFToMap.java @@ -79,7 +79,8 @@ public class UDAFToMap extends AbstractGenericUDAFResolver { inputValueOI = argOIs[1]; } else {// from partial aggregation internalMergeOI = (StandardMapObjectInspector) argOIs[0]; - inputKeyOI = HiveUtils.asPrimitiveObjectInspector(internalMergeOI.getMapKeyObjectInspector()); + inputKeyOI = HiveUtils.asPrimitiveObjectInspector( + internalMergeOI.getMapKeyObjectInspector()); inputValueOI = internalMergeOI.getMapValueObjectInspector(); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/map/UDAFToOrderedMap.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/map/UDAFToOrderedMap.java b/core/src/main/java/hivemall/tools/map/UDAFToOrderedMap.java index ba8ef82..e58ff67 100644 --- a/core/src/main/java/hivemall/tools/map/UDAFToOrderedMap.java +++ b/core/src/main/java/hivemall/tools/map/UDAFToOrderedMap.java @@ -53,18 +53,12 @@ import org.apache.hadoop.io.IntWritable; /** * Convert two aggregated columns into a sorted key-value map. */ -@Description( - name = "to_ordered_map", +@Description(name = "to_ordered_map", value = "_FUNC_(key, value [, const int k|const boolean reverseOrder=false]) " + "- Convert two aggregated columns into an ordered key-value map", - extended = "with t as (\n" - + " select 10 as key, 'apple' as value\n" - + " union all\n" - + " select 3 as key, 'banana' as value\n" - + " union all\n" - + " select 4 as key, 'candy' as value\n" - + ")\n" - + "select\n" + extended = "with t as (\n" + " select 10 as key, 'apple' as value\n" + " union all\n" + + " select 3 as key, 'banana' as value\n" + " union all\n" + + " select 4 as key, 'candy' as value\n" + ")\n" + "select\n" + " to_ordered_map(key, value, true), -- {10:\"apple\",4:\"candy\",3:\"banana\"} (reverse)\n" + " to_ordered_map(key, value, 1), -- {10:\"apple\"} (top-1)\n" + " to_ordered_map(key, value, 2), -- {10:\"apple\",4:\"candy\"} (top-2)\n" @@ -142,8 +136,8 @@ public final class UDAFToOrderedMap extends UDAFToMap { @Override public void reset(@SuppressWarnings("deprecation") AggregationBuffer agg) throws HiveException { - ((MapAggregationBuffer) agg).container = new TreeMap<Object, Object>( - Collections.reverseOrder()); + ((MapAggregationBuffer) agg).container = + new TreeMap<Object, Object>(Collections.reverseOrder()); } } @@ -175,8 +169,10 @@ public final class UDAFToOrderedMap extends UDAFToMap { this.partialMapField = soi.getStructFieldRef("partialMap"); // re-extract input key/value OIs - MapObjectInspector partialMapOI = (MapObjectInspector) partialMapField.getFieldObjectInspector(); - this.inputKeyOI = HiveUtils.asPrimitiveObjectInspector(partialMapOI.getMapKeyObjectInspector()); + MapObjectInspector partialMapOI = + (MapObjectInspector) partialMapField.getFieldObjectInspector(); + this.inputKeyOI = HiveUtils.asPrimitiveObjectInspector( + partialMapOI.getMapKeyObjectInspector()); this.inputValueOI = partialMapOI.getMapValueObjectInspector(); this.partialMapOI = ObjectInspectorFactory.getStandardMapObjectInspector( @@ -289,7 +285,8 @@ public final class UDAFToOrderedMap extends UDAFToMap { MapAggregationBuffer myagg = (MapAggregationBuffer) agg; Object partialMapObj = internalMergeOI.getStructFieldData(partial, partialMapField); - Map<?, ?> partialMap = partialMapOI.getMap(HiveUtils.castLazyBinaryObject(partialMapObj)); + Map<?, ?> partialMap = + partialMapOI.getMap(HiveUtils.castLazyBinaryObject(partialMapObj)); if (partialMap == null) { return; } @@ -301,7 +298,8 @@ public final class UDAFToOrderedMap extends UDAFToMap { } for (Map.Entry<?, ?> e : partialMap.entrySet()) { Object key = ObjectInspectorUtils.copyToStandardObject(e.getKey(), inputKeyOI); - Object value = ObjectInspectorUtils.copyToStandardObject(e.getValue(), inputValueOI); + Object value = + ObjectInspectorUtils.copyToStandardObject(e.getValue(), inputValueOI); myagg.container.put(key, value); } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/mapred/DistributedCacheLookupUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/mapred/DistributedCacheLookupUDF.java b/core/src/main/java/hivemall/tools/mapred/DistributedCacheLookupUDF.java index 2794476..62d0549 100644 --- a/core/src/main/java/hivemall/tools/mapred/DistributedCacheLookupUDF.java +++ b/core/src/main/java/hivemall/tools/mapred/DistributedCacheLookupUDF.java @@ -51,8 +51,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; import org.apache.hadoop.io.Text; -@Description( - name = "distcache_gets", +@Description(name = "distcache_gets", value = "_FUNC_(filepath, key, default_value [, parseKey]) - Returns map<key_type, value_type>|value_type") @UDFType(deterministic = false, stateful = false) public final class DistributedCacheLookupUDF extends GenericUDF { @@ -77,9 +76,8 @@ public final class DistributedCacheLookupUDF extends GenericUDF { + argOIs.length + getUsage()); } if (!ObjectInspectorUtils.isConstantObjectInspector(argOIs[2])) { - throw new UDFArgumentException( - "Third argument DEFAULT_VALUE must be a constant value: " - + TypeInfoUtils.getTypeInfoFromObjectInspector(argOIs[2])); + throw new UDFArgumentException("Third argument DEFAULT_VALUE must be a constant value: " + + TypeInfoUtils.getTypeInfoFromObjectInspector(argOIs[2])); } if (argOIs.length == 4) { this.parseKey = HiveUtils.getConstBoolean(argOIs[3]); @@ -126,8 +124,8 @@ public final class DistributedCacheLookupUDF extends GenericUDF { "parseKey=true is only available for string typed key(s)"); } - final Object2ObjectMap<Object, Object> map = new Object2ObjectOpenHashMap<Object, Object>( - 8192); + final Object2ObjectMap<Object, Object> map = + new Object2ObjectOpenHashMap<Object, Object>(8192); try { loadValues(map, new File(filepath), keyInputOI, valueInputOI); this.cache = map; @@ -141,8 +139,8 @@ public final class DistributedCacheLookupUDF extends GenericUDF { } private static void loadValues(Object2ObjectMap<Object, Object> map, File file, - PrimitiveObjectInspector keyOI, PrimitiveObjectInspector valueOI) throws IOException, - SerDeException { + PrimitiveObjectInspector keyOI, PrimitiveObjectInspector valueOI) + throws IOException, SerDeException { if (!file.exists()) { return; } @@ -156,8 +154,10 @@ public final class DistributedCacheLookupUDF extends GenericUDF { StructObjectInspector lineOI = (StructObjectInspector) serde.getObjectInspector(); StructField keyRef = lineOI.getStructFieldRef("key"); StructField valueRef = lineOI.getStructFieldRef("value"); - PrimitiveObjectInspector keyRefOI = (PrimitiveObjectInspector) keyRef.getFieldObjectInspector(); - PrimitiveObjectInspector valueRefOI = (PrimitiveObjectInspector) valueRef.getFieldObjectInspector(); + PrimitiveObjectInspector keyRefOI = + (PrimitiveObjectInspector) keyRef.getFieldObjectInspector(); + PrimitiveObjectInspector valueRefOI = + (PrimitiveObjectInspector) valueRef.getFieldObjectInspector(); BufferedReader reader = null; try { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/mapred/RowNumberUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/mapred/RowNumberUDF.java b/core/src/main/java/hivemall/tools/mapred/RowNumberUDF.java index 59f64ba..3c92e30 100644 --- a/core/src/main/java/hivemall/tools/mapred/RowNumberUDF.java +++ b/core/src/main/java/hivemall/tools/mapred/RowNumberUDF.java @@ -49,8 +49,8 @@ public final class RowNumberUDF extends UDF { if (taskId == -1) { this.taskId = HadoopUtils.getTaskId() + 1; if (taskId > 9999) { - throw new HiveException("TaskId out of range `" + taskId - + "`. rownum() supports 9999 tasks at max"); + throw new HiveException( + "TaskId out of range `" + taskId + "`. rownum() supports 9999 tasks at max"); } } sequence++; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/math/L2NormUDAF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/math/L2NormUDAF.java b/core/src/main/java/hivemall/tools/math/L2NormUDAF.java index dda47fa..921272a 100644 --- a/core/src/main/java/hivemall/tools/math/L2NormUDAF.java +++ b/core/src/main/java/hivemall/tools/math/L2NormUDAF.java @@ -25,8 +25,7 @@ import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.serde2.io.DoubleWritable; @SuppressWarnings("deprecation") -@Description( - name = "l2_norm", +@Description(name = "l2_norm", value = "_FUNC_(double xi) - Return L2 norm of a vector which has the given values in each dimension") public final class L2NormUDAF extends UDAF { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/matrix/TransposeAndDotUDAF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/matrix/TransposeAndDotUDAF.java b/core/src/main/java/hivemall/tools/matrix/TransposeAndDotUDAF.java index 440bbe6..d04ddc1 100644 --- a/core/src/main/java/hivemall/tools/matrix/TransposeAndDotUDAF.java +++ b/core/src/main/java/hivemall/tools/matrix/TransposeAndDotUDAF.java @@ -44,8 +44,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.DoubleObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; -@Description( - name = "transpose_and_dot", +@Description(name = "transpose_and_dot", value = "_FUNC_(array<number> matrix0_row, array<number> matrix1_row)" + " - Returns dot(matrix0.T, matrix1) as array<array<double>>, shape = (matrix0.#cols, matrix1.#cols)") public final class TransposeAndDotUDAF extends AbstractGenericUDAFResolver { @@ -118,16 +117,22 @@ public final class TransposeAndDotUDAF extends AbstractGenericUDAFResolver { if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) { this.matrix0RowOI = HiveUtils.asListOI(OIs[0]); - this.matrix0ElOI = HiveUtils.asDoubleCompatibleOI(matrix0RowOI.getListElementObjectInspector()); + this.matrix0ElOI = HiveUtils.asDoubleCompatibleOI( + matrix0RowOI.getListElementObjectInspector()); this.matrix1RowOI = HiveUtils.asListOI(OIs[1]); - this.matrix1ElOI = HiveUtils.asDoubleCompatibleOI(matrix1RowOI.getListElementObjectInspector()); + this.matrix1ElOI = HiveUtils.asDoubleCompatibleOI( + matrix1RowOI.getListElementObjectInspector()); } else { this.aggMatrixOI = HiveUtils.asListOI(OIs[0]); - this.aggMatrixRowOI = HiveUtils.asListOI(aggMatrixOI.getListElementObjectInspector()); - this.aggMatrixElOI = HiveUtils.asDoubleOI(aggMatrixRowOI.getListElementObjectInspector()); + this.aggMatrixRowOI = + HiveUtils.asListOI(aggMatrixOI.getListElementObjectInspector()); + this.aggMatrixElOI = + HiveUtils.asDoubleOI(aggMatrixRowOI.getListElementObjectInspector()); } - return ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector)); + return ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.writableDoubleObjectInspector)); } @Override http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/text/NormalizeUnicodeUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/text/NormalizeUnicodeUDF.java b/core/src/main/java/hivemall/tools/text/NormalizeUnicodeUDF.java index 0908e44..aefb4e2 100644 --- a/core/src/main/java/hivemall/tools/text/NormalizeUnicodeUDF.java +++ b/core/src/main/java/hivemall/tools/text/NormalizeUnicodeUDF.java @@ -26,8 +26,7 @@ import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.ql.udf.UDFType; -@Description( - name = "normalize_unicode", +@Description(name = "normalize_unicode", value = "_FUNC_(string str [, string form]) - Transforms `str` with the specified normalization form. " + "The `form` takes one of NFC (default), NFD, NFKC, or NFKD", extended = "select normalize_unicode('ï¾ï¾ï½¶ï½¸ï½¶ï¾ ','NFKC');\n" + "> ãã³ã«ã¯ã«ã\n" + "\n" http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/text/SingularizeUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/text/SingularizeUDF.java b/core/src/main/java/hivemall/tools/text/SingularizeUDF.java index 3d217e0..73d2d63 100644 --- a/core/src/main/java/hivemall/tools/text/SingularizeUDF.java +++ b/core/src/main/java/hivemall/tools/text/SingularizeUDF.java @@ -49,8 +49,8 @@ public final class SingularizeUDF extends UDF { private static final String[] prepositions = new String[] {"about", "above", "across", "after", "among", "around", "at", "athwart", "before", "behind", "below", "beneath", "beside", "besides", "between", "betwixt", "beyond", "but", "by", "during", "except", "for", - "from", "in", "into", "near", "of", "off", "on", "onto", "out", "over", "since", - "till", "to", "under", "until", "unto", "upon", "with"}; + "from", "in", "into", "near", "of", "off", "on", "onto", "out", "over", "since", "till", + "to", "under", "until", "unto", "upon", "with"}; // uninfected or uncountable words private static final String[] unchanged = new String[] {"advice", "bison", "bread", "bream", "breeches", "britches", "butter", "carp", "chassis", "cheese", "christmas", "clippers", http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/text/SplitWordsUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/text/SplitWordsUDF.java b/core/src/main/java/hivemall/tools/text/SplitWordsUDF.java index e015021..0b10c2f 100644 --- a/core/src/main/java/hivemall/tools/text/SplitWordsUDF.java +++ b/core/src/main/java/hivemall/tools/text/SplitWordsUDF.java @@ -27,8 +27,7 @@ import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.ql.udf.UDFType; import org.apache.hadoop.io.Text; -@Description( - name = "split_words", +@Description(name = "split_words", value = "_FUNC_(string query [, string regex]) - Returns an array<text> containing split strings") @UDFType(deterministic = true, stateful = false) public final class SplitWordsUDF extends UDF { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/text/StopwordUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/text/StopwordUDF.java b/core/src/main/java/hivemall/tools/text/StopwordUDF.java index 9d68de1..63babe2 100644 --- a/core/src/main/java/hivemall/tools/text/StopwordUDF.java +++ b/core/src/main/java/hivemall/tools/text/StopwordUDF.java @@ -39,14 +39,14 @@ public final class StopwordUDF extends UDF { "she", "her", "hers", "herself", "it", "its", "itself", "they", "them", "their", "theirs", "themselves", "what", "which", "who", "whom", "this", "that", "these", "those", "am", "is", "are", "was", "were", "be", "been", "being", "have", "has", - "had", "having", "do", "does", "did", "doing", "a", "an", "the", "and", "but", - "if", "or", "because", "as", "until", "while", "of", "at", "by", "for", "with", - "about", "against", "between", "into", "through", "during", "before", "after", - "above", "below", "to", "from", "up", "down", "in", "out", "on", "off", "over", - "under", "again", "further", "then", "once", "here", "there", "when", "where", - "why", "how", "all", "any", "both", "each", "few", "more", "most", "other", "some", - "such", "no", "nor", "not", "only", "own", "same", "so", "than", "too", "very", - "s", "t", "can", "will", "just", "don", "should", "now"}; + "had", "having", "do", "does", "did", "doing", "a", "an", "the", "and", "but", "if", + "or", "because", "as", "until", "while", "of", "at", "by", "for", "with", "about", + "against", "between", "into", "through", "during", "before", "after", "above", + "below", "to", "from", "up", "down", "in", "out", "on", "off", "over", "under", + "again", "further", "then", "once", "here", "there", "when", "where", "why", "how", + "all", "any", "both", "each", "few", "more", "most", "other", "some", "such", "no", + "nor", "not", "only", "own", "same", "so", "than", "too", "very", "s", "t", "can", + "will", "just", "don", "should", "now"}; Arrays.sort(stopwords); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/text/WordNgramsUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/text/WordNgramsUDF.java b/core/src/main/java/hivemall/tools/text/WordNgramsUDF.java index db3435a..fa8308b 100644 --- a/core/src/main/java/hivemall/tools/text/WordNgramsUDF.java +++ b/core/src/main/java/hivemall/tools/text/WordNgramsUDF.java @@ -34,12 +34,10 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -@Description( - name = "word_ngrams", +@Description(name = "word_ngrams", value = "_FUNC_(array<string> words, int minSize, int maxSize])" + " - Returns list of n-grams for given words, where `minSize <= n <= maxSize`", - extended = "select word_ngrams(tokenize('Machine learning is fun!', true), 1, 2);\n" - + "\n" + extended = "select word_ngrams(tokenize('Machine learning is fun!', true), 1, 2);\n" + "\n" + "> [\"machine\",\"machine learning\",\"learning\",\"learning is\",\"is\",\"is fun\",\"fun\"]") @UDFType(deterministic = true, stateful = false) public final class WordNgramsUDF extends UDF { @@ -54,8 +52,8 @@ public final class WordNgramsUDF extends UDF { throw new UDFArgumentException("`minSize` must be greater than zero: " + minSize); } if (minSize > maxSize) { - throw new UDFArgumentException("`maxSize` must be greater than or equal to `minSize`: " - + maxSize); + throw new UDFArgumentException( + "`maxSize` must be greater than or equal to `minSize`: " + maxSize); } return getNgrams(words, minSize, maxSize); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/vector/VectorAddUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/vector/VectorAddUDF.java b/core/src/main/java/hivemall/tools/vector/VectorAddUDF.java index ecff2f4..8442ae3 100644 --- a/core/src/main/java/hivemall/tools/vector/VectorAddUDF.java +++ b/core/src/main/java/hivemall/tools/vector/VectorAddUDF.java @@ -63,10 +63,12 @@ public final class VectorAddUDF extends GenericUDF { if (HiveUtils.isIntegerOI(xElemOI) && HiveUtils.isIntegerOI(yElemOI)) { this.floatingPoints = false; - return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaLongObjectInspector); + return ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaLongObjectInspector); } else { this.floatingPoints = true; - return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector); + return ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaDoubleObjectInspector); } } @@ -82,8 +84,8 @@ public final class VectorAddUDF extends GenericUDF { final int xLen = xOI.getListLength(arg0); final int yLen = yOI.getListLength(arg1); if (xLen != yLen) { - throw new HiveException("vector lengths do not match. x=" + xOI.getList(arg0) + ", y=" - + yOI.getList(arg1)); + throw new HiveException( + "vector lengths do not match. x=" + xOI.getList(arg0) + ", y=" + yOI.getList(arg1)); } if (floatingPoints) { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/tools/vector/VectorDotUDF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/tools/vector/VectorDotUDF.java b/core/src/main/java/hivemall/tools/vector/VectorDotUDF.java index 15568f5..2aa3c03 100644 --- a/core/src/main/java/hivemall/tools/vector/VectorDotUDF.java +++ b/core/src/main/java/hivemall/tools/vector/VectorDotUDF.java @@ -57,8 +57,8 @@ public final class VectorDotUDF extends GenericUDF { ObjectInspector argOI0 = argOIs[0]; if (!HiveUtils.isNumberListOI(argOI0)) { - throw new UDFArgumentException("Expected array<number> for the first argument: " - + argOI0.getTypeName()); + throw new UDFArgumentException( + "Expected array<number> for the first argument: " + argOI0.getTypeName()); } ListObjectInspector xListOI = HiveUtils.asListOI(argOI0); @@ -72,7 +72,8 @@ public final class VectorDotUDF extends GenericUDF { "Expected array<number> or number for the send argument: " + argOI1.getTypeName()); } - return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector); + return ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaDoubleObjectInspector); } @Override http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/topicmodel/IncrementalPLSAModel.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/topicmodel/IncrementalPLSAModel.java b/core/src/main/java/hivemall/topicmodel/IncrementalPLSAModel.java index 6419664..7a95539 100644 --- a/core/src/main/java/hivemall/topicmodel/IncrementalPLSAModel.java +++ b/core/src/main/java/hivemall/topicmodel/IncrementalPLSAModel.java @@ -228,9 +228,8 @@ public final class IncrementalPLSAModel extends AbstractProbabilisticTopicModel } if (p_dw == 0.d) { - throw new IllegalStateException( - "Perplexity would be Infinity. " - + "Try different mini-batch size `-s`, larger `-delta` and/or larger `-alpha`."); + throw new IllegalStateException("Perplexity would be Infinity. " + + "Try different mini-batch size `-s`, larger `-delta` and/or larger `-alpha`."); } numer += w_value * Math.log(p_dw); denom += w_value; @@ -242,8 +241,8 @@ public final class IncrementalPLSAModel extends AbstractProbabilisticTopicModel @Nonnull protected SortedMap<Float, List<String>> getTopicWords(@Nonnegative final int z) { - final SortedMap<Float, List<String>> res = new TreeMap<Float, List<String>>( - Collections.reverseOrder()); + final SortedMap<Float, List<String>> res = + new TreeMap<Float, List<String>>(Collections.reverseOrder()); for (Map.Entry<String, float[]> e : _p_zw.entrySet()) { final String w = e.getKey(); @@ -271,7 +270,8 @@ public final class IncrementalPLSAModel extends AbstractProbabilisticTopicModel return _p_zw.get(w)[z]; } - protected void setWordScore(@Nonnull final String w, @Nonnegative final int z, final float prob) { + protected void setWordScore(@Nonnull final String w, @Nonnegative final int z, + final float prob) { float[] prob_label = _p_zw.get(w); if (prob_label == null) { prob_label = newRandomFloatArray(_K, _rnd); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/topicmodel/LDAPredictUDAF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/topicmodel/LDAPredictUDAF.java b/core/src/main/java/hivemall/topicmodel/LDAPredictUDAF.java index 68c802f..2befec1 100644 --- a/core/src/main/java/hivemall/topicmodel/LDAPredictUDAF.java +++ b/core/src/main/java/hivemall/topicmodel/LDAPredictUDAF.java @@ -74,7 +74,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { if (!HiveUtils.isStringTypeInfo(typeInfo[0])) { throw new UDFArgumentTypeException(0, - "String type is expected for the first argument word: " + typeInfo[0].getTypeName()); + "String type is expected for the first argument word: " + + typeInfo[0].getTypeName()); } if (!HiveUtils.isNumberTypeInfo(typeInfo[1])) { throw new UDFArgumentTypeException(1, @@ -179,16 +180,16 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { String rawArgs = HiveUtils.getConstString(argOIs[4]); cl = parseOptions(rawArgs); - this.topics = Primitives.parseInt(cl.getOptionValue("topics"), - LDAUDTF.DEFAULT_TOPICS); + this.topics = + Primitives.parseInt(cl.getOptionValue("topics"), LDAUDTF.DEFAULT_TOPICS); if (topics < 1) { throw new UDFArgumentException( "A positive integer MUST be set to an option `-topics`: " + topics); } this.alpha = Primitives.parseFloat(cl.getOptionValue("alpha"), 1.f / topics); - this.delta = Primitives.parseDouble(cl.getOptionValue("delta"), - LDAUDTF.DEFAULT_DELTA); + this.delta = + Primitives.parseDouble(cl.getOptionValue("delta"), LDAUDTF.DEFAULT_DELTA); } else { this.topics = LDAUDTF.DEFAULT_TOPICS; this.alpha = 1.f / topics; @@ -221,8 +222,10 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { this.wcListElemOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; this.wcListOI = ObjectInspectorFactory.getStandardListObjectInspector(wcListElemOI); this.lambdaMapKeyOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - this.lambdaMapValueElemOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - this.lambdaMapValueOI = ObjectInspectorFactory.getStandardListObjectInspector(lambdaMapValueElemOI); + this.lambdaMapValueElemOI = + PrimitiveObjectInspectorFactory.javaStringObjectInspector; + this.lambdaMapValueOI = + ObjectInspectorFactory.getStandardListObjectInspector(lambdaMapValueElemOI); this.lambdaMapOI = ObjectInspectorFactory.getStandardMapObjectInspector( lambdaMapKeyOI, lambdaMapValueOI); } @@ -239,8 +242,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { fieldNames.add("probability"); fieldOIs.add(PrimitiveObjectInspectorFactory.writableFloatObjectInspector); - outputOI = ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorFactory.getStandardStructObjectInspector( - fieldNames, fieldOIs)); + outputOI = ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs)); } return outputOI; } @@ -250,12 +253,14 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); fieldNames.add("wcList"); - fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector)); + fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector)); fieldNames.add("lambdaMap"); fieldOIs.add(ObjectInspectorFactory.getStandardMapObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaFloatObjectInspector))); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaFloatObjectInspector))); fieldNames.add("topics"); fieldOIs.add(PrimitiveObjectInspectorFactory.writableIntObjectInspector); @@ -340,7 +345,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { } Object lambdaMapObj = internalMergeOI.getStructFieldData(partial, lambdaMapField); - Map<?, ?> lambdaMapRaw = lambdaMapOI.getMap(HiveUtils.castLazyBinaryObject(lambdaMapObj)); + Map<?, ?> lambdaMapRaw = + lambdaMapOI.getMap(HiveUtils.castLazyBinaryObject(lambdaMapObj)); Map<String, List<Float>> lambdaMap = new HashMap<String, List<Float>>(); for (Map.Entry<?, ?> e : lambdaMapRaw.entrySet()) { @@ -348,14 +354,15 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { String word = PrimitiveObjectInspectorUtils.getString(e.getKey(), lambdaMapKeyOI); Object lambdaMapValueObj = e.getValue(); - List<?> lambdaMapValueRaw = lambdaMapValueOI.getList(HiveUtils.castLazyBinaryObject(lambdaMapValueObj)); + List<?> lambdaMapValueRaw = + lambdaMapValueOI.getList(HiveUtils.castLazyBinaryObject(lambdaMapValueObj)); // fix map values to lists of Java Float objects int lambdaMapValueSize = lambdaMapValueRaw.size(); List<Float> lambda_word = new ArrayList<Float>(); for (int i = 0; i < lambdaMapValueSize; i++) { - lambda_word.add(HiveUtils.getFloat(lambdaMapValueRaw.get(i), - lambdaMapValueElemOI)); + lambda_word.add( + HiveUtils.getFloat(lambdaMapValueRaw.get(i), lambdaMapValueElemOI)); } lambdaMap.put(word, lambda_word); @@ -369,7 +376,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { this.alpha = PrimitiveObjectInspectorFactory.writableFloatObjectInspector.get(alphaObj); Object deltaObj = internalMergeOI.getStructFieldData(partial, deltaOptionField); - this.delta = PrimitiveObjectInspectorFactory.writableDoubleObjectInspector.get(deltaObj); + this.delta = + PrimitiveObjectInspectorFactory.writableDoubleObjectInspector.get(deltaObj); OnlineLDAPredictAggregationBuffer myAggr = (OnlineLDAPredictAggregationBuffer) agg; myAggr.setOptions(topics, alpha, delta); @@ -382,8 +390,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { OnlineLDAPredictAggregationBuffer myAggr = (OnlineLDAPredictAggregationBuffer) agg; float[] topicDistr = myAggr.get(); - SortedMap<Float, Integer> sortedDistr = new TreeMap<Float, Integer>( - Collections.reverseOrder()); + SortedMap<Float, Integer> sortedDistr = + new TreeMap<Float, Integer>(Collections.reverseOrder()); for (int i = 0; i < topicDistr.length; i++) { sortedDistr.put(topicDistr[i], i); } @@ -400,8 +408,8 @@ public final class LDAPredictUDAF extends AbstractGenericUDAFResolver { } - public static class OnlineLDAPredictAggregationBuffer extends - GenericUDAFEvaluator.AbstractAggregationBuffer { + public static class OnlineLDAPredictAggregationBuffer + extends GenericUDAFEvaluator.AbstractAggregationBuffer { private List<String> wcList; private Map<String, List<Float>> lambdaMap; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/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 9bac908..4cbd964 100644 --- a/core/src/main/java/hivemall/topicmodel/LDAUDTF.java +++ b/core/src/main/java/hivemall/topicmodel/LDAUDTF.java @@ -59,7 +59,8 @@ public final class LDAUDTF extends ProbabilisticTopicModelBaseUDTF { opts.addOption("d", "num_docs", true, "The total number of documents [default: auto]"); opts.addOption("tau", "tau0", true, "The parameter which downweights early iterations [default: 64.0]"); - opts.addOption("kappa", true, "Exponential decay rate (i.e., learning rate) [default: 0.7]"); + opts.addOption("kappa", true, + "Exponential decay rate (i.e., learning rate) [default: 0.7]"); opts.addOption("delta", true, "Check convergence in the expectation step [default: 1E-3]"); return opts; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java b/core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java index 14b6ef4..aed17ba 100644 --- a/core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java +++ b/core/src/main/java/hivemall/topicmodel/OnlineLDAModel.java @@ -332,8 +332,8 @@ public final class OnlineLDAModel extends AbstractProbabilisticTopicModel { } for (int k = 0; k < _K; k++) { - lambda_label[k] = (float) ((1.d - _rhot) * lambda_label[k] + _rhot - * lambdaTilde_label[k]); + lambda_label[k] = + (float) ((1.d - _rhot) * lambda_label[k] + _rhot * lambdaTilde_label[k]); } } } @@ -444,8 +444,8 @@ public final class OnlineLDAModel extends AbstractProbabilisticTopicModel { throw new IllegalArgumentException("Word `" + label + "` is not in the corpus."); } if (k >= lambda_label.length) { - throw new IllegalArgumentException("Topic index must be in [0, " - + _lambda.get(label).length + "]"); + throw new IllegalArgumentException( + "Topic index must be in [0, " + _lambda.get(label).length + "]"); } return lambda_label[k]; } @@ -469,8 +469,8 @@ public final class OnlineLDAModel extends AbstractProbabilisticTopicModel { public SortedMap<Float, List<String>> getTopicWords(@Nonnegative final int k, @Nonnegative int topN) { double lambdaSum = 0.d; - final SortedMap<Float, List<String>> sortedLambda = new TreeMap<Float, List<String>>( - Collections.reverseOrder()); + final SortedMap<Float, List<String>> sortedLambda = + new TreeMap<Float, List<String>>(Collections.reverseOrder()); for (Map.Entry<String, float[]> e : _lambda.entrySet()) { final float lambda_k = e.getValue()[k]; @@ -484,8 +484,8 @@ public final class OnlineLDAModel extends AbstractProbabilisticTopicModel { labels.add(e.getKey()); } - final SortedMap<Float, List<String>> ret = new TreeMap<Float, List<String>>( - Collections.reverseOrder()); + final SortedMap<Float, List<String>> ret = + new TreeMap<Float, List<String>>(Collections.reverseOrder()); topN = Math.min(topN, _lambda.keySet().size()); int tt = 0; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/topicmodel/PLSAPredictUDAF.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/topicmodel/PLSAPredictUDAF.java b/core/src/main/java/hivemall/topicmodel/PLSAPredictUDAF.java index 6210359..d9df347 100644 --- a/core/src/main/java/hivemall/topicmodel/PLSAPredictUDAF.java +++ b/core/src/main/java/hivemall/topicmodel/PLSAPredictUDAF.java @@ -75,7 +75,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { if (!HiveUtils.isStringTypeInfo(typeInfo[0])) { throw new UDFArgumentTypeException(0, - "String type is expected for the first argument word: " + typeInfo[0].getTypeName()); + "String type is expected for the first argument word: " + + typeInfo[0].getTypeName()); } if (!HiveUtils.isNumberTypeInfo(typeInfo[1])) { throw new UDFArgumentTypeException(1, @@ -89,7 +90,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { } if (!HiveUtils.isNumberTypeInfo(typeInfo[3])) { throw new UDFArgumentTypeException(3, - "Number type is expected for the forth argument prob: " + typeInfo[3].getTypeName()); + "Number type is expected for the forth argument prob: " + + typeInfo[3].getTypeName()); } if (typeInfo.length == 5) { @@ -180,17 +182,17 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { String rawArgs = HiveUtils.getConstString(argOIs[4]); cl = parseOptions(rawArgs); - this.topics = Primitives.parseInt(cl.getOptionValue("topics"), - PLSAUDTF.DEFAULT_TOPICS); + this.topics = + Primitives.parseInt(cl.getOptionValue("topics"), PLSAUDTF.DEFAULT_TOPICS); if (topics < 1) { throw new UDFArgumentException( "A positive integer MUST be set to an option `-topics`: " + topics); } - this.alpha = Primitives.parseFloat(cl.getOptionValue("alpha"), - PLSAUDTF.DEFAULT_ALPHA); - this.delta = Primitives.parseDouble(cl.getOptionValue("delta"), - PLSAUDTF.DEFAULT_DELTA); + this.alpha = + Primitives.parseFloat(cl.getOptionValue("alpha"), PLSAUDTF.DEFAULT_ALPHA); + this.delta = + Primitives.parseDouble(cl.getOptionValue("delta"), PLSAUDTF.DEFAULT_DELTA); } else { this.topics = PLSAUDTF.DEFAULT_TOPICS; this.alpha = PLSAUDTF.DEFAULT_ALPHA; @@ -224,7 +226,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { this.wcListOI = ObjectInspectorFactory.getStandardListObjectInspector(wcListElemOI); this.probMapKeyOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; this.probMapValueElemOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - this.probMapValueOI = ObjectInspectorFactory.getStandardListObjectInspector(probMapValueElemOI); + this.probMapValueOI = + ObjectInspectorFactory.getStandardListObjectInspector(probMapValueElemOI); this.probMapOI = ObjectInspectorFactory.getStandardMapObjectInspector(probMapKeyOI, probMapValueOI); } @@ -241,8 +244,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { fieldNames.add("probability"); fieldOIs.add(PrimitiveObjectInspectorFactory.writableFloatObjectInspector); - outputOI = ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorFactory.getStandardStructObjectInspector( - fieldNames, fieldOIs)); + outputOI = ObjectInspectorFactory.getStandardListObjectInspector( + ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs)); } return outputOI; } @@ -252,12 +255,14 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); fieldNames.add("wcList"); - fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector)); + fieldOIs.add(ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector)); fieldNames.add("probMap"); fieldOIs.add(ObjectInspectorFactory.getStandardMapObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaFloatObjectInspector))); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaFloatObjectInspector))); fieldNames.add("topics"); fieldOIs.add(PrimitiveObjectInspectorFactory.writableIntObjectInspector); @@ -350,7 +355,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { String word = PrimitiveObjectInspectorUtils.getString(e.getKey(), probMapKeyOI); Object probMapValueObj = e.getValue(); - List<?> probMapValueRaw = probMapValueOI.getList(HiveUtils.castLazyBinaryObject(probMapValueObj)); + List<?> probMapValueRaw = + probMapValueOI.getList(HiveUtils.castLazyBinaryObject(probMapValueObj)); // fix map values to lists of Java Float objects int probMapValueSize = probMapValueRaw.size(); @@ -370,7 +376,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { this.alpha = PrimitiveObjectInspectorFactory.writableFloatObjectInspector.get(alphaObj); Object deltaObj = internalMergeOI.getStructFieldData(partial, deltaOptionField); - this.delta = PrimitiveObjectInspectorFactory.writableDoubleObjectInspector.get(deltaObj); + this.delta = + PrimitiveObjectInspectorFactory.writableDoubleObjectInspector.get(deltaObj); PLSAPredictAggregationBuffer myAggr = (PLSAPredictAggregationBuffer) agg; myAggr.setOptions(topics, alpha, delta); @@ -383,8 +390,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { PLSAPredictAggregationBuffer myAggr = (PLSAPredictAggregationBuffer) agg; float[] topicDistr = myAggr.get(); - SortedMap<Float, Integer> sortedDistr = new TreeMap<Float, Integer>( - Collections.reverseOrder()); + SortedMap<Float, Integer> sortedDistr = + new TreeMap<Float, Integer>(Collections.reverseOrder()); for (int i = 0; i < topicDistr.length; i++) { sortedDistr.put(topicDistr[i], i); } @@ -401,8 +408,8 @@ public final class PLSAPredictUDAF extends AbstractGenericUDAFResolver { } - public static class PLSAPredictAggregationBuffer extends - GenericUDAFEvaluator.AbstractAggregationBuffer { + public static class PLSAPredictAggregationBuffer + extends GenericUDAFEvaluator.AbstractAggregationBuffer { private List<String> wcList; private Map<String, List<Float>> probMap; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/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 c7c6b15..33d940d 100644 --- a/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java +++ b/core/src/main/java/hivemall/topicmodel/ProbabilisticTopicModelBaseUDTF.java @@ -92,7 +92,8 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { protected Options getOptions() { Options opts = new Options(); opts.addOption("k", "topics", true, "The number of topics [default: 10]"); - opts.addOption("iter", "iterations", true, "The maximum number of iterations [default: 10]"); + opts.addOption("iter", "iterations", true, + "The maximum number of iterations [default: 10]"); opts.addOption("eps", "epsilon", true, "Check convergence based on the difference of perplexity [default: 1E-1]"); opts.addOption("s", "mini_batch_size", true, @@ -196,8 +197,8 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { file = File.createTempFile("hivemall_topicmodel", ".sgmt"); file.deleteOnExit(); if (!file.canWrite()) { - throw new UDFArgumentException("Cannot write a temporary file: " - + file.getAbsolutePath()); + throw new UDFArgumentException( + "Cannot write a temporary file: " + file.getAbsolutePath()); } logger.info("Record training samples to a file: " + file.getAbsolutePath()); } catch (IOException ioe) { @@ -300,8 +301,9 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { } final Reporter reporter = getReporter(); - final Counters.Counter iterCounter = (reporter == null) ? null : reporter.getCounter( - "hivemall.topicmodel.ProbabilisticTopicModel$Counter", "iteration"); + final Counters.Counter iterCounter = (reporter == null) ? null + : reporter.getCounter("hivemall.topicmodel.ProbabilisticTopicModel$Counter", + "iteration"); try { if (dst.getPosition() == 0L) {// run iterations w/o temporary file @@ -339,9 +341,7 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { break; } } - logger.info("Performed " - + Math.min(iter, iterations) - + " iterations of " + logger.info("Performed " + Math.min(iter, iterations) + " iterations of " + NumberUtils.formatNumber(numTrainingExamples) + " training examples on memory (thus " + NumberUtils.formatNumber(numTrainingExamples * Math.min(iter, iterations)) @@ -354,8 +354,8 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { try { dst.flush(); } catch (IOException e) { - throw new HiveException("Failed to flush a file: " - + dst.getFile().getAbsolutePath(), e); + throw new HiveException( + "Failed to flush a file: " + dst.getFile().getAbsolutePath(), e); } if (logger.isInfoEnabled()) { File tmpFile = dst.getFile(); @@ -385,8 +385,8 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { try { bytesRead = dst.read(buf); } catch (IOException e) { - throw new HiveException("Failed to read a file: " - + dst.getFile().getAbsolutePath(), e); + throw new HiveException( + "Failed to read a file: " + dst.getFile().getAbsolutePath(), e); } if (bytesRead == 0) { // reached file EOF break; @@ -427,9 +427,7 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { break; } } - logger.info("Performed " - + Math.min(iter, iterations) - + " iterations of " + logger.info("Performed " + Math.min(iter, iterations) + " iterations of " + NumberUtils.formatNumber(numTrainingExamples) + " training examples on a secondary storage (thus " + NumberUtils.formatNumber(numTrainingExamples * Math.min(iter, iterations)) @@ -442,8 +440,8 @@ public abstract class ProbabilisticTopicModelBaseUDTF extends UDTFWithOptions { try { dst.close(true); } catch (IOException e) { - throw new HiveException("Failed to close a file: " - + dst.getFile().getAbsolutePath(), e); + throw new HiveException( + "Failed to close a file: " + dst.getFile().getAbsolutePath(), e); } this.inputBuf = null; this.fileIO = null; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/buffer/DynamicByteArray.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/buffer/DynamicByteArray.java b/core/src/main/java/hivemall/utils/buffer/DynamicByteArray.java index 2d91870..51046d1 100644 --- a/core/src/main/java/hivemall/utils/buffer/DynamicByteArray.java +++ b/core/src/main/java/hivemall/utils/buffer/DynamicByteArray.java @@ -73,8 +73,8 @@ public final class DynamicByteArray { public byte get(final int index) { if (index >= length) { - throw new IndexOutOfBoundsException("Index " + index + " is outside of 0.." - + (length - 1)); + throw new IndexOutOfBoundsException( + "Index " + index + " is outside of 0.." + (length - 1)); } int i = index / chunkSize; int j = index % chunkSize; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/buffer/HeapBuffer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/buffer/HeapBuffer.java b/core/src/main/java/hivemall/utils/buffer/HeapBuffer.java index 10051a9..59cd8d6 100644 --- a/core/src/main/java/hivemall/utils/buffer/HeapBuffer.java +++ b/core/src/main/java/hivemall/utils/buffer/HeapBuffer.java @@ -136,8 +136,8 @@ public final class HeapBuffer { private void validatePointer(final long ptr) { if (ptr >= _position) { - throw new IllegalArgumentException("Invalid pointer " + ptr + " does not in range [0," - + _position + ')'); + throw new IllegalArgumentException( + "Invalid pointer " + ptr + " does not in range [0," + _position + ')'); } } @@ -288,8 +288,8 @@ public final class HeapBuffer { private void validateOffset(final long offset) { if (offset >= _chunkBytes) { - throw new IndexOutOfBoundsException("Invalid offset " + offset + " not in range [0," - + _chunkBytes + ')'); + throw new IndexOutOfBoundsException( + "Invalid offset " + offset + " not in range [0," + _chunkBytes + ')'); } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/Fastutil.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/Fastutil.java b/core/src/main/java/hivemall/utils/collections/Fastutil.java index 0ef1c21..c6ace89 100644 --- a/core/src/main/java/hivemall/utils/collections/Fastutil.java +++ b/core/src/main/java/hivemall/utils/collections/Fastutil.java @@ -38,22 +38,24 @@ public final class Fastutil { @Nonnull public static ObjectIterable<Int2LongMap.Entry> fastIterable(@Nonnull final Int2LongMap map) { final ObjectSet<Int2LongMap.Entry> entries = map.int2LongEntrySet(); - return entries instanceof Int2LongMap.FastEntrySet ? new ObjectIterable<Int2LongMap.Entry>() { - public ObjectIterator<Int2LongMap.Entry> iterator() { - return ((Int2LongMap.FastEntrySet) entries).fastIterator(); - } - } + return entries instanceof Int2LongMap.FastEntrySet + ? new ObjectIterable<Int2LongMap.Entry>() { + public ObjectIterator<Int2LongMap.Entry> iterator() { + return ((Int2LongMap.FastEntrySet) entries).fastIterator(); + } + } : entries; } @Nonnull public static ObjectIterable<Int2FloatMap.Entry> fastIterable(@Nonnull final Int2FloatMap map) { final ObjectSet<Int2FloatMap.Entry> entries = map.int2FloatEntrySet(); - return entries instanceof Int2FloatMap.FastEntrySet ? new ObjectIterable<Int2FloatMap.Entry>() { - public ObjectIterator<Int2FloatMap.Entry> iterator() { - return ((Int2FloatMap.FastEntrySet) entries).fastIterator(); - } - } + return entries instanceof Int2FloatMap.FastEntrySet + ? new ObjectIterable<Int2FloatMap.Entry>() { + public ObjectIterator<Int2FloatMap.Entry> iterator() { + return ((Int2FloatMap.FastEntrySet) entries).fastIterator(); + } + } : entries; } @@ -61,11 +63,12 @@ public final class Fastutil { public static <V> ObjectIterable<Int2ObjectMap.Entry<V>> fastIterable( @Nonnull final Int2ObjectMap<V> map) { final ObjectSet<Int2ObjectMap.Entry<V>> entries = map.int2ObjectEntrySet(); - return entries instanceof Int2ObjectMap.FastEntrySet ? new ObjectIterable<Int2ObjectMap.Entry<V>>() { - public ObjectIterator<Int2ObjectMap.Entry<V>> iterator() { - return ((Int2ObjectMap.FastEntrySet<V>) entries).fastIterator(); - } - } + return entries instanceof Int2ObjectMap.FastEntrySet + ? new ObjectIterable<Int2ObjectMap.Entry<V>>() { + public ObjectIterator<Int2ObjectMap.Entry<V>> iterator() { + return ((Int2ObjectMap.FastEntrySet<V>) entries).fastIterator(); + } + } : entries; } @@ -73,12 +76,13 @@ public final class Fastutil { public static <K, V> ObjectIterable<Object2ObjectMap.Entry<K, V>> fastIterable( @Nonnull final Object2ObjectMap<K, V> map) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); - return entries instanceof Object2ObjectMap.FastEntrySet ? new ObjectIterable<Object2ObjectMap.Entry<K, V>>() { - @SuppressWarnings("unchecked") - public ObjectIterator<Object2ObjectMap.Entry<K, V>> iterator() { - return ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator(); - } - } + return entries instanceof Object2ObjectMap.FastEntrySet + ? new ObjectIterable<Object2ObjectMap.Entry<K, V>>() { + @SuppressWarnings("unchecked") + public ObjectIterator<Object2ObjectMap.Entry<K, V>> iterator() { + return ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator(); + } + } : entries; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/arrays/DoubleArray3D.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/arrays/DoubleArray3D.java b/core/src/main/java/hivemall/utils/collections/arrays/DoubleArray3D.java index b7c5590..39e9021 100644 --- a/core/src/main/java/hivemall/utils/collections/arrays/DoubleArray3D.java +++ b/core/src/main/java/hivemall/utils/collections/arrays/DoubleArray3D.java @@ -111,21 +111,22 @@ public final class DoubleArray3D { throw new IllegalStateException("Double3DArray#configure() is not called"); } if (i >= n1 || i < 0) { - throw new ArrayIndexOutOfBoundsException("Index '" + i - + "' out of bounds for 1st dimension of size " + n1); + throw new ArrayIndexOutOfBoundsException( + "Index '" + i + "' out of bounds for 1st dimension of size " + n1); } if (j >= n2 || j < 0) { - throw new ArrayIndexOutOfBoundsException("Index '" + j - + "' out of bounds for 2nd dimension of size " + n2); + throw new ArrayIndexOutOfBoundsException( + "Index '" + j + "' out of bounds for 2nd dimension of size " + n2); } if (k >= n3 || k < 0) { - throw new ArrayIndexOutOfBoundsException("Index '" + k - + "' out of bounds for 3rd dimension of size " + n3); + throw new ArrayIndexOutOfBoundsException( + "Index '" + k + "' out of bounds for 3rd dimension of size " + n3); } final int idx = i * p1 + j * p2 + k; if (idx >= size) { - throw new IndexOutOfBoundsException("Computed internal index '" + idx - + "' exceeds buffer size '" + size + "' where i=" + i + ", j=" + j + ", k=" + k); + throw new IndexOutOfBoundsException( + "Computed internal index '" + idx + "' exceeds buffer size '" + size + "' where i=" + + i + ", j=" + j + ", k=" + k); } return idx; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/lists/IntArrayList.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/lists/IntArrayList.java b/core/src/main/java/hivemall/utils/collections/lists/IntArrayList.java index ea17c5f..fed61cc 100644 --- a/core/src/main/java/hivemall/utils/collections/lists/IntArrayList.java +++ b/core/src/main/java/hivemall/utils/collections/lists/IntArrayList.java @@ -101,8 +101,8 @@ public final class IntArrayList implements Serializable { public void set(final int index, final int value) { if (index > used) { - throw new IllegalArgumentException("Index " + index + " MUST be less than size() " - + used); + throw new IllegalArgumentException( + "Index " + index + " MUST be less than size() " + used); } else if (index == used) { ++used; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/maps/Long2DoubleOpenHashTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/maps/Long2DoubleOpenHashTable.java b/core/src/main/java/hivemall/utils/collections/maps/Long2DoubleOpenHashTable.java index 84eac5f..765cd30 100644 --- a/core/src/main/java/hivemall/utils/collections/maps/Long2DoubleOpenHashTable.java +++ b/core/src/main/java/hivemall/utils/collections/maps/Long2DoubleOpenHashTable.java @@ -180,8 +180,8 @@ public final class Long2DoubleOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } state = states[keyIdx]; @@ -256,8 +256,8 @@ public final class Long2DoubleOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == startIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } } } @@ -338,8 +338,8 @@ public final class Long2DoubleOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (newStates[keyIdx] != FREE); } @@ -461,8 +461,8 @@ public final class Long2DoubleOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (states[keyIdx] != FREE); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/maps/Long2FloatOpenHashTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/maps/Long2FloatOpenHashTable.java b/core/src/main/java/hivemall/utils/collections/maps/Long2FloatOpenHashTable.java index ca8c4ee..0bf5319 100644 --- a/core/src/main/java/hivemall/utils/collections/maps/Long2FloatOpenHashTable.java +++ b/core/src/main/java/hivemall/utils/collections/maps/Long2FloatOpenHashTable.java @@ -178,8 +178,8 @@ public final class Long2FloatOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } state = states[keyIdx]; @@ -254,8 +254,8 @@ public final class Long2FloatOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == startIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } } } @@ -336,8 +336,8 @@ public final class Long2FloatOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (newStates[keyIdx] != FREE); } @@ -459,8 +459,8 @@ public final class Long2FloatOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (states[keyIdx] != FREE); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/maps/Long2IntOpenHashTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/maps/Long2IntOpenHashTable.java b/core/src/main/java/hivemall/utils/collections/maps/Long2IntOpenHashTable.java index 360e806..4fb61bf 100644 --- a/core/src/main/java/hivemall/utils/collections/maps/Long2IntOpenHashTable.java +++ b/core/src/main/java/hivemall/utils/collections/maps/Long2IntOpenHashTable.java @@ -68,7 +68,8 @@ public final class Long2IntOpenHashTable implements Externalizable { protected int[] _values; protected byte[] _states; - protected Long2IntOpenHashTable(int size, float loadFactor, float growFactor, boolean forcePrime) { + protected Long2IntOpenHashTable(int size, float loadFactor, float growFactor, + boolean forcePrime) { if (size < 1) { throw new IllegalArgumentException(); } @@ -161,8 +162,8 @@ public final class Long2IntOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } state = states[keyIdx]; @@ -228,8 +229,8 @@ public final class Long2IntOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } state = states[keyIdx]; @@ -304,8 +305,8 @@ public final class Long2IntOpenHashTable implements Externalizable { keyIdx += keyLength; } if (keyIdx == startIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } } } @@ -387,8 +388,8 @@ public final class Long2IntOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (newStates[keyIdx] != FREE); } @@ -508,8 +509,8 @@ public final class Long2IntOpenHashTable implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (states[keyIdx] != FREE); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/collections/maps/OpenHashTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/collections/maps/OpenHashTable.java b/core/src/main/java/hivemall/utils/collections/maps/OpenHashTable.java index 28a677e..599a70e 100644 --- a/core/src/main/java/hivemall/utils/collections/maps/OpenHashTable.java +++ b/core/src/main/java/hivemall/utils/collections/maps/OpenHashTable.java @@ -157,8 +157,8 @@ public final class OpenHashTable<K, V> implements Externalizable { keyIdx += keyLength; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } state = states[keyIdx]; @@ -237,8 +237,8 @@ public final class OpenHashTable<K, V> implements Externalizable { keyIdx += keyLength; } if (keyIdx == startIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + key - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + key + ", keyIdx=" + keyIdx); } } } @@ -325,8 +325,8 @@ public final class OpenHashTable<K, V> implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (newStates[keyIdx] != FREE); } @@ -452,8 +452,8 @@ public final class OpenHashTable<K, V> implements Externalizable { keyIdx += newCapacity; } if (keyIdx == loopIndex) { - throw new IllegalStateException("Detected infinite loop where key=" + k - + ", keyIdx=" + keyIdx); + throw new IllegalStateException( + "Detected infinite loop where key=" + k + ", keyIdx=" + keyIdx); } } while (states[keyIdx] != FREE); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/geospatial/GeoSpatialUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/geospatial/GeoSpatialUtils.java b/core/src/main/java/hivemall/utils/geospatial/GeoSpatialUtils.java index fdccc95..5bc1d1e 100644 --- a/core/src/main/java/hivemall/utils/geospatial/GeoSpatialUtils.java +++ b/core/src/main/java/hivemall/utils/geospatial/GeoSpatialUtils.java @@ -96,8 +96,8 @@ public final class GeoSpatialUtils { double dLon = toRadians(lon2 - lon1); double sinDLat = sin(dLat / 2.d); double sinDLon = sin(dLon / 2.d); - double a = sinDLat * sinDLat + cos(toRadians(lat1)) * cos(toRadians(lat2)) * sinDLon - * sinDLon; + double a = + sinDLat * sinDLat + cos(toRadians(lat1)) * cos(toRadians(lat2)) * sinDLon * sinDLon; double c = 2.d * atan2(sqrt(a), sqrt(1.d - a)); return R * c; // Distance in Km }
