You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by bi...@apache.org on 2012/11/28 07:21:45 UTC

svn commit: r1414541 - in /pig/trunk: CHANGES.txt src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java

Author: billgraham
Date: Wed Nov 28 06:21:33 2012
New Revision: 1414541

URL: http://svn.apache.org/viewvc?rev=1414541&view=rev
Log:
PIG-3062: Change HBaseStorage to permit overriding pushProjection (billgraham)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1414541&r1=1414540&r2=1414541&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Nov 28 06:21:33 2012
@@ -26,6 +26,8 @@ PIG-3034: Remove Penny code from Pig rep
 
 IMPROVEMENTS
 
+PIG-3062: Change HBaseStorage to permit overriding pushProjection (billgraham)
+
 PIG-3016: Modernize more tests (jcoveney via cheolsoo)
 
 PIG-2582: Store size in bytes (not mbytes) in ResourceStatistics (prkommireddi via billgraham)

Modified: pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java?rev=1414541&r1=1414540&r2=1414541&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java (original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseStorage.java Wed Nov 28 06:21:33 2012
@@ -546,15 +546,33 @@ public class HBaseStorage extends LoadFu
         scan.setFilter(scanFilter);
     }
 
-  /**
-   * Returns the ColumnInfo list for so external objects can inspect it. This
-   * is available for unit testing. Ideally, the unit tests and the main source
-   * would each mirror the same package structure and this method could be package
-   * private.
-   * @return ColumnInfo
-   */
+   /**
+    * Returns the ColumnInfo list so external objects can inspect it.
+    * @return List of ColumnInfo objects
+    */
     public List<ColumnInfo> getColumnInfoList() {
-      return columnInfo_;
+        return columnInfo_;
+    }
+
+   /**
+    * Updates the ColumnInfo List. Use this if you need to implement custom projections
+    */
+    protected void setColumnInfoList(List<ColumnInfo> columnInfoList) {
+        this.columnInfo_ = columnInfoList;
+    }
+
+   /**
+    * Stores the requiredFieldsList as a serialized object so it can be fetched on the cluster. If
+    * you plan to overwrite pushProjection, you need to call this with the requiredFieldList so it
+    * they can be accessed on the cluster.
+    */
+    protected void storeProjectedFieldNames(RequiredFieldList requiredFieldList) throws FrontendException {
+        try {
+            getUDFProperties().setProperty(projectedFieldsName(),
+              ObjectSerializer.serialize(requiredFieldList));
+        } catch (IOException e) {
+            throw new FrontendException(e);
+        }
     }
 
     @Override
@@ -1018,14 +1036,9 @@ public class HBaseStorage extends LoadFu
         }
 
         // remember the projection
-        try {
-            getUDFProperties().setProperty( projectedFieldsName(),
-                    ObjectSerializer.serialize(requiredFieldList) );
-        } catch (IOException e) {
-            throw new FrontendException(e);
-        }
+        storeProjectedFieldNames(requiredFieldList);
 
-       if (loadRowKey_ &&
+        if (loadRowKey_ &&
                 ( requiredFields.size() < 1 || requiredFields.get(0).getIndex() != 0)) {
                 loadRowKey_ = false;
             projOffset = 0;
@@ -1042,7 +1055,7 @@ public class HBaseStorage extends LoadFu
                 LOG.debug("pushProjection -- col: " + colInfo);
         }
         }
-        columnInfo_ = newColumns;
+        setColumnInfoList(newColumns);
         return new RequiredFieldResponse(true);
     }