This is an automated email from the ASF dual-hosted git repository.

rameshkumar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 85f6162becb HIVE-27687 Logger variable should be static final as its 
creation takes more time in query compilation (#4692). (Ramesh Kumar reviewed 
by Stamatis Zampetakis)
85f6162becb is described below

commit 85f6162becb8723ff6c9f85875048ced6ca7ae89
Author: Ramesh Kumar <[email protected]>
AuthorDate: Fri Sep 29 08:56:51 2023 -0700

    HIVE-27687 Logger variable should be static final as its creation takes 
more time in query compilation (#4692). (Ramesh Kumar reviewed by Stamatis 
Zampetakis)
---
 .../java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java |  6 ++++--
 .../src/main/java/org/apache/hive/hcatalog/data/JsonSerDe.java |  8 ++++++--
 .../src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java      |  6 +++++-
 .../apache/hadoop/hive/serde2/AbstractEncodingAwareSerDe.java  |  2 +-
 .../src/java/org/apache/hadoop/hive/serde2/AbstractSerDe.java  |  4 ++--
 serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java   | 10 +++++++---
 6 files changed, 25 insertions(+), 11 deletions(-)

diff --git 
a/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java 
b/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java
index ff8fb8f339d..1bb77ba6976 100644
--- a/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java
+++ b/contrib/src/java/org/apache/hadoop/hive/contrib/serde2/RegexSerDe.java
@@ -76,6 +76,8 @@ import org.apache.hadoop.io.Writable;
     RegexSerDe.INPUT_REGEX_CASE_SENSITIVE })
 public class RegexSerDe extends AbstractEncodingAwareSerDe {
 
+  private static final Logger LOG = LoggerFactory.getLogger(RegexSerDe.class);
+
   public static final String INPUT_REGEX = "input.regex";
   public static final String OUTPUT_FORMAT_STRING = "output.format.string";
   public static final String INPUT_REGEX_CASE_SENSITIVE = 
"input.regex.case.insensitive";
@@ -173,7 +175,7 @@ public class RegexSerDe extends AbstractEncodingAwareSerDe {
       if (unmatchedRows >= nextUnmatchedRows) {
         nextUnmatchedRows = getNextNumberToDisplay(nextUnmatchedRows);
         // Report the row
-        log.warn("{} unmatched rows are found: {}", unmatchedRows, rowText);
+        LOG.warn("{} unmatched rows are found: {}", unmatchedRows, rowText);
       }
       return null;
     }
@@ -187,7 +189,7 @@ public class RegexSerDe extends AbstractEncodingAwareSerDe {
         if (partialMatchedRows >= nextPartialMatchedRows) {
           nextPartialMatchedRows = 
getNextNumberToDisplay(nextPartialMatchedRows);
           // Report the row
-          log.warn("" + partialMatchedRows
+          LOG.warn("" + partialMatchedRows
               + " partially unmatched rows are found, " + " cannot find group "
               + c + ": " + rowText);
         }
diff --git 
a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/JsonSerDe.java 
b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/JsonSerDe.java
index 7defd21c081..900b15e0ebc 100644
--- a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/JsonSerDe.java
+++ b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/JsonSerDe.java
@@ -42,6 +42,8 @@ import org.apache.hadoop.io.Writable;
 import org.apache.hive.hcatalog.common.HCatException;
 import org.apache.hive.hcatalog.data.schema.HCatSchema;
 import org.apache.hive.hcatalog.data.schema.HCatSchemaUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @SerDeSpec(schemaProps = {serdeConstants.LIST_COLUMNS,
                           serdeConstants.LIST_COLUMN_TYPES,
@@ -49,6 +51,8 @@ import org.apache.hive.hcatalog.data.schema.HCatSchemaUtils;
                           serdeConstants.SERIALIZATION_ENCODING})
 public class JsonSerDe extends AbstractEncodingAwareSerDe {
 
+  private static final Logger LOG = LoggerFactory.getLogger(JsonSerDe.class);
+
   private HCatSchema schema;
 
   private HCatRecordObjectInspector cachedObjectInspector;
@@ -65,8 +69,8 @@ public class JsonSerDe extends AbstractEncodingAwareSerDe {
     cachedObjectInspector = 
HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector(rowTypeInfo);
     try {
       schema = 
HCatSchemaUtils.getHCatSchema(rowTypeInfo).get(0).getStructSubSchema();
-      log.debug("schema : {}", schema);
-      log.debug("fields : {}", schema.getFieldNames());
+      LOG.debug("schema : {}", schema);
+      LOG.debug("fields : {}", schema.getFieldNames());
     } catch (HCatException e) {
       throw new SerDeException(e);
     }
diff --git 
a/kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java 
b/kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java
index bf9f03beb8a..718b56fd468 100644
--- a/kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java
+++ b/kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java
@@ -46,6 +46,8 @@ import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectIn
 import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -66,6 +68,8 @@ import java.util.stream.Collectors;
 @SerDeSpec(schemaProps = { serdeConstants.LIST_COLUMNS, 
serdeConstants.LIST_COLUMN_TYPES }) public class KafkaSerDe
     extends AbstractSerDe {
 
+  private static final Logger LOG = LoggerFactory.getLogger(KafkaSerDe.class);
+
   /**
    * Delegate SerDe used to Serialize and DeSerialize data form/to Kafka.
    */
@@ -129,7 +133,7 @@ import java.util.stream.Collectors;
       String schemaFromProperty = 
properties.getProperty(AvroSerdeUtils.AvroTableProperties.SCHEMA_LITERAL.getPropName(),
 "");
       Preconditions.checkArgument(!schemaFromProperty.isEmpty(), "Avro Schema 
is empty Can not go further");
       Schema schema = AvroSerdeUtils.getSchemaFor(schemaFromProperty);
-      log.debug("Building Avro Reader with schema {}", schemaFromProperty);
+      LOG.debug("Building Avro Reader with schema {}", schemaFromProperty);
       bytesConverter = getByteConverterForAvroDelegate(schema, properties);
     } else {
       bytesConverter = new BytesWritableConverter();
diff --git 
a/serde/src/java/org/apache/hadoop/hive/serde2/AbstractEncodingAwareSerDe.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/AbstractEncodingAwareSerDe.java
index a6cbb874518..abde65df339 100644
--- 
a/serde/src/java/org/apache/hadoop/hive/serde2/AbstractEncodingAwareSerDe.java
+++ 
b/serde/src/java/org/apache/hadoop/hive/serde2/AbstractEncodingAwareSerDe.java
@@ -43,7 +43,7 @@ public abstract class AbstractEncodingAwareSerDe extends 
AbstractSerDe {
     super.initialize(configuration, tableProperties, partitionProperties);
     charset = 
Charset.forName(properties.getProperty(serdeConstants.SERIALIZATION_ENCODING, 
"UTF-8"));
     if (this.charset.equals(Charsets.ISO_8859_1) || 
this.charset.equals(Charsets.US_ASCII)) {
-      log.warn("The data may not be properly converted to target charset " + 
charset);
+      log.warn("{} The data may not be properly converted to target charset 
{}", getClass().getName(), charset);
     }
   }
 
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/AbstractSerDe.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/AbstractSerDe.java
index d5c47ec87e2..96ec26fef02 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/AbstractSerDe.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/AbstractSerDe.java
@@ -44,7 +44,7 @@ import com.google.common.base.Preconditions;
  */
 public abstract class AbstractSerDe implements Deserializer, Serializer {
 
-  protected Logger log = LoggerFactory.getLogger(getClass());
+  protected static final Logger log = 
LoggerFactory.getLogger(AbstractSerDe.class);
 
   protected Optional<Configuration> configuration;
   protected Properties properties;
@@ -90,7 +90,7 @@ public abstract class AbstractSerDe implements Deserializer, 
Serializer {
     Preconditions.checkArgument(this.columnNames.size() == 
this.columnTypes.size(),
         "Column names must match count of column types");
 
-    log.debug("SerDe initialized: [{}][{}]", this.configuration, 
this.properties);
+    log.debug("{} initialized: [{}][{}]", getClass().getName(), 
this.configuration, this.properties);
   }
 
   protected List<String> parseColumnNames() {
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
index d3f4848a9a3..de4059d7af5 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/RegexSerDe.java
@@ -45,6 +45,8 @@ import org.apache.hadoop.io.Writable;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Lists;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * RegexSerDe uses regular expression (regex) to deserialize data. It doesn't
@@ -71,6 +73,8 @@ import com.google.common.collect.Lists;
     RegexSerDe.INPUT_REGEX, RegexSerDe.INPUT_REGEX_CASE_SENSITIVE })
 public class RegexSerDe extends AbstractEncodingAwareSerDe {
 
+  private static final Logger LOG = LoggerFactory.getLogger(RegexSerDe.class);
+
   public static final String INPUT_REGEX = "input.regex";
   public static final String INPUT_REGEX_CASE_SENSITIVE = 
"input.regex.case.insensitive";
 
@@ -101,7 +105,7 @@ public class RegexSerDe extends AbstractEncodingAwareSerDe {
 
     // output format string is not supported anymore, warn user of deprecation
     if (null != properties.getProperty("output.format.string")) {
-      log.warn("output.format.string has been deprecated");
+      LOG.warn("output.format.string has been deprecated");
     }
 
     // Parse the configuration parameters
@@ -173,7 +177,7 @@ public class RegexSerDe extends AbstractEncodingAwareSerDe {
       unmatchedRowsCount++;
         if (!alreadyLoggedNoMatch) {
          // Report the row if its the first time
-         log.warn("" + unmatchedRowsCount + " unmatched rows are found: " + 
rowText);
+         LOG.warn("" + unmatchedRowsCount + " unmatched rows are found: " + 
rowText);
          alreadyLoggedNoMatch = true;
       }
       return null;
@@ -255,7 +259,7 @@ public class RegexSerDe extends AbstractEncodingAwareSerDe {
          partialMatchedRowsCount++;
          if (!alreadyLoggedPartialMatch) {
          // Report the row if its the first row
-         log.warn("" + partialMatchedRowsCount
+         LOG.warn("" + partialMatchedRowsCount
             + " partially unmatched rows are found, " + " cannot find group "
             + c + ": " + rowText);
            alreadyLoggedPartialMatch = true;

Reply via email to