incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1293488 - in /incubator/hcatalog/branches/branch-0.3: CHANGES.txt src/java/org/apache/hcatalog/data/HCatRecordSerDe.java src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
Date Sat, 25 Feb 2012 00:15:41 GMT
Author: gates
Date: Sat Feb 25 00:15:40 2012
New Revision: 1293488

URL: http://svn.apache.org/viewvc?rev=1293488&view=rev
Log:
HCATALOG-270 HCatRecord SerDe does not handle List<Map> or List<List> or List<lazy
primitive> correctly

Modified:
    incubator/hcatalog/branches/branch-0.3/CHANGES.txt
    incubator/hcatalog/branches/branch-0.3/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
    incubator/hcatalog/branches/branch-0.3/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java

Modified: incubator/hcatalog/branches/branch-0.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.3/CHANGES.txt?rev=1293488&r1=1293487&r2=1293488&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.3/CHANGES.txt (original)
+++ incubator/hcatalog/branches/branch-0.3/CHANGES.txt Sat Feb 25 00:15:40 2012
@@ -119,6 +119,8 @@ Release 0.3.0 (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-270  HCatRecord SerDe does not handle List<Map> or List<List> or List<lazy
primitive> correctly (khorgath via gates)
+
   HCAT-232. Dynamic Partitioning broken: keys set to HIVE_DEFAULT_PARTITION (mithun via gates)
 
   HCAT-229. bin/hcat should put hcatalog.jar into classpath (daiky via gates)

Modified: incubator/hcatalog/branches/branch-0.3/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.3/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java?rev=1293488&r1=1293487&r2=1293488&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.3/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
(original)
+++ incubator/hcatalog/branches/branch-0.3/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
Sat Feb 25 00:15:40 2012
@@ -225,7 +225,11 @@ public class HCatRecordSerDe implements 
     List l = loi.getList(f);
     ObjectInspector eloi = loi.getListElementObjectInspector();
     if (eloi.getCategory() == Category.PRIMITIVE){
-      return l;
+      List<Object> list = new ArrayList<Object>(l.size());
+      for(int i = 0; i < l.size(); i++){
+        list.add(((PrimitiveObjectInspector)eloi).getPrimitiveJavaObject(l.get(i)));
+      }
+      return list;
     } else if (eloi.getCategory() == Category.STRUCT){
       List<List<?>> list = new ArrayList<List<?>>(l.size());
       for (int i = 0 ; i < l.size() ; i++ ){
@@ -237,18 +241,18 @@ public class HCatRecordSerDe implements 
       for (int i = 0 ; i < l.size() ; i++ ){
         list.add(serializeList(l.get(i), (ListObjectInspector) eloi));
       }
+      return list;
     } else if (eloi.getCategory() == Category.MAP){
       List<Map<?,?>> list = new ArrayList<Map<?,?>>(l.size());
       for (int i = 0 ; i < l.size() ; i++ ){
         list.add(serializeMap(l.get(i), (MapObjectInspector) eloi));
       }
-      throw new SerDeException("HCatSerDe map type unimplemented");
+      return list;
     } else {
       throw new SerDeException(getClass().toString() 
           + " does not know what to do with fields of unknown category: "
           + eloi.getCategory() + " , type: " + eloi.getTypeName());
     }
-    return l;
   }
 
   /**

Modified: incubator/hcatalog/branches/branch-0.3/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/branches/branch-0.3/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java?rev=1293488&r1=1293487&r2=1293488&view=diff
==============================================================================
--- incubator/hcatalog/branches/branch-0.3/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
(original)
+++ incubator/hcatalog/branches/branch-0.3/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
Sat Feb 25 00:15:40 2012
@@ -81,14 +81,26 @@ public class TestHCatRecordSerDe extends
       c1_1.add(i2);
       c1.add(c1_1);
     rlist.add(c1);
+    List<Object> am = new ArrayList<Object>();
+      Map<String,String> am_1 = new HashMap<String,String>();
+        am_1.put("noo","haha");
+      am.add(am_1);
+    rlist.add(am);
+    List<Object> aa = new ArrayList<Object>();
+      List<String> aa_1 = new ArrayList<String>();
+        aa_1.add("bloo");
+        aa_1.add("bwahaha");
+      aa.add(aa_1);
+    rlist.add(aa);
 
     String typeString = 
         "tinyint,smallint,int,bigint,double,float,string,string,"
         + "struct<a:string,b:string>,array<int>,map<smallint,string>,boolean,"
-        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>";
+        + "array<struct<i1:int,i2:struct<ii1:array<int>,ii2:map<string,struct<iii1:int>>>>>,"
+        + "array<map<string,string>>,array<array<string>>";
     Properties props = new Properties();
     
-    props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1");
+    props.put(Constants.LIST_COLUMNS, "ti,si,i,bi,d,f,s,n,r,l,m,b,c1,am,aa");
     props.put(Constants.LIST_COLUMN_TYPES, typeString);
 
     data.put(props, new DefaultHCatRecord(rlist));



Mime
View raw message