pkumarsinha commented on a change in pull request #2724: URL: https://github.com/apache/hive/pull/2724#discussion_r744418558
########## File path: ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFDeserialize.java ########## @@ -0,0 +1,96 @@ +/* + * 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.hadoop.hive.ql.udf.generic; + +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.messaging.MessageEncoder; +import org.apache.hadoop.hive.metastore.messaging.MessageFactory; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.exec.UDFArgumentException; +import org.apache.hadoop.io.Text; +import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; + +/** + * TestGenericUDFDeserialize. Review comment: Add description ########## File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ########## @@ -696,7 +696,8 @@ private static void populateLlapDaemonVarsSet(Set<String> llapDaemonVarsSetLocal + "attempted using the snapshot based approach. If disabled, the replication will fail in case the target is " + "modified."), REPL_STATS_TOP_EVENTS_COUNTS("hive.repl.stats.events.count", 5, - "Number of top costliest events that needs to maintained per event type for the replication statistics."), + "Number of top costliest events that needs to maintained per event type for the replication statistics." + + " Maximum permissible limit is 10."), Review comment: fix typo ########## File path: ql/src/java/org/apache/hadoop/hive/ql/parse/repl/metric/ReplicationMetricCollector.java ########## @@ -105,6 +110,21 @@ public void reportFailoverStart(String stageName, Map<String, Long> metricMap, } } + private void updateRMProgressIfLimitExceeds(Progress progress, Stage stage) throws SemanticException { + MessageSerializer serializer = MessageFactory.getDefaultInstanceForReplMetrics(conf).getSerializer(); + ObjectMapper mapper = new ObjectMapper(); + String serializedProgress = null; + try { + serializedProgress = serializer.serialize(mapper.writeValueAsString(progress)); + } catch (Exception e) { + throw new SemanticException(e); + } + if (serializedProgress.length() > ReplStatsTracker.RM_PROGRESS_LENGTH) { + stage.setReplStats("Error: RM_PROGRESS limit exceeded to " + serializedProgress.length()); Review comment: Add a log line too ########## File path: ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFDeserialize.java ########## @@ -0,0 +1,96 @@ +/* + * 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.hadoop.hive.ql.udf.generic; + +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.messaging.MessageEncoder; +import org.apache.hadoop.hive.metastore.messaging.MessageFactory; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.exec.UDFArgumentException; +import org.apache.hadoop.io.Text; +import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; + +/** + * TestGenericUDFDeserialize. + */ +public class TestGenericUDFDeserialize { + + @Test + public void testOneArg() throws HiveException { + GenericUDFDeserialize udf = new GenericUDFDeserialize(); + ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; + ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; + UDFArgumentException ex = null; + try { + udf.initialize(new ObjectInspector[]{valueOI1}); + } catch (UDFArgumentException e) { + ex = e; + } + assertNotNull("The function deserialize() accepts 2 argument.", ex); Review comment: Assert from exception message ########## File path: ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFDeserialize.java ########## @@ -0,0 +1,96 @@ +/* + * 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.hadoop.hive.ql.udf.generic; + +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.messaging.MessageEncoder; +import org.apache.hadoop.hive.metastore.messaging.MessageFactory; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.exec.UDFArgumentException; +import org.apache.hadoop.io.Text; +import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; + +/** + * TestGenericUDFDeserialize. + */ +public class TestGenericUDFDeserialize { + + @Test + public void testOneArg() throws HiveException { + GenericUDFDeserialize udf = new GenericUDFDeserialize(); + ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; + ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.writableStringObjectInspector; + UDFArgumentException ex = null; + try { + udf.initialize(new ObjectInspector[]{valueOI1}); + } catch (UDFArgumentException e) { + ex = e; + } + assertNotNull("The function deserialize() accepts 2 argument.", ex); + ex = null; + try { + udf.initialize(new ObjectInspector[]{valueOI2, valueOI1}); + } catch (UDFArgumentException e) { + ex = e; + } + assertNull("The function deserialize() accepts 2 argument.", ex); Review comment: Assert from exception message ########## File path: ql/src/java/org/apache/hadoop/hive/ql/parse/repl/metric/MetricSink.java ########## @@ -116,14 +116,17 @@ public void run() { int totalMetricsSize = metrics.size(); List<ReplicationMetrics> replicationMetricsList = new ArrayList<>(totalMetricsSize); ObjectMapper mapper = new ObjectMapper(); + MessageEncoder encoder = MessageFactory.getDefaultInstanceForReplMetrics(conf); for (int index = 0; index < totalMetricsSize; index++) { ReplicationMetric metric = metrics.removeFirst(); ReplicationMetrics persistentMetric = new ReplicationMetrics(); persistentMetric.setDumpExecutionId(metric.getDumpExecutionId()); persistentMetric.setScheduledExecutionId(metric.getScheduledExecutionId()); persistentMetric.setPolicy(metric.getPolicy()); - persistentMetric.setProgress(mapper.writeValueAsString(metric.getProgress())); + persistentMetric.setProgress( + encoder.getSerializer().serialize(mapper.writeValueAsString(metric.getProgress()))); Review comment: We will end up doing serialization twice. Can you pls move the column limit check right here so that we do it just once? ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java ########## @@ -14364,17 +14364,22 @@ public void addReplicationMetrics(ReplicationMetricList replicationMetricList) { mReplicationMetrics.setStartTime((int) (System.currentTimeMillis()/1000)); } if (!StringUtils.isEmpty(replicationMetric.getMetadata())) { - mReplicationMetrics.setMetadata(replicationMetric.getMetadata()); + if (replicationMetric.getMetadata().length() > 4000) { Review comment: Define constants for these limit numbers -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
