Hi,

I built a UDF function to decode the URLs from the log files.  When I run
the script in Hive, i get the following error message.  Is there something I
should be catching beside the NULL values?


Thanks,
-ray

java.lang.RuntimeException: Unable to execute method public
org.apache.hadoop.io.Text
com.test.norm.URLDecode.evaluate(org.apache.hadoop.io.Text)  on object
com.test.norm.urldec...@27b03c1a of class com.test.norm.URLDecode with
arguments 
{http%3A%2F%2Fswapalease.com%2Fvehiclesearch%2FVehicleDtlF.asp%3Fyear1%3D2007%26year2%3D2010%26make%3DLexus%26model%3DRX%2B350%26category%3D%2525%26state%3D%26zipcode%3D43017%26zipDistance%3D100%26begPayment%3D%26endPayment%3D%26begPrice%3D0%26endPrice%3D250000%26BegMonthsRemaining%3D%26EndMonthsRemaining%3D%26BegMilesPerMo%3D%26EndMilesPerMo%3D%26recent_list%3D%26forSale%3D%26Country%3DUS%26ListingType%3DF%26ExtColor%3D%25%26IntColor%3D%25%26Engine%3D%25%26Transmission%3D%25%26showIncentive%3D%26showNewLease%3D%26leaseCompany%3D0%26showOnlyDealer%3D%26DUID%3D%26sort%3D3%26page%3D1%26ResultsPerPage%3D10%26vehicleID%3D545503:org.apache.hadoop.io.Text}
of size 1:null
        at org.apache.hadoop.hive.ql.exec.ExecMapper.map(ExecMapper.java:182)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
        at org.apache.hadoop.mapred.Child.main(Child.java:158)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to
execute method public org.apache.hadoop.io.Text
com.test.norm.URLDecode.evaluate(org.apache.hadoop.io.Text)  on object
com.test.norm.urldec...@27b03c1a of class com.test.norm.URLDecode with
arguments 
{http%3A%2F%2Fswapalease.com%2Fvehiclesearch%2FVehicleDtlF.asp%3Fyear1%3D2007%26year2%3D2010%26make%3DLexus%26model%3DRX%2B350%26category%3D%2525%26state%3D%26zipcode%3D43017%26zipDistance%3D100%26begPayment%3D%26endPayment%3D%26begPrice%3D0%26endPrice%3D250000%26BegMonthsRemaining%3D%26EndMonthsRemaining%3D%26BegMilesPerMo%3D%26EndMilesPerMo%3D%26recent_list%3D%26forSale%3D%26Country%3DUS%26ListingType%3DF%26ExtColor%3D%25%26IntColor%3D%25%26Engine%3D%25%26Transmission%3D%25%26showIncentive%3D%26showNewLease%3D%26leaseCompany%3D0%26showOnlyDealer%3D%26DUID%3D%26sort%3D3%26page%3D1%26ResultsPerPage%3D10%26vehicleID%3D545503:org.apache.hadoop.io.Text}
of size 1:null
        at 
org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:478)
        at 
org.apache.hadoop.hive.ql.exec.ExprNodeFuncEvaluator.evaluate(ExprNodeFuncEvaluator.java:131)
        at 
org.apache.hadoop.hive.ql.exec.ExprNodeFuncEvaluator.evaluate(ExprNodeFuncEvaluator.java:99)
        at 
org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:72)
        at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:486)
        at 
org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:42)
        at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:486)
        at 
org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:297)
        at org.apache.hadoop.hive.ql.exec.ExecMapper.map(ExecMapper.java:165)
        ... 3 more



Below is the UDF class;
    package com.test.norm;

    import org.apache.hadoop.hive.ql.exec.UDF;
    import org.apache.hadoop.io.Text;
    import org.apache.log4j.Logger;
    import java.io.UnsupportedEncodingException;
    import java.net.URLDecoder;


    public final class URLDecode extends UDF {



      private static final Logger LOG = Logger.getLogger(URLDecode.class);


      public Text evaluate(final Text s) {
          if (s == null) {
              LOG.error("input is null");
              return null;
          }


        String url_orig = s.toString();

          if (url_orig == null || url_orig.isEmpty()) {
              LOG.error("orig url is null");
              return null;
          }

        String url_norm = null;

            try {
                url_norm = URLDecoder.decode(url_orig, "UTF-8");
          //      url_norm = URLDecoder.decode(url_norm, "UTF-8");
            } catch (Exception exception) {
                LOG.error("wrong url code :::" + exception.getMessage());
                return null;
            }
          if (url_norm == null) {
              LOG.error("cant decode from " + s);
              return null;
          }
          Text to_value = new Text();
           to_value.set(url_norm);
            return to_value;
        }
}

Reply via email to