From 677b542090fb118f365704aca5b6358379f0bceb Mon Sep 17 00:00:00 2001 From: aaronshan Date: Wed, 27 Jul 2016 12:05:04 +0800 Subject: [PATCH] add or revise function description --- README.md | 16 ++++++++-------- .../functions/array/UDFArrayConcat.java | 4 ++++ .../functions/array/UDFArrayContains.java | 4 ++++ .../functions/array/UDFArrayDistinct.java | 4 ++++ .../functions/array/UDFArrayElementAt.java | 4 ++++ .../functions/array/UDFArrayIntersect.java | 4 ++++ .../functions/array/UDFArrayJoin.java | 4 ++++ .../shanruifeng/functions/array/UDFArrayMax.java | 4 ++++ .../shanruifeng/functions/array/UDFArrayMin.java | 4 ++++ .../functions/array/UDFArrayPosition.java | 4 ++++ .../functions/array/UDFArrayRemove.java | 4 ++++ .../functions/array/UDFArrayReverse.java | 4 ++++ .../functions/array/UDFArraySlice.java | 4 ++++ .../functions/array/UDFArraySort.java | 4 ++++ .../functions/array/UDFArrayValueCount.java | 4 ++++ .../functions/card/UDFChinaIdCardArea.java | 4 ++++ .../functions/card/UDFChinaIdCardBirthday.java | 4 ++++ .../functions/card/UDFChinaIdCardCity.java | 4 ++++ .../functions/card/UDFChinaIdCardGender.java | 4 ++++ .../functions/card/UDFChinaIdCardInfo.java | 4 ++++ .../functions/card/UDFChinaIdCardProvince.java | 4 ++++ .../functions/card/UDFChinaIdCardValid.java | 4 ++++ .../shanruifeng/functions/date/UDFDayOfWeek.java | 4 ++++ .../shanruifeng/functions/date/UDFTypeOfDay.java | 4 ++++ .../functions/date/UDFZodiacSignCn.java | 2 +- .../functions/date/UDFZodiacSignEn.java | 2 +- .../json/UDFJsonArrayExtractScalar.java | 4 ++++ .../functions/json/UDFJsonArrayGet.java | 4 ++++ .../functions/json/UDFJsonArrayLength.java | 4 ++++ .../functions/json/UDFJsonExtract.java | 4 ++++ .../functions/json/UDFJsonExtractScalar.java | 4 ++++ .../shanruifeng/functions/json/UDFJsonSize.java | 4 ++++ .../functions/string/UDFChineseToPinYin.java | 4 ++++ .../cc/shanruifeng/functions/string/UDFMd5.java | 4 ++++ .../shanruifeng/functions/string/UDFSha256.java | 4 ++++ 35 files changed, 138 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1af14ba..980fc88 100644 --- a/README.md +++ b/README.md @@ -51,19 +51,19 @@ You can also directly download file from [release page](https://github.com/aaron | function| description | |:--|:--| -|array_contains(array, value) -> boolean | whether ARRAY contains value or not.| -|array_intersect(array, array) -> array | returns the two array's intersection, without duplicates..| +|array_contains(array, E) -> boolean | whether array contains value or not.| +|array_intersect(array, array) -> array | returns the two array's intersection, without duplicates.| |array_max(array) -> E | returns the maximum value of input array.| |array_min(array) -> E | returns the minimum value of input array.| |array_join(array, delimiter, null_replacement) -> string | concatenates the elements of the given array using the delimiter and an optional `null_replacement` to replace nulls.| |array_distinct(array) -> array | remove duplicate values from the array.| -|array_position(array, value) -> long | returns the position of the first occurrence of the element in array (or 0 if not found).| -|array_remove(array, value) -> array | remove all elements that equal element from array.| +|array_position(array, E) -> long | returns the position of the first occurrence of the element in array (or 0 if not found).| +|array_remove(array, E) -> array | remove all elements that equal element from array.| |array_reverse(array) -> array | reverse the array element.| -|array_sort(array) -> array | sorts and returns the array x. The elements of x must be orderable..| +|array_sort(array) -> array | sorts and returns the array. The elements of array must be orderable.| |array_concat(array, array) -> array | concatenates two arrays.| -|array_value_count(array, value) -> long | count ARRAY's element number that element value equals given value.| -|array_slice(array, start, length) -> array | subsets array starting from index start (or starting from the end if start is negative) with a length of length| +|array_value_count(array, E) -> long | count array's element number that element value equals given value.| +|array_slice(array, start, length) -> array | subsets array starting from index start (or starting from the end if start is negative) with a length of length.| |array_element_at(array, index) -> E | returns element of array at given index. If index < 0, element_at accesses elements from the last to the first.| ### 3. date functions @@ -79,7 +79,7 @@ You can also directly download file from [release page](https://github.com/aaron | function| description | |:--|:--| |json_array_get(json, jsonPath) -> array(varchar) |returns the element at the specified index into the `json_array`. The index is zero-based.| -|json_array_length(json, jsonPath) -> array(varchar) |Returns the array length of `json` (a string containing a JSON array).| +|json_array_length(json, jsonPath) -> array(varchar) |returns the array length of `json` (a string containing a JSON array).| |json_array_extract(json, jsonPath) -> array(varchar) |extract json array by given jsonPath.| |json_array_extract_scalar(json, jsonPath) -> array(varchar) |like `json_array_extract`, but returns the result value as a string (as opposed to being encoded as JSON).| |json_extract(json, jsonPath) -> array(varchar) |extract json by given jsonPath.| diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayConcat.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayConcat.java index b6201ff..5c705fc 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayConcat.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayConcat.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -13,6 +14,9 @@ * @date 2016-07-26 * @time 17:30 */ +@Description(name = "array_concat" + , value = "_FUNC_(array, array) - concatenates two arrays." + , extended = "Example:\n > select _FUNC_(array, array) from src;") public class UDFArrayConcat extends GenericUDF { private static final int ARG_COUNT = 2; // Number of arguments to this UDF private transient ListObjectInspector leftArrayOI; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayContains.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayContains.java index 1837f5f..a0d13d0 100755 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayContains.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayContains.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.array; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -15,6 +16,9 @@ * @author ruifeng.shan * @date 2015-3-23 */ +@Description(name = "array_contains" + , value = "_FUNC_(array, E) - whether array contains value or not." + , extended = "Example:\n > select _FUNC_(array, value) from src;") public class UDFArrayContains extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayDistinct.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayDistinct.java index d7b7eff..e6910b2 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayDistinct.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayDistinct.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.ints.IntArrays; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-26 * @time 17:29 */ +@Description(name = "array_distinct" + , value = "_FUNC_(array) - remove duplicate values from the array." + , extended = "Example:\n > select _FUNC_(array) from src;") public class UDFArrayDistinct extends GenericUDF { private static final int INITIAL_SIZE = 128; private static final int ARG_COUNT = 1; // Number of arguments to this UDF diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayElementAt.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayElementAt.java index d1c1926..346efd7 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayElementAt.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayElementAt.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.array; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-27 * @time 10:09 */ +@Description(name = "array_element_at" + , value = "_FUNC_(array, index) - returns element of array at given index. If index < 0, element_at accesses elements from the last to the first." + , extended = "Example:\n > select _FUNC_(array, index) from src;") public class UDFArrayElementAt extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayIntersect.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayIntersect.java index fb426bb..4c6ccfc 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayIntersect.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayIntersect.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.ints.IntArrays; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -17,6 +18,9 @@ * @date 2016-07-26 * @time 11:57 */ +@Description(name = "array_intersect" + , value = "_FUNC_(array, array) - returns the two array's intersection, without duplicates." + , extended = "Example:\n > select _FUNC_(array, array) from src;") public class UDFArrayIntersect extends GenericUDF { private static final int INITIAL_SIZE = 128; private static final int ARG_COUNT = 2; // Number of arguments to this UDF diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayJoin.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayJoin.java index 5caf408..e9e7172 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayJoin.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayJoin.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.array; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -17,6 +18,9 @@ * @date 2016-07-26 * @time 17:31 */ +@Description(name = "array_join" + , value = "_FUNC_(array, delimiter, null_replacement) - concatenates the elements of the given array using the delimiter and an optional null_replacement to replace nulls." + , extended = "Example:\n > select _FUNC_(array, delimiter) from src;\n> select _FUNC_(array, delimiter, null_replacement) from src;") public class UDFArrayJoin extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayMax.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayMax.java index d1519da..db89426 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayMax.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayMax.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import it.unimi.dsi.fastutil.ints.IntArrays; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -17,6 +18,9 @@ * @date 2016-07-26 * @time 17:31 */ +@Description(name = "array_max" + , value = "_FUNC_(array) - returns the maximum value of input array." + , extended = "Example:\n > select _FUNC_(array) from src;") public class UDFArrayMax extends GenericUDF { private static final int INITIAL_SIZE = 128; private static final int ARG_COUNT = 1; // Number of arguments to this UDF diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayMin.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayMin.java index db4832d..9678a98 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayMin.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayMin.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import it.unimi.dsi.fastutil.ints.IntArrays; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -17,6 +18,9 @@ * @date 2016-07-26 * @time 17:32 */ +@Description(name = "array_min" + , value = "_FUNC_(array) - returns the minimum value of input array." + , extended = "Example:\n > select _FUNC_(array) from src;") public class UDFArrayMin extends GenericUDF { private static final int INITIAL_SIZE = 128; private static final int ARG_COUNT = 1; // Number of arguments to this UDF diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayPosition.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayPosition.java index ed299d3..4c6efcf 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayPosition.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayPosition.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.array; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-26 * @time 17:32 */ +@Description(name = "array_position" + , value = "_FUNC_(array, E) - returns the position of the first occurrence of the element in array (or 0 if not found)." + , extended = "Example:\n > select _FUNC_(array, value) from src;") public class UDFArrayPosition extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayRemove.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayRemove.java index 20cbcd2..c7dc6b8 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayRemove.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayRemove.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-26 * @time 18:07 */ +@Description(name = "array_remove" + , value = "_FUNC_(array, E) - remove all elements that equal element from array." + , extended = "Example:\n > select _FUNC_(array, value) from src;") public class UDFArrayRemove extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayReverse.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayReverse.java index 58caabc..ce45ba9 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayReverse.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayReverse.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -13,6 +14,9 @@ * @date 2016-07-26 * @time 18:03 */ +@Description(name = "array_reverse" + , value = "_FUNC_(array) - reverse the array element." + , extended = "Example:\n > select _FUNC_(array) from src;") public class UDFArrayReverse extends GenericUDF { private static final int ARG_COUNT = 1; // Number of arguments to this UDF private transient ListObjectInspector arrayOI; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArraySlice.java b/src/main/java/cc/shanruifeng/functions/array/UDFArraySlice.java index 9475bf2..7f65937 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArraySlice.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArraySlice.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.array; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -18,6 +19,9 @@ * @date 2016-07-27 * @time 10:24 */ +@Description(name = "array_slice" + , value = "_FUNC_(array, start, length) - subsets array starting from index start (or starting from the end if start is negative) with a length of length." + , extended = "Example:\n > select _FUNC_(array, start, length) from src;") public class UDFArraySlice extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArraySort.java b/src/main/java/cc/shanruifeng/functions/array/UDFArraySort.java index 33cc9a8..85961af 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArraySort.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArraySort.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.ints.IntArrays; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-26 * @time 17:32 */ +@Description(name = "array_sort" + , value = "_FUNC_(array) - sorts and returns the array. The elements of array must be orderable." + , extended = "Example:\n > select _FUNC_(array) from src;") public class UDFArraySort extends GenericUDF { private static final int INITIAL_SIZE = 128; private static final int ARG_COUNT = 1; // Number of arguments to this UDF diff --git a/src/main/java/cc/shanruifeng/functions/array/UDFArrayValueCount.java b/src/main/java/cc/shanruifeng/functions/array/UDFArrayValueCount.java index eaeaa1b..ecdbf6a 100644 --- a/src/main/java/cc/shanruifeng/functions/array/UDFArrayValueCount.java +++ b/src/main/java/cc/shanruifeng/functions/array/UDFArrayValueCount.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.array; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; @@ -16,6 +17,9 @@ * @date 2016-07-26 * @time 20:58 */ +@Description(name = "array_value_count" + , value = "_FUNC_(array, E) - count array's element number that element value equals given value." + , extended = "Example:\n > select _FUNC_(array, value) from src;") public class UDFArrayValueCount extends GenericUDF { private static final int ARRAY_IDX = 0; diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardArea.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardArea.java index 736e3ca..15ee4bc 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardArea.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardArea.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 20:12 */ +@Description(name = "id_card_area" + , value = "_FUNC_(string) - get area by given china id card." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardArea extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardBirthday.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardBirthday.java index b33c7e1..6e65fc8 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardBirthday.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardBirthday.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 20:14 */ +@Description(name = "id_card_birthday" + , value = "_FUNC_(string) - get birthday by given china id card." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardBirthday extends UDF{ private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardCity.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardCity.java index adf45a1..fc81038 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardCity.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardCity.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 20:11 */ +@Description(name = "id_card_city" + , value = "_FUNC_(string) - get city by given china id card." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardCity extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardGender.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardGender.java index ae484cd..f0c8ced 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardGender.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardGender.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 20:14 */ +@Description(name = "id_card_gender" + , value = "_FUNC_(string) - get gender by given china id card." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardGender extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardInfo.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardInfo.java index 7401dd5..f5ed6c2 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardInfo.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardInfo.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ */ //身份证->json +@Description(name = "id_card_info" + , value = "_FUNC_(string) - get all info by given china id card, output is json string." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardInfo extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardProvince.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardProvince.java index 706bbee..efcffc6 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardProvince.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardProvince.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 19:42 */ +@Description(name = "id_card_province" + , value = "_FUNC_(string) - get province by given china id card." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardProvince extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardValid.java b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardValid.java index 81b9883..279a061 100644 --- a/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardValid.java +++ b/src/main/java/cc/shanruifeng/functions/card/UDFChinaIdCardValid.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.card; import cc.shanruifeng.functions.utils.CardUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.BooleanWritable; import org.apache.hadoop.io.Text; @@ -10,6 +11,9 @@ * @date 2016-07-25 * @time 20:15 */ +@Description(name = "is_valid_id_card" + , value = "_FUNC_(string) - whether given china id card is valid or not." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChinaIdCardValid extends UDF { private BooleanWritable result = new BooleanWritable(); diff --git a/src/main/java/cc/shanruifeng/functions/date/UDFDayOfWeek.java b/src/main/java/cc/shanruifeng/functions/date/UDFDayOfWeek.java index 32b57bd..982e776 100755 --- a/src/main/java/cc/shanruifeng/functions/date/UDFDayOfWeek.java +++ b/src/main/java/cc/shanruifeng/functions/date/UDFDayOfWeek.java @@ -1,5 +1,6 @@ package cc.shanruifeng.functions.date; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.serde2.io.TimestampWritable; import org.apache.hadoop.io.IntWritable; @@ -14,6 +15,9 @@ * @author ruifeng.shan * @date 15-8-31 */ +@Description(name = "day_of_week" + , value = "_FUNC_(date) - day of week. if monday, return 1, tuesday return 2 ... sunday return 7." + , extended = "Example:\n > select _FUNC_(date_string) from src;\n > select _FUNC_(date) from src;") public class UDFDayOfWeek extends UDF { public final static DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); diff --git a/src/main/java/cc/shanruifeng/functions/date/UDFTypeOfDay.java b/src/main/java/cc/shanruifeng/functions/date/UDFTypeOfDay.java index 6a5d113..9fde811 100755 --- a/src/main/java/cc/shanruifeng/functions/date/UDFTypeOfDay.java +++ b/src/main/java/cc/shanruifeng/functions/date/UDFTypeOfDay.java @@ -3,6 +3,7 @@ import cc.shanruifeng.functions.utils.ConfigUtils; import java.util.Calendar; import java.util.Map; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.serde2.io.TimestampWritable; import org.apache.hadoop.io.IntWritable; @@ -15,6 +16,9 @@ * @author ruifeng.shan * @date 15-9-1 */ +@Description(name = "type_of_day" + , value = "_FUNC_(date) - get type of day in china. if normal festival, return 1; if weekend, return 2, if workday return 3, if weekend or festival but work, return 4; if error, return null." + , extended = "Example:\n > select _FUNC_(date_string) from src;\n > select _FUNC_(date) from src;") public class UDFTypeOfDay extends UDF { public final static DateTimeFormatter DEFAULT_DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); public final static Map dayMap = ConfigUtils.getDayMap(); diff --git a/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignCn.java b/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignCn.java index 4e8e10c..be3ee30 100644 --- a/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignCn.java +++ b/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignCn.java @@ -13,7 +13,7 @@ /** * Created by ruifengshan on 16/3/18. */ -@Description(name = "zodiacCn" +@Description(name = "zodiac_cn" , value = "_FUNC_(date) - from the input date string or separate month and day arguments, returns the sing of the Zodiac." , extended = "Example:\n > select _FUNC_(date_string) from src;\n > select _FUNC_(month, day) from src;") public class UDFZodiacSignCn extends UDF { diff --git a/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignEn.java b/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignEn.java index cd795a1..3e8b2df 100644 --- a/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignEn.java +++ b/src/main/java/cc/shanruifeng/functions/date/UDFZodiacSignEn.java @@ -13,7 +13,7 @@ /** * Created by ruifengshan on 16/3/18. */ -@Description(name = "zodiacEn" +@Description(name = "zodiac_en" , value = "_FUNC_(date) - from the input date string or separate month and day arguments, returns the sing of the Zodiac." , extended = "Example:\n > select _FUNC_(date_string) from src;\n > select _FUNC_(month, day) from src;") public class UDFZodiacSignEn extends UDF { diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayExtractScalar.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayExtractScalar.java index de5708b..713bee0 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayExtractScalar.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayExtractScalar.java @@ -4,6 +4,7 @@ import cc.shanruifeng.functions.utils.json.JsonPath; import cc.shanruifeng.functions.utils.json.JsonUtils; import java.util.ArrayList; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException; import org.apache.hadoop.hive.ql.metadata.HiveException; @@ -19,6 +20,9 @@ * @date 2016-07-25 * @time 15:33 */ +@Description(name = "json_array_extract_scalar", value = "_FUNC_(json, json_path) - extract json array by given jsonPath. but returns the result value as a string (as opposed to being encoded as JSON)." + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonArrayExtractScalar extends GenericUDF { private ObjectInspectorConverters.Converter[] converters; diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayGet.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayGet.java index 9876571..8987b82 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayGet.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayGet.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.json; import cc.shanruifeng.functions.utils.json.JsonUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -9,6 +10,9 @@ * @date 2016-07-25 * @time 15:29 */ +@Description(name = "json_array_get", value = "_FUNC_(json, json_path) - returns the element at the specified index into the json_array. The index is zero-based.. " + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonArrayGet extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayLength.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayLength.java index ed82f35..4bfa91b 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayLength.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonArrayLength.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.json; import cc.shanruifeng.functions.utils.json.JsonUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; @@ -10,6 +11,9 @@ * @date 2016-07-25 * @time 14:57 */ +@Description(name = "json_array_length", value = "_FUNC_(json, json_path) - Returns the array length of json (a string containing a JSON array). " + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonArrayLength extends UDF { private LongWritable result = new LongWritable(); diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtract.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtract.java index 065be57..3f57c7e 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtract.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtract.java @@ -2,6 +2,7 @@ import cc.shanruifeng.functions.utils.json.JsonExtract; import cc.shanruifeng.functions.utils.json.JsonPath; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -10,6 +11,9 @@ * @date 2016-07-25 * @time 16:26 */ +@Description(name = "json_extract", value = "_FUNC_(json, json_path) - extract json by given jsonPath. " + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonExtract extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtractScalar.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtractScalar.java index 87907b8..6af6884 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtractScalar.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonExtractScalar.java @@ -2,6 +2,7 @@ import cc.shanruifeng.functions.utils.json.JsonExtract; import cc.shanruifeng.functions.utils.json.JsonPath; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -10,6 +11,9 @@ * @date 2016-07-25 * @time 16:26 */ +@Description(name = "json_extract_scalar", value = "_FUNC_(json, json_path) - like json_extract, but returns the result value as a string (as opposed to being encoded as JSON). " + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonExtractScalar extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/json/UDFJsonSize.java b/src/main/java/cc/shanruifeng/functions/json/UDFJsonSize.java index 5ea0bb3..71e6cf8 100644 --- a/src/main/java/cc/shanruifeng/functions/json/UDFJsonSize.java +++ b/src/main/java/cc/shanruifeng/functions/json/UDFJsonSize.java @@ -4,6 +4,7 @@ import cc.shanruifeng.functions.utils.json.JsonPath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; @@ -13,6 +14,9 @@ * @date 2016-07-25 * @time 16:33 */ +@Description(name = "json_size", value = "_FUNC_(json, json_path) - like json_extract, but returns the size of the value. For objects or arrays, the size is the number of members, and the size of a scalar value is zero. " + , extended = "Example:\n" + + " > SELECT _FUNC_(json_array, json_path) FROM src LIMIT 1;") public class UDFJsonSize extends UDF{ private LongWritable result = new LongWritable(); diff --git a/src/main/java/cc/shanruifeng/functions/string/UDFChineseToPinYin.java b/src/main/java/cc/shanruifeng/functions/string/UDFChineseToPinYin.java index 40ac2c0..b468748 100755 --- a/src/main/java/cc/shanruifeng/functions/string/UDFChineseToPinYin.java +++ b/src/main/java/cc/shanruifeng/functions/string/UDFChineseToPinYin.java @@ -6,6 +6,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; @@ -16,6 +17,9 @@ * Author: ruifengshan * Date: 23/03/2015 */ +@Description(name = "pinyin" + , value = "_FUNC_(string) - get pinyin by given chinese." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFChineseToPinYin extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/string/UDFMd5.java b/src/main/java/cc/shanruifeng/functions/string/UDFMd5.java index 2511413..807b6bf 100644 --- a/src/main/java/cc/shanruifeng/functions/string/UDFMd5.java +++ b/src/main/java/cc/shanruifeng/functions/string/UDFMd5.java @@ -1,12 +1,16 @@ package cc.shanruifeng.functions.string; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.io.Text; /** * Created by ruifengshan on 16/3/18. */ +@Description(name = "md5" + , value = "_FUNC_(string) - get md5 hash code by given input string." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFMd5 extends UDF { private Text result = new Text(); diff --git a/src/main/java/cc/shanruifeng/functions/string/UDFSha256.java b/src/main/java/cc/shanruifeng/functions/string/UDFSha256.java index b7d4434..df4d05d 100644 --- a/src/main/java/cc/shanruifeng/functions/string/UDFSha256.java +++ b/src/main/java/cc/shanruifeng/functions/string/UDFSha256.java @@ -1,6 +1,7 @@ package cc.shanruifeng.functions.string; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.hadoop.hive.ql.exec.Description; import org.apache.hadoop.io.Text; /** @@ -8,6 +9,9 @@ * @date 2016-07-25 * @time 14:29 */ +@Description(name = "sha256" + , value = "_FUNC_(string) - get sha256 hash code by given input string." + , extended = "Example:\n > select _FUNC_(string) from src;") public class UDFSha256 { private Text result = new Text();