diff --git common/src/java/org/apache/hive/common/util/AnnotationUtils.java common/src/java/org/apache/hive/common/util/AnnotationUtils.java deleted file mode 100644 index be41a79..0000000 --- common/src/java/org/apache/hive/common/util/AnnotationUtils.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hive.common.util; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -public class AnnotationUtils { - - // to avoid https://bugs.openjdk.java.net/browse/JDK-7122142 - public static T getAnnotation(Class clazz, Class annotationClass) { - synchronized (annotationClass) { - return clazz.getAnnotation(annotationClass); - } - } - - // to avoid https://bugs.openjdk.java.net/browse/JDK-7122142 - public static T getAnnotation(Method method, Class annotationClass) { - synchronized (annotationClass) { - return method.getAnnotation(annotationClass); - } - } -} diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java index 40ec4e5..0ffd16c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java @@ -198,7 +198,6 @@ import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.util.ToolRunner; -import org.apache.hive.common.util.AnnotationUtils; import org.stringtemplate.v4.ST; /** @@ -3215,7 +3214,7 @@ private int describeFunction(DescFunctionDesc descFunc) throws HiveException { funcClass = functionInfo.getFunctionClass(); } if (funcClass != null) { - desc = AnnotationUtils.getAnnotation(funcClass, Description.class); + desc = funcClass.getAnnotation(Description.class); } if (desc != null) { outStream.writeBytes(desc.value().replace("_FUNC_", funcName)); diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java index e238ff1..5e11a5c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java @@ -44,6 +44,7 @@ import org.apache.hadoop.hive.ql.Driver; import org.apache.hadoop.hive.ql.DriverContext; import org.apache.hadoop.hive.ql.hooks.ReadEntity; +import org.apache.hadoop.hive.ql.metadata.AuthorizationException; import org.apache.hadoop.hive.ql.metadata.Table; import org.apache.hadoop.hive.ql.optimizer.physical.StageIDsRearranger; import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; @@ -57,7 +58,6 @@ import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.util.StringUtils; -import org.apache.hive.common.util.AnnotationUtils; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -143,9 +143,7 @@ public JSONObject getJSONLogicalPlan(PrintStream out, ExplainWork work) throws E } if (work.getParseContext() != null) { - if (out != null) { - out.print("LOGICAL PLAN:"); - } + out.print("LOGICAL PLAN:"); JSONObject jsonPlan = outputMap(work.getParseContext().getTopOps(), true, out, jsonOutput, work.getExtended(), 0); if (out != null) { @@ -528,7 +526,7 @@ private JSONObject outputPlan(Serializable work, private JSONObject outputPlan(Serializable work, PrintStream out, boolean extended, boolean jsonOutput, int indent, String appendToHeader) throws Exception { // Check if work has an explain annotation - Annotation note = AnnotationUtils.getAnnotation(work.getClass(), Explain.class); + Annotation note = work.getClass().getAnnotation(Explain.class); String keyJSONObject = null; @@ -587,7 +585,7 @@ private JSONObject outputPlan(Serializable work, PrintStream out, for (Method m : methods) { int prop_indents = jsonOutput ? 0 : indent + 2; - note = AnnotationUtils.getAnnotation(m, Explain.class); + note = m.getAnnotation(Explain.class); if (note instanceof Explain) { Explain xpl_note = (Explain) note; diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java index 074255b..da2b3c7 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java @@ -25,7 +25,6 @@ import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF; import org.apache.hadoop.hive.ql.udf.ptf.TableFunctionResolver; import org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction; -import org.apache.hive.common.util.AnnotationUtils; /** * FunctionInfo. @@ -75,8 +74,7 @@ public FunctionInfo(String displayName, Class t { this.displayName = displayName; this.tableFunctionResolver = tFnCls; - PartitionTableFunctionDescription def = AnnotationUtils.getAnnotation( - tableFunctionResolver, PartitionTableFunctionDescription.class); + PartitionTableFunctionDescription def = tableFunctionResolver.getAnnotation(PartitionTableFunctionDescription.class); this.isNative = (def == null) ? false : def.isInternal(); this.isInternalTableFunction = isNative; } @@ -138,7 +136,7 @@ public GenericUDAFResolver getGenericUDAFResolver() { } /** - * Get the display name for this function. This should be transferred into + * Get the display name for this function. This should be transfered into * exprNodeGenericUDFDesc, and will be used as the first parameter to * GenericUDF.getDisplayName() call, instead of hard-coding the function name. * This will solve the problem of displaying only one name when a udf is diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java index 0c6a3d4..a80feb9 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java @@ -144,7 +144,6 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.util.ReflectionUtils; -import org.apache.hive.common.util.AnnotationUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -1614,14 +1613,14 @@ public static boolean isDeterministic(GenericUDF genericUDF) { // the deterministic annotation declares return false; } - UDFType genericUDFType = AnnotationUtils.getAnnotation(genericUDF.getClass(), UDFType.class); + UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); if (genericUDFType != null && genericUDFType.deterministic() == false) { return false; } if (genericUDF instanceof GenericUDFBridge) { GenericUDFBridge bridge = (GenericUDFBridge) (genericUDF); - UDFType bridgeUDFType = AnnotationUtils.getAnnotation(bridge.getUdfClass(), UDFType.class); + UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); if (bridgeUDFType != null && bridgeUDFType.deterministic() == false) { return false; } @@ -1639,14 +1638,14 @@ public static boolean isDeterministic(GenericUDF genericUDF) { * Returns whether a GenericUDF is stateful or not. */ public static boolean isStateful(GenericUDF genericUDF) { - UDFType genericUDFType = AnnotationUtils.getAnnotation(genericUDF.getClass(), UDFType.class); + UDFType genericUDFType = genericUDF.getClass().getAnnotation(UDFType.class); if (genericUDFType != null && genericUDFType.stateful()) { return true; } if (genericUDF instanceof GenericUDFBridge) { GenericUDFBridge bridge = (GenericUDFBridge) genericUDF; - UDFType bridgeUDFType = AnnotationUtils.getAnnotation(bridge.getUdfClass(), UDFType.class); + UDFType bridgeUDFType = bridge.getUdfClass().getAnnotation(UDFType.class); if (bridgeUDFType != null && bridgeUDFType.stateful()) { return true; } @@ -1885,7 +1884,7 @@ public static WindowFunctionInfo getWindowFunctionInfo(String functionName) { /** * Both UDF and UDAF functions can imply order for analytical functions * - * @param functionName + * @param name * name of function * @return true if a GenericUDF or GenericUDAF exists for this name and implyOrder is true, false * otherwise. @@ -1895,8 +1894,7 @@ public static boolean impliesOrder(String functionName) { FunctionInfo info = getFunctionInfo(functionName); if (info != null) { if (info.isGenericUDF()) { - UDFType type = - AnnotationUtils.getAnnotation(info.getGenericUDF().getClass(), UDFType.class); + UDFType type = info.getGenericUDF().getClass().getAnnotation(UDFType.class); if (type != null) { return type.impliesOrder(); } @@ -1963,8 +1961,7 @@ public static boolean isRankingFunction(String name){ FunctionInfo info = getFunctionInfo(name); GenericUDAFResolver res = info.getGenericUDAFResolver(); if (res != null){ - WindowFunctionDescription desc = - AnnotationUtils.getAnnotation(res.getClass(), WindowFunctionDescription.class); + WindowFunctionDescription desc = res.getClass().getAnnotation(WindowFunctionDescription.class); if (desc != null){ return desc.rankingFunction(); } diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java index 9b2d787..37139a7 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/WindowFunctionInfo.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hive.ql.exec; import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver; -import org.apache.hive.common.util.AnnotationUtils; @SuppressWarnings("deprecation") public class WindowFunctionInfo implements CommonFunctionInfo @@ -34,8 +33,7 @@ assert fInfo.isGenericUDAF(); this.fInfo = fInfo; Class wfnCls = fInfo.getGenericUDAFResolver().getClass(); - WindowFunctionDescription def = - AnnotationUtils.getAnnotation(wfnCls, WindowFunctionDescription.class); + WindowFunctionDescription def = wfnCls.getAnnotation(WindowFunctionDescription.class); if ( def != null) { supportsWindow = def.supportsWindow(); diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorExpressionDescriptor.java ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorExpressionDescriptor.java index 2d67b5b..bfdd3ce 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorExpressionDescriptor.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorExpressionDescriptor.java @@ -20,7 +20,6 @@ import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression; import org.apache.hadoop.hive.ql.metadata.HiveException; -import org.apache.hive.common.util.AnnotationUtils; /** * Describes a vector expression and encapsulates the {@link Mode}, number of arguments, @@ -220,8 +219,7 @@ public String toString() { } public Class getVectorExpressionClass(Class udf, Descriptor descriptor) throws HiveException { - VectorizedExpressions annotation = - AnnotationUtils.getAnnotation(udf, VectorizedExpressions.class); + VectorizedExpressions annotation = udf.getAnnotation(VectorizedExpressions.class); if (annotation == null || annotation.value() == null) { return null; } diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java index b129ddd..68f8fd8 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java @@ -72,7 +72,6 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory; import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspector; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; -import org.apache.hive.common.util.AnnotationUtils; import org.apache.thrift.TException; import com.google.common.collect.Lists; @@ -230,7 +229,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, // our stats for NDV is approx, not accurate. return null; } - if (aggr.getGenericUDAFName().equals(AnnotationUtils.getAnnotation(GenericUDAFSum.class, + if (aggr.getGenericUDAFName().equals(GenericUDAFSum.class.getAnnotation( Description.class).name())) { if(!(aggr.getParameters().get(0) instanceof ExprNodeConstantDesc)){ return null; @@ -244,7 +243,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, ois.add(PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector( PrimitiveCategory.DECIMAL)); } - else if (aggr.getGenericUDAFName().equals(AnnotationUtils.getAnnotation(GenericUDAFCount.class, + else if (aggr.getGenericUDAFName().equals(GenericUDAFCount.class.getAnnotation( Description.class).name())) { Long rowCnt = 0L; if ((aggr.getParameters().isEmpty() || aggr.getParameters().get(0) instanceof diff --git ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java index 4475b76..5aa3e82 100644 --- ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/plan/GroupByDesc.java @@ -23,7 +23,6 @@ import org.apache.hadoop.hive.ql.udf.UDFType; import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; -import org.apache.hive.common.util.AnnotationUtils; /** * GroupByDesc. @@ -229,7 +228,7 @@ public boolean isDistinctLike() { for (AggregationDesc ad : aggregators) { if (!ad.getDistinct()) { GenericUDAFEvaluator udafEval = ad.getGenericUDAFEvaluator(); - UDFType annot = AnnotationUtils.getAnnotation(udafEval.getClass(), UDFType.class); + UDFType annot = udafEval.getClass().getAnnotation(UDFType.class); if (annot == null || !annot.distinctLike()) { return false; } diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java index 4b22a5b..3bd97b0 100644 --- ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java @@ -26,7 +26,6 @@ import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef; import org.apache.hadoop.hive.ql.udf.UDFType; import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; -import org.apache.hive.common.util.AnnotationUtils; /** * A Generic User-defined aggregation function (GenericUDAF) for the use with @@ -50,7 +49,7 @@ public static boolean isEstimable(AggregationBuffer buffer) { if (buffer instanceof AbstractAggregationBuffer) { Class clazz = buffer.getClass(); - AggregationType annotation = AnnotationUtils.getAnnotation(clazz, AggregationType.class); + AggregationType annotation = clazz.getAnnotation(AggregationType.class); return annotation != null && annotation.estimable(); } return false; @@ -95,7 +94,7 @@ public GenericUDAFEvaluator() { * Additionally setup GenericUDAFEvaluator with MapredContext before initializing. * This is only called in runtime of MapRedTask. * - * @param mapredContext context + * @param context context */ public void configure(MapredContext mapredContext) { }