http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java b/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java index cbb1989..f3fe703 100644 --- a/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java +++ b/core/src/main/java/hivemall/utils/hadoop/HiveUtils.java @@ -105,8 +105,8 @@ public final class HiveUtils { if (o instanceof LongWritable) { long l = ((LongWritable) o).get(); if (l > 0x7fffffffL) { - throw new IllegalArgumentException("feature index must be less than " - + Integer.MAX_VALUE + ", but was " + l); + throw new IllegalArgumentException( + "feature index must be less than " + Integer.MAX_VALUE + ", but was " + l); } return (int) l; } @@ -503,8 +503,8 @@ public final class HiveUtils { } ConstantObjectInspector constOI = (ConstantObjectInspector) oi; if (constOI.getCategory() != Category.LIST) { - throw new UDFArgumentException("argument must be an array: " - + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); + throw new UDFArgumentException( + "argument must be an array: " + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); } final List<?> lst = (List<?>) constOI.getWritableConstantValue(); if (lst == null) { @@ -530,11 +530,12 @@ public final class HiveUtils { } ConstantObjectInspector constOI = (ConstantObjectInspector) oi; if (constOI.getCategory() != Category.LIST) { - throw new UDFArgumentException("argument must be an array: " - + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); + throw new UDFArgumentException( + "argument must be an array: " + TypeInfoUtils.getTypeInfoFromObjectInspector(oi)); } StandardConstantListObjectInspector listOI = (StandardConstantListObjectInspector) constOI; - PrimitiveObjectInspector elemOI = HiveUtils.asDoubleCompatibleOI(listOI.getListElementObjectInspector()); + PrimitiveObjectInspector elemOI = + HiveUtils.asDoubleCompatibleOI(listOI.getListElementObjectInspector()); final List<?> lst = listOI.getWritableConstantValue(); if (lst == null) { @@ -795,8 +796,8 @@ public final class HiveUtils { } final int length = listOI.getListLength(argObj); if (out.length != length) { - throw new UDFArgumentException("Dimension mismatched. Expected: " + out.length - + ", Actual: " + length); + throw new UDFArgumentException( + "Dimension mismatched. Expected: " + out.length + ", Actual: " + length); } for (int i = 0; i < length; i++) { Object o = listOI.getListElement(argObj, i); @@ -821,8 +822,8 @@ public final class HiveUtils { } final int length = listOI.getListLength(argObj); if (out.length != length) { - throw new UDFArgumentException("Dimension mismatched. Expected: " + out.length - + ", Actual: " + length); + throw new UDFArgumentException( + "Dimension mismatched. Expected: " + out.length + ", Actual: " + length); } for (int i = 0; i < length; i++) { Object o = listOI.getListElement(argObj, i); @@ -957,8 +958,8 @@ public final class HiveUtils { case STRING: break; default: - throw new UDFArgumentTypeException(0, "Unexpected type '" + argOI.getTypeName() - + "' is passed."); + throw new UDFArgumentTypeException(0, + "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; } @@ -984,8 +985,8 @@ public final class HiveUtils { case TIMESTAMP: break; default: - throw new UDFArgumentTypeException(0, "Unexpected type '" + argOI.getTypeName() - + "' is passed."); + throw new UDFArgumentTypeException(0, + "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; } @@ -1005,15 +1006,15 @@ public final class HiveUtils { case BYTE: break; default: - throw new UDFArgumentTypeException(0, "Unexpected type '" + argOI.getTypeName() - + "' is passed."); + throw new UDFArgumentTypeException(0, + "Unexpected type '" + argOI.getTypeName() + "' is passed."); } return oi; } @Nonnull - public static PrimitiveObjectInspector asDoubleCompatibleOI(@Nonnull final ObjectInspector argOI) - throws UDFArgumentTypeException { + public static PrimitiveObjectInspector asDoubleCompatibleOI( + @Nonnull final ObjectInspector argOI) throws UDFArgumentTypeException { if (argOI.getCategory() != Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but " + argOI.getTypeName() + " is passed."); @@ -1176,8 +1177,8 @@ public final class HiveUtils { @Nonnull public static LazyString lazyString(@Nonnull final String str, final byte escapeChar) { - LazyStringObjectInspector oi = LazyPrimitiveObjectInspectorFactory.getLazyStringObjectInspector( - false, escapeChar); + LazyStringObjectInspector oi = + LazyPrimitiveObjectInspectorFactory.getLazyStringObjectInspector(false, escapeChar); return lazyString(str, oi); } @@ -1194,15 +1195,16 @@ public final class HiveUtils { @Nonnull public static LazyInteger lazyInteger(@Nonnull final int v) { - LazyInteger lazy = new LazyInteger( - LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR); + LazyInteger lazy = + new LazyInteger(LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR); lazy.getWritableObject().set(v); return lazy; } @Nonnull public static LazyLong lazyLong(@Nonnull final long v) { - LazyLong lazy = new LazyLong(LazyPrimitiveObjectInspectorFactory.LAZY_LONG_OBJECT_INSPECTOR); + LazyLong lazy = + new LazyLong(LazyPrimitiveObjectInspectorFactory.LAZY_LONG_OBJECT_INSPECTOR); lazy.getWritableObject().set(v); return lazy; }
http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/hadoop/JsonSerdeUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/hadoop/JsonSerdeUtils.java b/core/src/main/java/hivemall/utils/hadoop/JsonSerdeUtils.java index 34932bd..1315537 100644 --- a/core/src/main/java/hivemall/utils/hadoop/JsonSerdeUtils.java +++ b/core/src/main/java/hivemall/utils/hadoop/JsonSerdeUtils.java @@ -127,9 +127,9 @@ public final class JsonSerdeUtils { /** * Serialize Hive objects as Text. */ - private static void serializeStruct(@Nonnull final StringBuilder sb, - @Nullable final Object obj, @Nonnull final StructObjectInspector soi, - @Nullable final List<String> columnNames) throws SerDeException { + private static void serializeStruct(@Nonnull final StringBuilder sb, @Nullable final Object obj, + @Nonnull final StructObjectInspector soi, @Nullable final List<String> columnNames) + throws SerDeException { if (obj == null) { sb.append("null"); } else { @@ -273,7 +273,8 @@ public final class JsonSerdeUtils { break; } case STRING: { - String s = SerDeUtils.escapeString(((StringObjectInspector) poi).getPrimitiveJavaObject(obj)); + String s = SerDeUtils.escapeString( + ((StringObjectInspector) poi).getPrimitiveJavaObject(obj)); appendWithQuotes(sb, s); break; } @@ -296,30 +297,28 @@ public final class JsonSerdeUtils { sb.append(((HiveDecimalObjectInspector) poi).getPrimitiveJavaObject(obj)); break; case VARCHAR: { - String s = SerDeUtils.escapeString(((HiveVarcharObjectInspector) poi).getPrimitiveJavaObject( - obj) - .toString()); + String s = SerDeUtils.escapeString( + ((HiveVarcharObjectInspector) poi).getPrimitiveJavaObject(obj).toString()); appendWithQuotes(sb, s); break; } case CHAR: { //this should use HiveChar.getPaddedValue() but it's protected; currently (v0.13) // HiveChar.toString() returns getPaddedValue() - String s = SerDeUtils.escapeString(((HiveCharObjectInspector) poi).getPrimitiveJavaObject( - obj) - .toString()); + String s = SerDeUtils.escapeString( + ((HiveCharObjectInspector) poi).getPrimitiveJavaObject(obj).toString()); appendWithQuotes(sb, s); break; } default: - throw new SerDeException("Unknown primitive type: " - + poi.getPrimitiveCategory()); + throw new SerDeException( + "Unknown primitive type: " + poi.getPrimitiveCategory()); } } } - private static void buildJSONString(@Nonnull final StringBuilder sb, - @Nullable final Object obj, @Nonnull final ObjectInspector oi) throws SerDeException { + private static void buildJSONString(@Nonnull final StringBuilder sb, @Nullable final Object obj, + @Nonnull final ObjectInspector oi) throws SerDeException { switch (oi.getCategory()) { case PRIMITIVE: { PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi; @@ -376,13 +375,12 @@ public final class JsonSerdeUtils { @SuppressWarnings("unchecked") @Nonnull - public static <T> T deserialize(@Nonnull final Text t, - @Nullable final List<String> columnNames, @Nullable final List<TypeInfo> columnTypes) - throws SerDeException { + public static <T> T deserialize(@Nonnull final Text t, @Nullable final List<String> columnNames, + @Nullable final List<TypeInfo> columnTypes) throws SerDeException { final Object result; try { - JsonParser p = new JsonFactory().createJsonParser(new FastByteArrayInputStream( - t.getBytes())); + JsonParser p = + new JsonFactory().createJsonParser(new FastByteArrayInputStream(t.getBytes())); final JsonToken token = p.nextToken(); if (token == JsonToken.START_OBJECT) { result = parseObject(p, columnNames, columnTypes); @@ -402,8 +400,8 @@ public final class JsonSerdeUtils { @Nonnull private static Object parseObject(@Nonnull final JsonParser p, @CheckForNull final List<String> columnNames, - @CheckForNull final List<TypeInfo> columnTypes) throws JsonParseException, IOException, - SerDeException { + @CheckForNull final List<TypeInfo> columnTypes) + throws JsonParseException, IOException, SerDeException { Preconditions.checkNotNull(columnNames, "columnNames MUST NOT be null in parseObject", SerDeException.class); Preconditions.checkNotNull(columnTypes, "columnTypes MUST NOT be null in parseObject", @@ -437,8 +435,8 @@ public final class JsonSerdeUtils { @Nonnull private static List<Object> parseArray(@Nonnull final JsonParser p, - @CheckForNull final List<TypeInfo> columnTypes) throws HCatException, IOException, - SerDeException { + @CheckForNull final List<TypeInfo> columnTypes) + throws HCatException, IOException, SerDeException { Preconditions.checkNotNull(columnTypes, "columnTypes MUST NOT be null", SerDeException.class); if (columnTypes.size() != 1) { @@ -459,8 +457,8 @@ public final class JsonSerdeUtils { } @Nonnull - private static Object parseValue(@Nonnull final JsonParser p) throws JsonParseException, - IOException { + private static Object parseValue(@Nonnull final JsonParser p) + throws JsonParseException, IOException { final JsonToken t = p.getCurrentToken(); switch (t) { case VALUE_FALSE: @@ -481,8 +479,8 @@ public final class JsonSerdeUtils { } private static void populateRecord(@Nonnull final List<Object> r, - @Nonnull final JsonToken token, @Nonnull final JsonParser p, @Nonnull final HCatSchema s) - throws IOException { + @Nonnull final JsonToken token, @Nonnull final JsonParser p, + @Nonnull final HCatSchema s) throws IOException { if (token != JsonToken.FIELD_NAME) { throw new IOException("Field name expected"); } @@ -577,8 +575,8 @@ public final class JsonSerdeUtils { break; case VARCHAR: int vLen = ((BaseCharTypeInfo) hcatFieldSchema.getTypeInfo()).getLength(); - val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveVarchar(p.getText(), - vLen); + val = (valueToken == JsonToken.VALUE_NULL) ? null + : new HiveVarchar(p.getText(), vLen); break; case CHAR: int cLen = ((BaseCharTypeInfo) hcatFieldSchema.getTypeInfo()).getLength(); @@ -678,8 +676,8 @@ public final class JsonSerdeUtils { case CHAR: return new HiveChar(s, ((BaseCharTypeInfo) mapKeyType).getLength()); default: - throw new IOException("Could not convert from string to map type " - + mapKeyType.getTypeName()); + throw new IOException( + "Could not convert from string to map type " + mapKeyType.getTypeName()); } } @@ -693,8 +691,8 @@ public final class JsonSerdeUtils { } } - private static void skipValue(@Nonnull final JsonParser p) throws JsonParseException, - IOException { + private static void skipValue(@Nonnull final JsonParser p) + throws JsonParseException, IOException { JsonToken valueToken = p.nextToken(); if ((valueToken == JsonToken.START_ARRAY) || (valueToken == JsonToken.START_OBJECT)) { // if the currently read token is a beginning of an array or object, move stream forward http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/io/CompressionStreamFactory.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/io/CompressionStreamFactory.java b/core/src/main/java/hivemall/utils/io/CompressionStreamFactory.java index 2127e7f..a87f94b 100644 --- a/core/src/main/java/hivemall/utils/io/CompressionStreamFactory.java +++ b/core/src/main/java/hivemall/utils/io/CompressionStreamFactory.java @@ -78,8 +78,8 @@ public final class CompressionStreamFactory { return new LZMA2InputStream(in, dictSize); } default: - throw new UnsupportedOperationException("Unsupported compression algorithm: " - + algo); + throw new UnsupportedOperationException( + "Unsupported compression algorithm: " + algo); } } @@ -145,7 +145,8 @@ public final class CompressionStreamFactory { throw new IllegalStateException("LZMA2Option configuration failed", e); } FinishableWrapperOutputStream wrapped = new FinishableWrapperOutputStream(out); - final org.tukaani.xz.FinishableOutputStream lzma2 = options.getOutputStream(wrapped); + final org.tukaani.xz.FinishableOutputStream lzma2 = + options.getOutputStream(wrapped); return new FinishableOutputStreamAdapter(lzma2) { @Override public void finish() throws IOException { @@ -155,8 +156,8 @@ public final class CompressionStreamFactory { }; } default: - throw new UnsupportedOperationException("Unsupported compression algorithm: " - + algo); + throw new UnsupportedOperationException( + "Unsupported compression algorithm: " + algo); } } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/io/LimitedInputStream.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/io/LimitedInputStream.java b/core/src/main/java/hivemall/utils/io/LimitedInputStream.java index f9bb07c..5f0d3aa 100644 --- a/core/src/main/java/hivemall/utils/io/LimitedInputStream.java +++ b/core/src/main/java/hivemall/utils/io/LimitedInputStream.java @@ -31,8 +31,7 @@ import javax.annotation.Nonnegative; * Input stream which is limited to a certain length. Implementation is based on LimitedInputStream * in Apache Commons FileUpload. * - * @link - * https://commons.apache.org/proper/commons-fileupload/apidocs/org/apache/commons/fileupload/util + * @link https://commons.apache.org/proper/commons-fileupload/apidocs/org/apache/commons/fileupload/util * /LimitedInputStream.html */ public class LimitedInputStream extends FilterInputStream { @@ -47,8 +46,8 @@ public class LimitedInputStream extends FilterInputStream { } protected void raiseError() throws IOException { - throw new IOException("Exceeded maximum size of input stream: limit = " + max - + " bytes, but pos = " + pos); + throw new IOException( + "Exceeded maximum size of input stream: limit = " + max + " bytes, but pos = " + pos); } private void proceed(@Nonnegative final long bytes) throws IOException { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/ArrayUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/ArrayUtils.java b/core/src/main/java/hivemall/utils/lang/ArrayUtils.java index eb8ef1d..e06400a 100644 --- a/core/src/main/java/hivemall/utils/lang/ArrayUtils.java +++ b/core/src/main/java/hivemall/utils/lang/ArrayUtils.java @@ -239,7 +239,8 @@ public final class ArrayUtils { return INDEX_NOT_FOUND; } - public static int lastIndexOf(@Nullable final int[] array, final int valueToFind, int startIndex) { + public static int lastIndexOf(@Nullable final int[] array, final int valueToFind, + int startIndex) { if (array == null) { return INDEX_NOT_FOUND; } @@ -285,8 +286,8 @@ public final class ArrayUtils { public static void copy(@Nonnull final int[] src, @Nonnull final int[] dest) { if (src.length != dest.length) { - throw new IllegalArgumentException("src.legnth '" + src.length + "' != dest.length '" - + dest.length + "'"); + throw new IllegalArgumentException( + "src.legnth '" + src.length + "' != dest.length '" + dest.length + "'"); } System.arraycopy(src, 0, dest, 0, src.length); } @@ -303,7 +304,8 @@ public final class ArrayUtils { } @Nonnull - public static float[] append(@Nonnull float[] array, final int currentSize, final float element) { + public static float[] append(@Nonnull float[] array, final int currentSize, + final float element) { if (currentSize + 1 > array.length) { float[] newArray = new float[currentSize * 2]; System.arraycopy(array, 0, newArray, 0, currentSize); @@ -739,7 +741,8 @@ public final class ArrayUtils { } @Nonnull - public static float[] newRandomFloatArray(@Nonnegative final int size, @Nonnull final PRNG rnd) { + public static float[] newRandomFloatArray(@Nonnegative final int size, + @Nonnull final PRNG rnd) { final float[] ret = new float[size]; for (int i = 0; i < size; i++) { ret[i] = (float) rnd.nextDouble(); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/BitUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/BitUtils.java b/core/src/main/java/hivemall/utils/lang/BitUtils.java index 5f4235e..96f5df6 100644 --- a/core/src/main/java/hivemall/utils/lang/BitUtils.java +++ b/core/src/main/java/hivemall/utils/lang/BitUtils.java @@ -64,7 +64,8 @@ public final class BitUtils { return pos; } - public static int indexOfClearBit(@Nonnull final BitSet bits, final int nth, final int lastIndex) { + public static int indexOfClearBit(@Nonnull final BitSet bits, final int nth, + final int lastIndex) { int j = bits.nextClearBit(0); for (int c = 0; j <= lastIndex; j = bits.nextClearBit(j + 1), c++) { if (c == nth) { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/HalfFloat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/HalfFloat.java b/core/src/main/java/hivemall/utils/lang/HalfFloat.java index 7c778c4..1a05977 100644 --- a/core/src/main/java/hivemall/utils/lang/HalfFloat.java +++ b/core/src/main/java/hivemall/utils/lang/HalfFloat.java @@ -181,8 +181,8 @@ public final class HalfFloat { public static void checkRange(final float f) { if (Math.abs(f) > HalfFloat.MAX_FLOAT) { - throw new IllegalArgumentException("Acceptable maximum weight is " - + HalfFloat.MAX_FLOAT + ": " + f); + throw new IllegalArgumentException( + "Acceptable maximum weight is " + HalfFloat.MAX_FLOAT + ": " + f); } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/ObjectUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/ObjectUtils.java b/core/src/main/java/hivemall/utils/lang/ObjectUtils.java index fd4af32..459f135 100644 --- a/core/src/main/java/hivemall/utils/lang/ObjectUtils.java +++ b/core/src/main/java/hivemall/utils/lang/ObjectUtils.java @@ -113,13 +113,13 @@ public final class ObjectUtils { oos.flush(); } - public static <T> T readObject(@Nonnull final byte[] obj) throws IOException, - ClassNotFoundException { + public static <T> T readObject(@Nonnull final byte[] obj) + throws IOException, ClassNotFoundException { return readObject(obj, obj.length); } - public static <T> T readObject(@Nonnull final byte[] obj, final int length) throws IOException, - ClassNotFoundException { + public static <T> T readObject(@Nonnull final byte[] obj, final int length) + throws IOException, ClassNotFoundException { return readObject(new FastByteArrayInputStream(obj, length)); } @@ -134,8 +134,8 @@ public final class ObjectUtils { } @SuppressWarnings("unchecked") - public static <T> T readObject(@Nonnull final InputStream is) throws IOException, - ClassNotFoundException { + public static <T> T readObject(@Nonnull final InputStream is) + throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(is); return (T) ois.readObject(); } @@ -146,8 +146,8 @@ public final class ObjectUtils { dst.readExternal(ois); } - public static <T> T readCompressedObject(@Nonnull final byte[] obj) throws IOException, - ClassNotFoundException { + public static <T> T readCompressedObject(@Nonnull final byte[] obj) + throws IOException, ClassNotFoundException { FastByteArrayInputStream bis = new FastByteArrayInputStream(obj); final InflaterInputStream iis = new InflaterInputStream(bis); try { @@ -185,8 +185,8 @@ public final class ObjectUtils { } public static void readCompressedObject(@Nonnull final byte[] src, final int offset, - final int length, @Nonnull final Externalizable dst) throws IOException, - ClassNotFoundException { + final int length, @Nonnull final Externalizable dst) + throws IOException, ClassNotFoundException { FastByteArrayInputStream bis = new FastByteArrayInputStream(src, offset, length); final InflaterInputStream iis = new InflaterInputStream(bis); try { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/Preconditions.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/Preconditions.java b/core/src/main/java/hivemall/utils/lang/Preconditions.java index eabbc0a..3843a27 100644 --- a/core/src/main/java/hivemall/utils/lang/Preconditions.java +++ b/core/src/main/java/hivemall/utils/lang/Preconditions.java @@ -42,8 +42,8 @@ public final class Preconditions { try { throwable = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException( - "Failed to instantiate a class: " + clazz.getName(), e); + throw new IllegalStateException("Failed to instantiate a class: " + clazz.getName(), + e); } throw throwable; } @@ -58,12 +58,12 @@ public final class Preconditions { Constructor<E> constructor = clazz.getConstructor(String.class); throwable = constructor.newInstance(errorMessage); } catch (NoSuchMethodException | SecurityException e1) { - throw new IllegalStateException("Failed to get a Constructor(String): " - + clazz.getName(), e1); + throw new IllegalStateException( + "Failed to get a Constructor(String): " + clazz.getName(), e1); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) { - throw new IllegalStateException( - "Failed to instantiate a class: " + clazz.getName(), e2); + throw new IllegalStateException("Failed to instantiate a class: " + clazz.getName(), + e2); } throw throwable; } @@ -90,8 +90,8 @@ public final class Preconditions { try { throwable = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { - throw new IllegalStateException( - "Failed to instantiate a class: " + clazz.getName(), e); + throw new IllegalStateException("Failed to instantiate a class: " + clazz.getName(), + e); } throw throwable; } @@ -104,15 +104,15 @@ public final class Preconditions { try { constructor = clazz.getConstructor(String.class); } catch (NoSuchMethodException | SecurityException e) { - throw new IllegalStateException( - "Failed to get a constructor of " + clazz.getName(), e); + throw new IllegalStateException("Failed to get a constructor of " + clazz.getName(), + e); } final E throwable; try { throwable = constructor.newInstance(errorMessage); } catch (ReflectiveOperationException | IllegalArgumentException e) { - throw new IllegalStateException( - "Failed to instantiate a class: " + clazz.getName(), e); + throw new IllegalStateException("Failed to instantiate a class: " + clazz.getName(), + e); } throw throwable; } @@ -127,8 +127,8 @@ public final class Preconditions { public static void checkArgument(boolean expression, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) { if (!expression) { - throw new IllegalArgumentException(StringUtils.format(errorMessageTemplate, - errorMessageArgs)); + throw new IllegalArgumentException( + StringUtils.format(errorMessageTemplate, errorMessageArgs)); } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/PrivilegedAccessor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/PrivilegedAccessor.java b/core/src/main/java/hivemall/utils/lang/PrivilegedAccessor.java index 234bb5b..8cf41b6 100644 --- a/core/src/main/java/hivemall/utils/lang/PrivilegedAccessor.java +++ b/core/src/main/java/hivemall/utils/lang/PrivilegedAccessor.java @@ -91,7 +91,8 @@ public final class PrivilegedAccessor { public static Method getMethod(Class<?> thisClass, String methodName, Class<?>[] classTypes) throws NoSuchMethodException { if (thisClass == null) { - throw new NoSuchMethodException("Class is not specified for method " + methodName + "."); + throw new NoSuchMethodException( + "Class is not specified for method " + methodName + "."); } try { return thisClass.getDeclaredMethod(methodName, classTypes); @@ -114,8 +115,8 @@ public final class PrivilegedAccessor { * @param fieldName the name of the field * @return an object representing the value of the field */ - public static Object getValue(Object instance, String fieldName) throws IllegalAccessException, - NoSuchFieldException { + public static Object getValue(Object instance, String fieldName) + throws IllegalAccessException, NoSuchFieldException { Field field = getField(instance.getClass(), fieldName, true); return field.get(instance); } @@ -193,9 +194,9 @@ public final class PrivilegedAccessor { * specified arguments includes null object. */ public static Object invokeStaticMethod(String className, String methodName, - Class<?>[] classTypes, Object... objects) throws ClassNotFoundException, - SecurityException, NoSuchMethodException, IllegalArgumentException, - IllegalAccessException, InvocationTargetException { + Class<?>[] classTypes, Object... objects) + throws ClassNotFoundException, SecurityException, NoSuchMethodException, + IllegalArgumentException, IllegalAccessException, InvocationTargetException { Class<?> primeClass = Class.forName(className); Method method = primeClass.getDeclaredMethod(methodName, classTypes); method.setAccessible(true); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/mutable/MutableDouble.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/mutable/MutableDouble.java b/core/src/main/java/hivemall/utils/lang/mutable/MutableDouble.java index 4770882..ee8e81c 100644 --- a/core/src/main/java/hivemall/utils/lang/mutable/MutableDouble.java +++ b/core/src/main/java/hivemall/utils/lang/mutable/MutableDouble.java @@ -24,8 +24,8 @@ import java.io.Serializable; import javax.annotation.Nonnull; -public final class MutableDouble extends Number implements Copyable<MutableDouble>, - Comparable<MutableDouble>, Serializable { +public final class MutableDouble extends Number + implements Copyable<MutableDouble>, Comparable<MutableDouble>, Serializable { private static final long serialVersionUID = 3275291486084936953L; private double value; @@ -97,8 +97,8 @@ public final class MutableDouble extends Number implements Copyable<MutableDoubl @Override public boolean equals(Object obj) { - return (obj instanceof MutableDouble) - && (Double.doubleToLongBits(((MutableDouble) obj).value) == Double.doubleToLongBits(value)); + return (obj instanceof MutableDouble) && (Double.doubleToLongBits( + ((MutableDouble) obj).value) == Double.doubleToLongBits(value)); } @Override http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/mutable/MutableFloat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/mutable/MutableFloat.java b/core/src/main/java/hivemall/utils/lang/mutable/MutableFloat.java index 8ec3e99..918466b 100644 --- a/core/src/main/java/hivemall/utils/lang/mutable/MutableFloat.java +++ b/core/src/main/java/hivemall/utils/lang/mutable/MutableFloat.java @@ -22,8 +22,8 @@ import hivemall.utils.lang.Copyable; import java.io.Serializable; -public final class MutableFloat extends Number implements Copyable<MutableFloat>, - Comparable<MutableFloat>, Serializable { +public final class MutableFloat extends Number + implements Copyable<MutableFloat>, Comparable<MutableFloat>, Serializable { private static final long serialVersionUID = 1758508142164954048L; private float value; @@ -95,8 +95,8 @@ public final class MutableFloat extends Number implements Copyable<MutableFloat> @Override public boolean equals(Object obj) { - return (obj instanceof MutableFloat) - && (Float.floatToIntBits(((MutableFloat) obj).value) == Float.floatToIntBits(value)); + return (obj instanceof MutableFloat) && (Float.floatToIntBits( + ((MutableFloat) obj).value) == Float.floatToIntBits(value)); } @Override http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/mutable/MutableInt.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/mutable/MutableInt.java b/core/src/main/java/hivemall/utils/lang/mutable/MutableInt.java index 904fa5e..e527f2b 100644 --- a/core/src/main/java/hivemall/utils/lang/mutable/MutableInt.java +++ b/core/src/main/java/hivemall/utils/lang/mutable/MutableInt.java @@ -22,8 +22,8 @@ import hivemall.utils.lang.Copyable; import java.io.Serializable; -public final class MutableInt extends Number implements Copyable<MutableInt>, - Comparable<MutableInt>, Serializable { +public final class MutableInt extends Number + implements Copyable<MutableInt>, Comparable<MutableInt>, Serializable { private static final long serialVersionUID = -3289272606407100628L; private int value; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/lang/mutable/MutableLong.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/lang/mutable/MutableLong.java b/core/src/main/java/hivemall/utils/lang/mutable/MutableLong.java index 06fb606..94fed48 100644 --- a/core/src/main/java/hivemall/utils/lang/mutable/MutableLong.java +++ b/core/src/main/java/hivemall/utils/lang/mutable/MutableLong.java @@ -22,8 +22,8 @@ import hivemall.utils.lang.Copyable; import java.io.Serializable; -public final class MutableLong extends Number implements Copyable<MutableLong>, - Comparable<MutableLong>, Serializable { +public final class MutableLong extends Number + implements Copyable<MutableLong>, Comparable<MutableLong>, Serializable { private static final long serialVersionUID = 4215176730382645660L; private long value; http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/math/FastMath.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/math/FastMath.java b/core/src/main/java/hivemall/utils/math/FastMath.java index 09f7a16..6b5382d 100644 --- a/core/src/main/java/hivemall/utils/math/FastMath.java +++ b/core/src/main/java/hivemall/utils/math/FastMath.java @@ -142,12 +142,12 @@ public final class FastMath { static final int EXP_LO_TAB_SIZE = (1 << EXP_LO_TAB_SIZE_POT) + 1; static final int EXP_LO_TAB_MID_INDEX = ((EXP_LO_TAB_SIZE - 1) / 2); static final int EXP_LO_INDEXING = EXP_LO_TAB_MID_INDEX / EXP_LO_DISTANCE_TO_ZERO; - static final int EXP_LO_INDEXING_DIV_SHIFT = EXP_LO_TAB_SIZE_POT - 1 - - EXP_LO_DISTANCE_TO_ZERO_POT; + static final int EXP_LO_INDEXING_DIV_SHIFT = + EXP_LO_TAB_SIZE_POT - 1 - EXP_LO_DISTANCE_TO_ZERO_POT; static final class MyTExp { - static final double[] expHiTab = new double[1 + (int) EXP_OVERFLOW_LIMIT - - (int) EXP_UNDERFLOW_LIMIT]; + static final double[] expHiTab = + new double[1 + (int) EXP_OVERFLOW_LIMIT - (int) EXP_UNDERFLOW_LIMIT]; static final double[] expLoPosTab = new double[EXP_LO_TAB_SIZE]; static final double[] expLoNegTab = new double[EXP_LO_TAB_SIZE]; @@ -238,8 +238,8 @@ public final class FastMath { final double z = zIndex * (1.0 / EXP_LO_INDEXING); final double eps = y - z; final double expZ = MyTExp.expLoPosTab[zIndex + EXP_LO_TAB_MID_INDEX]; - final double expEps = (1 + eps - * (1 + eps * (1.0 / 2 + eps * (1.0 / 6 + eps * (1.0 / 24))))); + final double expEps = + (1 + eps * (1 + eps * (1.0 / 2 + eps * (1.0 / 6 + eps * (1.0 / 24))))); final double loTerm = expZ * expEps; return hiTerm * loTerm; @@ -266,12 +266,10 @@ public final class FastMath { // Taking int part instead of rounding, which takes too long. int i = (int) (value * EXP_LO_INDEXING); double delta = value - i * (1.0 / EXP_LO_INDEXING); - return MyTExp.expLoPosTab[i + EXP_LO_TAB_MID_INDEX] - * (MyTExp.expLoNegTab[i + EXP_LO_TAB_MID_INDEX] + delta - * (1 + delta - * (1.0 / 2 + delta - * (1.0 / 6 + delta - * (1.0 / 24 + delta * (1.0 / 120)))))); + return MyTExp.expLoPosTab[i + EXP_LO_TAB_MID_INDEX] * (MyTExp.expLoNegTab[i + + EXP_LO_TAB_MID_INDEX] + + delta * (1 + delta * (1.0 / 2 + + delta * (1.0 / 6 + delta * (1.0 / 24 + delta * (1.0 / 120)))))); } else { return exp(value) - 1; } @@ -310,12 +308,8 @@ public final class FastMath { if (value < 1.14) { double z = (value - 1.0) / (value + 1.0); double z2 = z * z; - return z - * (2 + z2 - * ((2.0 / 3) + z2 - * ((2.0 / 5) + z2 - * ((2.0 / 7) + z2 - * ((2.0 / 9) + z2 * ((2.0 / 11))))))); + return z * (2 + z2 * ((2.0 / 3) + z2 * ((2.0 / 5) + + z2 * ((2.0 / 7) + z2 * ((2.0 / 9) + z2 * ((2.0 / 11))))))); } h = 0.0; } else if (value < DOUBLE_MIN_NORMAL) { @@ -379,15 +373,12 @@ public final class FastMath { } else if (Math.abs(value) < 0.15) { double z = value / (value + 2.0); double z2 = z * z; - return z - * (2 + z2 - * ((2.0 / 3) + z2 - * ((2.0 / 5) + z2 - * ((2.0 / 7) + z2 - * ((2.0 / 9) + z2 * ((2.0 / 11))))))); + return z * (2 + z2 * ((2.0 / 3) + z2 * ((2.0 / 5) + + z2 * ((2.0 / 7) + z2 * ((2.0 / 9) + z2 * ((2.0 / 11))))))); } - int valuePlusOneBitsHi = (int) (Double.doubleToRawLongBits(valuePlusOne) >> 32) & 0x7FFFFFFF; + int valuePlusOneBitsHi = + (int) (Double.doubleToRawLongBits(valuePlusOne) >> 32) & 0x7FFFFFFF; int valuePlusOneExp = (valuePlusOneBitsHi >> 20) - MAX_DOUBLE_EXPONENT; // Getting the first LOG_BITS bits of the mantissa. int xIndex = ((valuePlusOneBitsHi << 12) >>> (32 - LOG_BITS)); @@ -417,7 +408,8 @@ public final class FastMath { */ private static double twoPowNormalOrSubnormal(final int power) { if (power <= -MAX_DOUBLE_EXPONENT) { // Not normal. - return Double.longBitsToDouble(0x0008000000000000L >> (-(power + MAX_DOUBLE_EXPONENT))); + return Double.longBitsToDouble( + 0x0008000000000000L >> (-(power + MAX_DOUBLE_EXPONENT))); } else { // Normal. return Double.longBitsToDouble(((long) (power + MAX_DOUBLE_EXPONENT)) << 52); } @@ -433,7 +425,8 @@ public final class FastMath { private static double twoPow(final int power) { if (power <= -MAX_DOUBLE_EXPONENT) { // Not normal. if (power >= MIN_DOUBLE_EXPONENT) { // Subnormal. - return Double.longBitsToDouble(0x0008000000000000L >> (-(power + MAX_DOUBLE_EXPONENT))); + return Double.longBitsToDouble( + 0x0008000000000000L >> (-(power + MAX_DOUBLE_EXPONENT))); } else { // Underflow. return 0.0; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/math/MathUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/math/MathUtils.java b/core/src/main/java/hivemall/utils/math/MathUtils.java index dd9e892..5b4a88a 100644 --- a/core/src/main/java/hivemall/utils/math/MathUtils.java +++ b/core/src/main/java/hivemall/utils/math/MathUtils.java @@ -100,11 +100,11 @@ public final class MathUtils { * Returns the inverse erf. This code is based on erfInv() in * org.apache.commons.math3.special.Erf. * <p> - * This implementation is described in the paper: <a - * href="http://people.maths.ox.ac.uk/gilesm/files/gems_erfinv.pdf">Approximating the erfinv + * This implementation is described in the paper: + * <a href="http://people.maths.ox.ac.uk/gilesm/files/gems_erfinv.pdf">Approximating the erfinv * function</a> by Mike Giles, Oxford-Man Institute of Quantitative Finance, which was published - * in GPU Computing Gems, volume 2, 2010. The source code is available <a - * href="http://gpucomputing.net/?q=node/1828">here</a>. + * in GPU Computing Gems, volume 2, 2010. The source code is available + * <a href="http://gpucomputing.net/?q=node/1828">here</a>. * </p> * * @param x the value @@ -211,11 +211,13 @@ public final class MathUtils { return (float) Math.sqrt(sqsum); } - public static double gaussian(final double mean, final double stddev, @Nonnull final Random rnd) { + public static double gaussian(final double mean, final double stddev, + @Nonnull final Random rnd) { return mean + (stddev * rnd.nextGaussian()); } - public static double lognormal(final double mean, final double stddev, @Nonnull final Random rnd) { + public static double lognormal(final double mean, final double stddev, + @Nonnull final Random rnd) { return Math.exp(gaussian(mean, stddev, rnd)); } @@ -339,7 +341,8 @@ public final class MathUtils { } } - public static void add(@Nonnull final float[] src, @Nonnull final double[] dst, final int size) { + public static void add(@Nonnull final float[] src, @Nonnull final double[] dst, + final int size) { for (int i = 0; i < size; i++) { dst[i] += src[i]; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/math/MatrixUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/math/MatrixUtils.java b/core/src/main/java/hivemall/utils/math/MatrixUtils.java index 36e378b..6c08a61 100644 --- a/core/src/main/java/hivemall/utils/math/MatrixUtils.java +++ b/core/src/main/java/hivemall/utils/math/MatrixUtils.java @@ -48,8 +48,8 @@ public final class MatrixUtils { * R_j = â_{i=1}^{k} A_i R_{j-i} where j = 1..k, R_{-i} = R'_i * </pre> * - * @see <a - * href="http://www.emptyloop.com/technotes/a%20tutorial%20on%20linear%20prediction%20and%20levinson-durbin.pdf">Cedrick + * @see <a href= + * "http://www.emptyloop.com/technotes/a%20tutorial%20on%20linear%20prediction%20and%20levinson-durbin.pdf">Cedrick * Collomb: A tutorial on linear prediction and Levinson-Durbin</a> * @param R autocovariance where |R| >= order * @param A coefficient to be solved where |A| >= order + 1 @@ -58,10 +58,10 @@ public final class MatrixUtils { @Nonnull public static double[] aryule(@Nonnull final double[] R, @Nonnull final double[] A, final int order) { - Preconditions.checkArgument(R.length > order, "|R| MUST be greater than or equals to " - + order + ": " + R.length); - Preconditions.checkArgument(A.length >= order + 1, "|A| MUST be greater than or equals to " - + (order + 1) + ": " + A.length); + Preconditions.checkArgument(R.length > order, + "|R| MUST be greater than or equals to " + order + ": " + R.length); + Preconditions.checkArgument(A.length >= order + 1, + "|A| MUST be greater than or equals to " + (order + 1) + ": " + A.length); final double[] E = new double[order + 1]; A[0] = 1.0d; @@ -99,10 +99,10 @@ public final class MatrixUtils { @Nonnull public static double[] aryule2(@Nonnull final double[] R, @Nonnull final double[] A, final int order) { - Preconditions.checkArgument(R.length > order, "|C| MUST be greater than or equals to " - + order + ": " + R.length); - Preconditions.checkArgument(A.length >= order + 1, "|A| MUST be greater than or equals to " - + (order + 1) + ": " + A.length); + Preconditions.checkArgument(R.length > order, + "|C| MUST be greater than or equals to " + order + ": " + R.length); + Preconditions.checkArgument(A.length >= order + 1, + "|A| MUST be greater than or equals to " + (order + 1) + ": " + A.length); final double[] E = new double[order + 1]; A[0] = E[0] = 1.0d; @@ -148,10 +148,10 @@ public final class MatrixUtils { @Nonnull public static double[] arburg(@Nonnull final double[] X, @Nonnull final double[] A, final int order) { - Preconditions.checkArgument(X.length > order, "|X| MUST be greater than or equals to " - + order + ": " + X.length); - Preconditions.checkArgument(A.length >= order + 1, "|A| MUST be greater than or equals to " - + (order + 1) + ": " + A.length); + Preconditions.checkArgument(X.length > order, + "|X| MUST be greater than or equals to " + order + ": " + X.length); + Preconditions.checkArgument(A.length >= order + 1, + "|A| MUST be greater than or equals to " + (order + 1) + ": " + A.length); final int nDataPoints = X.length; final double[] E = new double[order + 1]; @@ -237,8 +237,8 @@ public final class MatrixUtils { @Nonnull public static RealMatrix[][] toeplitz(@Nonnull final RealMatrix[] c, final int dim) { Preconditions.checkArgument(dim >= 1, "Invalid dimension: " + dim); - Preconditions.checkArgument(c.length >= dim, "|c| must be greater than " + dim + ": " - + c.length); + Preconditions.checkArgument(c.length >= dim, + "|c| must be greater than " + dim + ": " + c.length); /* * Toeplitz matrix (symmetric, invertible, k*dimensions by k*dimensions) @@ -284,8 +284,8 @@ public final class MatrixUtils { @Nonnull public static double[][] toeplitz(@Nonnull final double[] c, final int dim) { Preconditions.checkArgument(dim >= 1, "Invalid dimension: " + dim); - Preconditions.checkArgument(c.length >= dim, "|c| must be greater than " + dim + ": " - + c.length); + Preconditions.checkArgument(c.length >= dim, + "|c| must be greater than " + dim + ": " + c.length); /* * Toeplitz matrix (symmetric, invertible, k*dimensions by k*dimensions) @@ -385,8 +385,8 @@ public final class MatrixUtils { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (offset >= data.length) { - throw new IndexOutOfBoundsException("Offset " + offset - + " exceeded data.length " + data.length); + throw new IndexOutOfBoundsException( + "Offset " + offset + " exceeded data.length " + data.length); } double value = data[offset]; cell.setEntry(i, j, value); @@ -406,7 +406,8 @@ public final class MatrixUtils { Preconditions.checkArgument(grid.length >= 1, "The number of rows must be greater than 1"); Preconditions.checkArgument(grid[0].length >= 1, "The number of cols must be greater than 1"); - Preconditions.checkArgument(dimensions > 0, "Dimension should be more than 0: ", dimensions); + Preconditions.checkArgument(dimensions > 0, "Dimension should be more than 0: ", + dimensions); final int rows = grid.length; final int cols = grid[0].length; @@ -422,8 +423,8 @@ public final class MatrixUtils { @Nonnull public static RealMatrix combinedMatrices(@Nonnull final RealMatrix[] grid) { - Preconditions.checkArgument(grid.length >= 1, "The number of rows must be greater than 0: " - + grid.length); + Preconditions.checkArgument(grid.length >= 1, + "The number of rows must be greater than 0: " + grid.length); final int rows = grid.length; final int rowDims = grid[0].getRowDimension(); @@ -512,7 +513,7 @@ public final class MatrixUtils { /** * Find the first singular vector/value of a matrix A based on the Power method. * - * @see http + * @see http * ://www.cs.yale.edu/homes/el327/datamining2013aFiles/07_singular_value_decomposition.pdf * @param A target matrix * @param x0 initial vector @@ -632,12 +633,14 @@ public final class MatrixUtils { x = unitL2norm(x); RealMatrix subR = R.getSubMatrix(i, i + 1, 0, n - 1); - R.setSubMatrix(subR.subtract(x.outerProduct(subR.preMultiply(x)).scalarMultiply(2)) - .getData(), i, 0); + R.setSubMatrix( + subR.subtract(x.outerProduct(subR.preMultiply(x)).scalarMultiply(2)).getData(), i, + 0); RealMatrix subQt = Qt.getSubMatrix(i, i + 1, 0, n - 1); - Qt.setSubMatrix(subQt.subtract(x.outerProduct(subQt.preMultiply(x)).scalarMultiply(2)) - .getData(), i, 0); + Qt.setSubMatrix( + subQt.subtract(x.outerProduct(subQt.preMultiply(x)).scalarMultiply(2)).getData(), i, + 0); } } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/math/Primes.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/math/Primes.java b/core/src/main/java/hivemall/utils/math/Primes.java index f65131a..d46358d 100644 --- a/core/src/main/java/hivemall/utils/math/Primes.java +++ b/core/src/main/java/hivemall/utils/math/Primes.java @@ -27,39 +27,38 @@ public final class Primes { 823, 859, 883, 1021, 1063, 1093, 1153, 1231, 1321, 1429, 1489, 1621, 1699, 1789, 1873, 1951, 2029, 2131, 2143, 2311, 2383, 2593, 2731, 2803, 3001, 3121, 3259, 3391, 3583, 3673, 3919, 4093, 4273, 4423, 4651, 4801, 5023, 5281, 5521, 5743, 5881, 6301, 6571, - 6871, 7129, 7489, 7759, 8089, 8539, 8863, 9283, 9721, 10141, 10531, 11071, 11551, - 12073, 12613, 13009, 13759, 14323, 14869, 15649, 16363, 17029, 17839, 18541, 19471, - 20233, 21193, 22159, 23059, 24181, 25171, 26263, 27541, 28753, 30013, 31321, 32719, - 34213, 35731, 37309, 38923, 40639, 42463, 44281, 46309, 48313, 50461, 52711, 55051, - 57529, 60091, 62299, 65521, 68281, 71413, 74611, 77713, 81373, 84979, 88663, 92671, - 96739, 100801, 105529, 109849, 115021, 120079, 125509, 131011, 136861, 142873, 149251, - 155863, 162751, 169891, 177433, 185071, 193381, 202129, 211063, 220021, 229981, 240349, - 250969, 262111, 273643, 285841, 298411, 311713, 325543, 339841, 355009, 370663, 386989, - 404269, 422113, 440809, 460081, 480463, 501829, 524221, 547399, 571603, 596929, 623353, - 651019, 679909, 709741, 741343, 774133, 808441, 844201, 881539, 920743, 961531, - 1004119, 1048573, 1094923, 1143283, 1193911, 1246963, 1302181, 1359733, 1420039, - 1482853, 1548541, 1616899, 1688413, 1763431, 1841293, 1922773, 2008081, 2097133, - 2189989, 2286883, 2388163, 2493853, 2604013, 2719669, 2840041, 2965603, 3097123, - 3234241, 3377191, 3526933, 3682363, 3845983, 4016041, 4193803, 4379719, 4573873, - 4776223, 4987891, 5208523, 5439223, 5680153, 5931313, 6194191, 6468463, 6754879, - 7053331, 7366069, 7692343, 8032639, 8388451, 8759953, 9147661, 9552733, 9975193, - 10417291, 10878619, 11360203, 11863153, 12387841, 12936529, 13509343, 14107801, - 14732413, 15384673, 16065559, 16777141, 17519893, 18295633, 19105483, 19951231, - 20834689, 21757291, 22720591, 23726449, 24776953, 25873963, 27018853, 28215619, - 29464579, 30769093, 32131711, 33554011, 35039911, 36591211, 38211163, 39903121, - 41669479, 43514521, 45441199, 47452879, 49553941, 51747991, 54039079, 56431513, - 58930021, 61539091, 64263571, 67108669, 70079959, 73182409, 76422793, 79806229, - 83339383, 87029053, 90881083, 94906249, 99108043, 103495879, 108077731, 112863013, - 117860053, 123078019, 128526943, 134217439, 140159911, 146365159, 152845393, 159612601, - 166679173, 174058849, 181765093, 189812341, 198216103, 206991601, 216156043, 225726379, - 235720159, 246156271, 257054491, 268435009, 280319203, 292730833, 305691181, 319225021, - 333358513, 348117151, 363529759, 379624279, 396432481, 413983771, 432312511, 451452613, - 471440161, 492312523, 514109251, 536870839, 560640001, 585461743, 611382451, 638450569, - 666717199, 696235363, 727060069, 759249643, 792864871, 827967631, 864625033, 902905501, - 942880663, 984625531, 1028218189, 1073741719, 1121280091, 1170923713, 1222764841, - 1276901371, 1333434301, 1392470281, 1454120779, 1518500173, 1585729993, 1655935399, - 1729249999, 1805811253, 1885761133, 1969251079, 2056437379, 2147482951, - Integer.MAX_VALUE}; + 6871, 7129, 7489, 7759, 8089, 8539, 8863, 9283, 9721, 10141, 10531, 11071, 11551, 12073, + 12613, 13009, 13759, 14323, 14869, 15649, 16363, 17029, 17839, 18541, 19471, 20233, + 21193, 22159, 23059, 24181, 25171, 26263, 27541, 28753, 30013, 31321, 32719, 34213, + 35731, 37309, 38923, 40639, 42463, 44281, 46309, 48313, 50461, 52711, 55051, 57529, + 60091, 62299, 65521, 68281, 71413, 74611, 77713, 81373, 84979, 88663, 92671, 96739, + 100801, 105529, 109849, 115021, 120079, 125509, 131011, 136861, 142873, 149251, 155863, + 162751, 169891, 177433, 185071, 193381, 202129, 211063, 220021, 229981, 240349, 250969, + 262111, 273643, 285841, 298411, 311713, 325543, 339841, 355009, 370663, 386989, 404269, + 422113, 440809, 460081, 480463, 501829, 524221, 547399, 571603, 596929, 623353, 651019, + 679909, 709741, 741343, 774133, 808441, 844201, 881539, 920743, 961531, 1004119, + 1048573, 1094923, 1143283, 1193911, 1246963, 1302181, 1359733, 1420039, 1482853, + 1548541, 1616899, 1688413, 1763431, 1841293, 1922773, 2008081, 2097133, 2189989, + 2286883, 2388163, 2493853, 2604013, 2719669, 2840041, 2965603, 3097123, 3234241, + 3377191, 3526933, 3682363, 3845983, 4016041, 4193803, 4379719, 4573873, 4776223, + 4987891, 5208523, 5439223, 5680153, 5931313, 6194191, 6468463, 6754879, 7053331, + 7366069, 7692343, 8032639, 8388451, 8759953, 9147661, 9552733, 9975193, 10417291, + 10878619, 11360203, 11863153, 12387841, 12936529, 13509343, 14107801, 14732413, + 15384673, 16065559, 16777141, 17519893, 18295633, 19105483, 19951231, 20834689, + 21757291, 22720591, 23726449, 24776953, 25873963, 27018853, 28215619, 29464579, + 30769093, 32131711, 33554011, 35039911, 36591211, 38211163, 39903121, 41669479, + 43514521, 45441199, 47452879, 49553941, 51747991, 54039079, 56431513, 58930021, + 61539091, 64263571, 67108669, 70079959, 73182409, 76422793, 79806229, 83339383, + 87029053, 90881083, 94906249, 99108043, 103495879, 108077731, 112863013, 117860053, + 123078019, 128526943, 134217439, 140159911, 146365159, 152845393, 159612601, 166679173, + 174058849, 181765093, 189812341, 198216103, 206991601, 216156043, 225726379, 235720159, + 246156271, 257054491, 268435009, 280319203, 292730833, 305691181, 319225021, 333358513, + 348117151, 363529759, 379624279, 396432481, 413983771, 432312511, 451452613, 471440161, + 492312523, 514109251, 536870839, 560640001, 585461743, 611382451, 638450569, 666717199, + 696235363, 727060069, 759249643, 792864871, 827967631, 864625033, 902905501, 942880663, + 984625531, 1028218189, 1073741719, 1121280091, 1170923713, 1222764841, 1276901371, + 1333434301, 1392470281, 1454120779, 1518500173, 1585729993, 1655935399, 1729249999, + 1805811253, 1885761133, 1969251079, 2056437379, 2147482951, Integer.MAX_VALUE}; private Primes() {} http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/math/StatsUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/math/StatsUtils.java b/core/src/main/java/hivemall/utils/math/StatsUtils.java index 599bf51..ace8c6d 100644 --- a/core/src/main/java/hivemall/utils/math/StatsUtils.java +++ b/core/src/main/java/hivemall/utils/math/StatsUtils.java @@ -97,10 +97,10 @@ public final class StatsUtils { public static double pdf(@Nonnull final RealVector x, @Nonnull final RealVector x_hat, @Nonnull final RealMatrix sigma) { final int dim = x.getDimension(); - Preconditions.checkArgument(x_hat.getDimension() == dim, "|x| != |x_hat|, |x|=" + dim - + ", |x_hat|=" + x_hat.getDimension()); - Preconditions.checkArgument(sigma.getRowDimension() == dim, "|x| != |sigma|, |x|=" + dim - + ", |sigma|=" + sigma.getRowDimension()); + Preconditions.checkArgument(x_hat.getDimension() == dim, + "|x| != |x_hat|, |x|=" + dim + ", |x_hat|=" + x_hat.getDimension()); + Preconditions.checkArgument(sigma.getRowDimension() == dim, + "|x| != |sigma|, |x|=" + dim + ", |sigma|=" + sigma.getRowDimension()); Preconditions.checkArgument(sigma.isSquare(), "Sigma is not square matrix"); LUDecomposition LU = new LUDecomposition(sigma); @@ -249,8 +249,8 @@ public final class StatsUtils { */ public static double chiSquareTest(@Nonnull final double[] observed, @Nonnull final double[] expected) { - final ChiSquaredDistribution distribution = new ChiSquaredDistribution( - expected.length - 1.d); + final ChiSquaredDistribution distribution = + new ChiSquaredDistribution(expected.length - 1.d); return 1.d - distribution.cumulativeProbability(chiSquare(observed, expected)); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/main/java/hivemall/utils/net/NetUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/hivemall/utils/net/NetUtils.java b/core/src/main/java/hivemall/utils/net/NetUtils.java index 57fecf6..498aa6b 100644 --- a/core/src/main/java/hivemall/utils/net/NetUtils.java +++ b/core/src/main/java/hivemall/utils/net/NetUtils.java @@ -52,7 +52,8 @@ public final class NetUtils { } public static boolean isIPAddress(final String ip) { - return ip.matches("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); + return ip.matches( + "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); } public static int getAvailablePort() { @@ -78,8 +79,8 @@ public final class NetUtils { return i; } } - throw new NoSuchElementException("Could not find available port greater than or equals to " - + basePort); + throw new NoSuchElementException( + "Could not find available port greater than or equals to " + basePort); } public static boolean isPortAvailable(final int port) { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/test/java/hivemall/TestUtils.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/hivemall/TestUtils.java b/core/src/test/java/hivemall/TestUtils.java index 1f1f1da..fd8d189 100644 --- a/core/src/test/java/hivemall/TestUtils.java +++ b/core/src/test/java/hivemall/TestUtils.java @@ -36,8 +36,8 @@ import org.apache.hive.com.esotericsoftware.kryo.io.Output; public final class TestUtils { public static <T extends GenericUDF> void testGenericUDFSerialization(@Nonnull Class<T> clazz, - @Nonnull ObjectInspector[] ois, @Nonnull Object[] row) throws HiveException, - IOException { + @Nonnull ObjectInspector[] ois, @Nonnull Object[] row) + throws HiveException, IOException { final T udf; try { udf = clazz.newInstance(); @@ -67,9 +67,8 @@ public final class TestUtils { } @SuppressWarnings("deprecation") - public static <T extends GenericUDTF> void testGenericUDTFSerialization( - @Nonnull Class<T> clazz, @Nonnull ObjectInspector[] ois, @Nonnull Object[][] rows) - throws HiveException { + public static <T extends GenericUDTF> void testGenericUDTFSerialization(@Nonnull Class<T> clazz, + @Nonnull ObjectInspector[] ois, @Nonnull Object[][] rows) throws HiveException { final T udtf; try { udtf = clazz.newInstance(); http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/test/java/hivemall/anomaly/ChangeFinder2DTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/hivemall/anomaly/ChangeFinder2DTest.java b/core/src/test/java/hivemall/anomaly/ChangeFinder2DTest.java index eb17881..0fff98b 100644 --- a/core/src/test/java/hivemall/anomaly/ChangeFinder2DTest.java +++ b/core/src/test/java/hivemall/anomaly/ChangeFinder2DTest.java @@ -133,9 +133,9 @@ public class ChangeFinder2DTest { public void testPoissonDist() throws HiveException { final int examples = 10000; final int dims = 3; - final PoissonDistribution[] poisson = new PoissonDistribution[] { - new PoissonDistribution(10.d), new PoissonDistribution(5.d), - new PoissonDistribution(20.d)}; + final PoissonDistribution[] poisson = + new PoissonDistribution[] {new PoissonDistribution(10.d), + new PoissonDistribution(5.d), new PoissonDistribution(20.d)}; final Random rand = new Random(42); final Double[] x = new Double[dims]; final List<Double> xList = Arrays.asList(x); @@ -201,8 +201,8 @@ public class ChangeFinder2DTest { if (i % 5 == 0) { mean[j] += 50.d; } - NormalDistribution normDist = new NormalDistribution(new Well19937c(i + j), - mean[j], sd[j]); + NormalDistribution normDist = + new NormalDistribution(new Well19937c(i + j), mean[j], sd[j]); data[j] = normDist.sample(len); data[j][len / (j + 2) + DIM % (j + 1)] = mean[j] + (j + 4) * sd[j]; } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java b/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java index 9b0885d..8bd8134 100644 --- a/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java +++ b/core/src/test/java/hivemall/classifier/GeneralClassifierUDTFTest.java @@ -65,7 +65,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-opt UnsupportedOpt"); @@ -77,7 +78,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-loss UnsupportedLoss"); @@ -89,7 +91,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-reg UnsupportedReg"); @@ -104,7 +107,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); udtf.initialize(new ObjectInspector[] {stringListOI, intOI}); @@ -123,7 +127,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector valueOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector featureListOI = ObjectInspectorFactory.getStandardListObjectInspector(featureOI); + ListObjectInspector featureListOI = + ObjectInspectorFactory.getStandardListObjectInspector(featureOI); udtf.initialize(new ObjectInspector[] {featureListOI, valueOI}); @@ -163,8 +168,8 @@ public class GeneralClassifierUDTFTest { @Test public void testLazyStringFeature() throws Exception { - LazyStringObjectInspector oi = LazyPrimitiveObjectInspectorFactory.getLazyStringObjectInspector( - false, (byte) 0); + LazyStringObjectInspector oi = + LazyPrimitiveObjectInspectorFactory.getLazyStringObjectInspector(false, (byte) 0); List<LazyString> x = Arrays.asList(lazyString("ãã¹ã:-2", oi), lazyString("æ¼¢å:-333.0", oi), lazyString("test:-1")); testFeature(x, oi, LazyString.class, String.class); @@ -235,7 +240,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, options); @@ -250,8 +256,9 @@ public class GeneralClassifierUDTFTest { double cumLoss = udtf.getCumulativeLoss(); println("Cumulative loss: " + cumLoss); double normalizedLoss = cumLoss / samplesList.size(); - Assert.assertTrue("cumLoss: " + cumLoss + ", normalizedLoss: " + normalizedLoss - + "\noptions: " + options, normalizedLoss < 0.5d); + Assert.assertTrue( + "cumLoss: " + cumLoss + ", normalizedLoss: " + normalizedLoss + "\noptions: " + options, + normalizedLoss < 0.5d); int numTests = 0; int numCorrect = 0; @@ -315,7 +322,8 @@ public class GeneralClassifierUDTFTest { GeneralClassifierUDTF udtf = new GeneralClassifierUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-opt SGD -loss logloss -reg L2 -lambda 0.1 -cv_rate 0.005"); @@ -372,12 +380,12 @@ public class GeneralClassifierUDTFTest { @Test public void testSerialization() throws HiveException { - TestUtils.testGenericUDTFSerialization( - GeneralClassifierUDTF.class, + TestUtils.testGenericUDTFSerialization(GeneralClassifierUDTF.class, new ObjectInspector[] { - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector), - PrimitiveObjectInspectorFactory.javaIntObjectInspector}, new Object[][] {{ - Arrays.asList("1:-2", "2:-1"), 0}}); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector), + PrimitiveObjectInspectorFactory.javaIntObjectInspector}, + new Object[][] {{Arrays.asList("1:-2", "2:-1"), 0}}); } private static void println(String msg) { http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/test/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTFTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTFTest.java b/core/src/test/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTFTest.java index ec5a382..ac6ab2e 100644 --- a/core/src/test/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTFTest.java +++ b/core/src/test/java/hivemall/classifier/KernelExpansionPassiveAggressiveUDTFTest.java @@ -50,7 +50,8 @@ public class KernelExpansionPassiveAggressiveUDTFTest { KernelExpansionPassiveAggressiveUDTF udtf = new KernelExpansionPassiveAggressiveUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); udtf.initialize(new ObjectInspector[] {stringListOI, intOI}); BufferedReader news20 = readFile("news20-small.binary.gz"); @@ -78,7 +79,8 @@ public class KernelExpansionPassiveAggressiveUDTFTest { KernelExpansionPassiveAggressiveUDTF udtf = new KernelExpansionPassiveAggressiveUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 0.01"); @@ -150,17 +152,18 @@ public class KernelExpansionPassiveAggressiveUDTFTest { @Test public void testSerialization() throws HiveException { - TestUtils.testGenericUDTFSerialization( - KernelExpansionPassiveAggressiveUDTF.class, + TestUtils.testGenericUDTFSerialization(KernelExpansionPassiveAggressiveUDTF.class, new ObjectInspector[] { - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector), - PrimitiveObjectInspectorFactory.javaIntObjectInspector}, new Object[][] {{ - Arrays.asList("1:-2", "2:-1"), 0}}); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector), + PrimitiveObjectInspectorFactory.javaIntObjectInspector}, + new Object[][] {{Arrays.asList("1:-2", "2:-1"), 0}}); } @Nonnull private static BufferedReader readFile(@Nonnull String fileName) throws IOException { - InputStream is = KernelExpansionPassiveAggressiveUDTFTest.class.getResourceAsStream(fileName); + InputStream is = + KernelExpansionPassiveAggressiveUDTFTest.class.getResourceAsStream(fileName); if (fileName.endsWith(".gz")) { is = new GZIPInputStream(is); } http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/c4036695/core/src/test/java/hivemall/classifier/PassiveAggressiveUDTFTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/hivemall/classifier/PassiveAggressiveUDTFTest.java b/core/src/test/java/hivemall/classifier/PassiveAggressiveUDTFTest.java index 721b777..5ccbaa2 100644 --- a/core/src/test/java/hivemall/classifier/PassiveAggressiveUDTFTest.java +++ b/core/src/test/java/hivemall/classifier/PassiveAggressiveUDTFTest.java @@ -43,24 +43,28 @@ public class PassiveAggressiveUDTFTest { public void testInitialize() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); /* test for INT_TYPE_NAME feature */ - StructObjectInspector intListSOI = udtf.initialize(new ObjectInspector[] {intListOI, intOI}); + StructObjectInspector intListSOI = + udtf.initialize(new ObjectInspector[] {intListOI, intOI}); assertEquals("struct<feature:int,weight:float>", intListSOI.getTypeName()); /* test for STRING_TYPE_NAME feature */ ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; - ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI); - StructObjectInspector stringListSOI = udtf.initialize(new ObjectInspector[] {stringListOI, - intOI}); + ListObjectInspector stringListOI = + ObjectInspectorFactory.getStandardListObjectInspector(stringOI); + StructObjectInspector stringListSOI = + udtf.initialize(new ObjectInspector[] {stringListOI, intOI}); assertEquals("struct<feature:string,weight:float>", stringListSOI.getTypeName()); /* test for BIGINT_TYPE_NAME feature */ ObjectInspector longOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; - ListObjectInspector longListOI = ObjectInspectorFactory.getStandardListObjectInspector(longOI); - StructObjectInspector longListSOI = udtf.initialize(new ObjectInspector[] {longListOI, - intOI}); + ListObjectInspector longListOI = + ObjectInspectorFactory.getStandardListObjectInspector(longOI); + StructObjectInspector longListSOI = + udtf.initialize(new ObjectInspector[] {longListOI, intOI}); assertEquals("struct<feature:bigint,weight:float>", longListSOI.getTypeName()); } @@ -68,7 +72,8 @@ public class PassiveAggressiveUDTFTest { public void testTrain() throws HiveException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); udtf.initialize(new ObjectInspector[] {intListOI, intOI}); /* train weights by List<Object> */ @@ -113,7 +118,8 @@ public class PassiveAggressiveUDTFTest { public void testPA1Eta() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 3.0"); @@ -134,7 +140,8 @@ public class PassiveAggressiveUDTFTest { public void testPA1EtaDefaultParameter() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); udtf.initialize(new ObjectInspector[] {intListOI, intOI}); float loss = 0.1f; @@ -148,7 +155,8 @@ public class PassiveAggressiveUDTFTest { public void testPA1TrainWithoutParameter() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); /* define aggressive parameter */ udtf.initialize(new ObjectInspector[] {intListOI, intOI}); @@ -167,7 +175,8 @@ public class PassiveAggressiveUDTFTest { public void testPA1TrainWithParameter() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 0.1"); @@ -188,7 +197,8 @@ public class PassiveAggressiveUDTFTest { public void testPA2EtaWithoutParameter() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA2(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); /* do initialize() with aggressiveness parameter */ udtf.initialize(new ObjectInspector[] {intListOI, intOI}); @@ -207,7 +217,8 @@ public class PassiveAggressiveUDTFTest { public void testPA2EtaWithParameter() throws UDFArgumentException { PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA2(); ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; - ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI); + ListObjectInspector intListOI = + ObjectInspectorFactory.getStandardListObjectInspector(intOI); ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 3.0"); @@ -226,22 +237,22 @@ public class PassiveAggressiveUDTFTest { @Test public void testPA1Serialization() throws HiveException { - TestUtils.testGenericUDTFSerialization( - PassiveAggressiveUDTF.PA1.class, + TestUtils.testGenericUDTFSerialization(PassiveAggressiveUDTF.PA1.class, new ObjectInspector[] { - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector), - PrimitiveObjectInspectorFactory.javaIntObjectInspector}, new Object[][] {{ - Arrays.asList("1:-2", "2:-1"), 0}}); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector), + PrimitiveObjectInspectorFactory.javaIntObjectInspector}, + new Object[][] {{Arrays.asList("1:-2", "2:-1"), 0}}); } @Test public void testPA2Serialization() throws HiveException { - TestUtils.testGenericUDTFSerialization( - PassiveAggressiveUDTF.PA2.class, + TestUtils.testGenericUDTFSerialization(PassiveAggressiveUDTF.PA2.class, new ObjectInspector[] { - ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector), - PrimitiveObjectInspectorFactory.javaIntObjectInspector}, new Object[][] {{ - Arrays.asList("1:-2", "2:-1"), 0}}); + ObjectInspectorFactory.getStandardListObjectInspector( + PrimitiveObjectInspectorFactory.javaStringObjectInspector), + PrimitiveObjectInspectorFactory.javaIntObjectInspector}, + new Object[][] {{Arrays.asList("1:-2", "2:-1"), 0}}); } }
