hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aihu...@apache.org
Subject [1/3] hive git commit: HIVE-17966: org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveArrayInspector - Review (BELUGA BEHR, reviewed by Aihua Xu)
Date Mon, 08 Jan 2018 19:42:12 GMT
Repository: hive
Updated Branches:
  refs/heads/master a6b88d9d2 -> 148807a98


HIVE-17966: org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveArrayInspector - Review
(BELUGA BEHR, reviewed by Aihua Xu)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/aa45b021
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/aa45b021
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/aa45b021

Branch: refs/heads/master
Commit: aa45b021f8f2e65afcb3134ea79c91db86668bcd
Parents: a6b88d9
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Mon Jan 8 10:44:16 2018 -0800
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Mon Jan 8 10:44:16 2018 -0800

----------------------------------------------------------------------
 .../serde/ParquetHiveArrayInspector.java        | 41 ++++++++------------
 1 file changed, 16 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/aa45b021/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveArrayInspector.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveArrayInspector.java
b/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveArrayInspector.java
index 55614a3..c4a286d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveArrayInspector.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveArrayInspector.java
@@ -14,6 +14,7 @@
 package org.apache.hadoop.hive.ql.io.parquet.serde;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -69,7 +70,7 @@ public class ParquetHiveArrayInspector implements SettableListObjectInspector
{
     }
 
     if (data instanceof List) {
-      return ((List)data).get(index);
+      return ((List<?>)data).get(index);
     }
 
     throw new UnsupportedOperationException("Cannot inspect " + data.getClass().getCanonicalName());
@@ -91,7 +92,7 @@ public class ParquetHiveArrayInspector implements SettableListObjectInspector
{
     }
 
     if (data instanceof List) {
-      return ((List)data).size();
+      return ((List<?>)data).size();
     }
 
     throw new UnsupportedOperationException("Cannot inspect " + data.getClass().getCanonicalName());
@@ -108,13 +109,7 @@ public class ParquetHiveArrayInspector implements SettableListObjectInspector
{
       if (array == null) {
         return null;
       }
-
-      final List<Writable> list = new ArrayList<Writable>(array.length);
-      for (final Writable obj : array) {
-        list.add(obj);
-      }
-
-      return list;
+      return new ArrayList<Writable>(Arrays.asList(array));
     }
 
     if (data instanceof List) {
@@ -126,29 +121,27 @@ public class ParquetHiveArrayInspector implements SettableListObjectInspector
{
 
   @Override
   public Object create(final int size) {
-    final ArrayList<Object> result = new ArrayList<Object>(size);
-    for (int i = 0; i < size; ++i) {
-      result.add(null);
-    }
-    return result;
+    return new ArrayList<Object>(Arrays.asList(new Object[size]));
   }
 
   @Override
+  @SuppressWarnings("unchecked")
   public Object set(final Object list, final int index, final Object element) {
-    final ArrayList l = (ArrayList) list;
+    final List<Object> l = (List<Object>) list;
     l.set(index, element);
     return list;
   }
 
   @Override
+  @SuppressWarnings("unchecked")
   public Object resize(final Object list, final int newSize) {
-    final ArrayList l = (ArrayList) list;
-    l.ensureCapacity(newSize);
-    while (l.size() < newSize) {
-      l.add(null);
-    }
-    while (l.size() > newSize) {
-      l.remove(l.size() - 1);
+    final List<Object> l = (List<Object>) list;
+    final int deltaSize = newSize - l.size();
+    if (deltaSize > 0) {
+      l.addAll(Arrays.asList(new Object[deltaSize]));
+    } else {
+      int size = l.size();
+      l.subList(size + deltaSize, size).clear();
     }
     return list;
   }
@@ -167,8 +160,6 @@ public class ParquetHiveArrayInspector implements SettableListObjectInspector
{
 
   @Override
   public int hashCode() {
-    int hash = 3;
-    hash = 29 * hash + (this.arrayElementInspector != null ? this.arrayElementInspector.hashCode()
: 0);
-    return hash;
+    return (this.arrayElementInspector != null ? this.arrayElementInspector.hashCode() :
0);
   }
 }


Mime
View raw message