incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1293483 - in /incubator/hcatalog/trunk: CHANGES.txt src/java/org/apache/hcatalog/data/HCatRecordSerDe.java src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
Date Fri, 24 Feb 2012 23:53:25 GMT
Author: gates
Date: Fri Feb 24 23:53:25 2012
New Revision: 1293483

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

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
    incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1293483&r1=1293482&r2=1293483&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Fri Feb 24 23:53:25 2012
@@ -48,6 +48,8 @@ Trunk (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-248 Set execute.setugi conf variable to true by default (hashutosh via gates)
 
   HCAT-254. Fix storage-drives build.xml (hashutosh via khorgath)

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java?rev=1293483&r1=1293482&r2=1293483&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java (original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java Fri Feb
24 23:53:25 2012
@@ -238,7 +238,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++ ){
@@ -250,20 +254,21 @@ 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(HCatRecordSerDe.class.toString() 
           + " does not know what to do with fields of unknown category: "
           + eloi.getCategory() + " , type: " + eloi.getTypeName());
     }
-    return l;
   }
 
+
   /**
    * Return an object inspector that can read through the object 
    * that we return from deserialize(). To wit, that means we need 

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java?rev=1293483&r1=1293482&r2=1293483&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java (original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/TestHCatRecordSerDe.java Fri
Feb 24 23:53:25 2012
@@ -83,14 +83,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);
 //    props.put(Constants.SERIALIZATION_NULL_FORMAT, "\\N");
 //    props.put(Constants.SERIALIZATION_FORMAT, "1");
@@ -146,7 +158,7 @@ public class TestHCatRecordSerDe extends
 
       LazyHCatRecord s6 = new LazyHCatRecord(s4,hrsd.getObjectInspector());
       System.out.println("SIX:"+s6.toString());
-      
+
     }
 
   }



Mime
View raw message