incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avand...@apache.org
Subject svn commit: r1344843 - in /incubator/hcatalog/trunk: ./ src/java/org/apache/hcatalog/data/ src/java/org/apache/hcatalog/data/schema/ src/test/org/apache/hcatalog/data/schema/
Date Thu, 31 May 2012 18:16:54 GMT
Author: avandana
Date: Thu May 31 18:16:53 2012
New Revision: 1344843

URL: http://svn.apache.org/viewvc?rev=1344843&view=rev
Log:
HCAT-406 The toString method in HCatFieldSchema class return only type information.

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/HCatRecordSerDe.java
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatFieldSchema.java
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatSchema.java
    incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1344843&r1=1344842&r2=1344843&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Thu May 31 18:16:53 2012
@@ -43,6 +43,8 @@ Trunk (unreleased changes)
   OPTIMIZATIONS
 
   BUG FIXES
+  HCAT-406 The "toString" method in HCatFieldSchema class return only type information. (avandana)
+
   HCAT-421 Unit test failures in trunk build (avandana)
 
   HCAT-411 Incorrect example provided in the HCatalog documentation (Overview page) avandana

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=1344843&r1=1344842&r2=1344843&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 Thu May
31 18:16:53 2012
@@ -99,7 +99,7 @@ public class HCatRecordSerDe implements 
 
       LOG.debug("Initializing HCatRecordSerDe through HCatSchema {}." ,hsch);
 
-    rowTypeInfo = (StructTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(hsch.toString());
+    rowTypeInfo = (StructTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(hsch.getSchemaAsTypeString());
     cachedObjectInspector = HCatRecordObjectInspectorFactory.getHCatRecordObjectInspector(rowTypeInfo);
 
   }

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatFieldSchema.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatFieldSchema.java?rev=1344843&r1=1344842&r2=1344843&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatFieldSchema.java
(original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatFieldSchema.java
Thu May 31 18:16:53 2012
@@ -208,8 +208,12 @@ public class HCatFieldSchema implements 
     }
 
     @Override
-    public String toString(){
-        return getTypeString();
+    public String toString() {
+        return "HCatFieldSchema ["
+                + (fieldName != null ? "fieldName=" + fieldName + ", " : "fieldName=null")
+                + (comment != null ? "comment=" + comment + ", " : "comment=null")
+                + (type != null ? "type=" + getTypeString() + ", " : "type=null")
+                + (category != null ? "category=" + category : "category=null") + "]";
     }
 
     public String getTypeString(){
@@ -222,17 +226,17 @@ public class HCatFieldSchema implements 
             sb.append(type);
         }else if (Category.STRUCT == category){
             sb.append("struct<");
-            sb.append(subSchema.toString());
+            sb.append(subSchema.getSchemaAsTypeString());
             sb.append(">");
         }else if (Category.ARRAY == category){
             sb.append("array<");
-            sb.append(subSchema.toString());
+            sb.append(subSchema.getSchemaAsTypeString());
             sb.append(">");
         }else if (Category.MAP == category){
             sb.append("map<");
             sb.append(mapKeyType);
             sb.append(",");
-            sb.append(subSchema.toString());
+            sb.append(subSchema.getSchemaAsTypeString());
             sb.append(">");
         }
         return (typeString = sb.toString().toLowerCase());

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatSchema.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatSchema.java?rev=1344843&r1=1344842&r2=1344843&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatSchema.java (original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/data/schema/HCatSchema.java Thu
May 31 18:16:53 2012
@@ -139,4 +139,22 @@ public class HCatSchema implements Seria
         }
         return sb.toString();
     }
+
+    public String getSchemaAsTypeString(){
+        boolean first = true;
+        StringBuilder sb = new StringBuilder();
+        for (HCatFieldSchema hfs : fieldSchemas){
+            if (!first){
+                sb.append(",");
+            }else{
+                first = false;
+            }
+            if (hfs.getName() != null){
+                sb.append(hfs.getName());
+                sb.append(":");
+            }
+            sb.append(hfs.getTypeString());
+        }
+        return sb.toString();
+    }
 }

Modified: incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java?rev=1344843&r1=1344842&r2=1344843&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java
(original)
+++ incubator/hcatalog/trunk/src/test/org/apache/hcatalog/data/schema/TestHCatSchemaUtils.java
Thu May 31 18:16:53 2012
@@ -41,10 +41,11 @@ public class TestHCatSchemaUtils extends
         TypeInfo ti = TypeInfoUtils.getTypeInfoFromTypeString(typeString);
 
         HCatSchema hsch = HCatSchemaUtils.getHCatSchemaFromTypeString(typeString);
-        LOG.info(ti.getTypeName());
+        LOG.info("Type name : {}",ti.getTypeName());
         LOG.info("HCatSchema : {}",hsch);
-        assertEquals(ti.getTypeName(),hsch.toString());
-        assertEquals(hsch.toString(),typeString);
+        assertEquals(hsch.size(), 1);
+        assertEquals(ti.getTypeName(),hsch.get(0).getTypeString());
+        assertEquals(hsch.get(0).getTypeString(),typeString);
     }
 
     @SuppressWarnings("unused")



Mime
View raw message