public Object exec()

in datafu-pig/src/main/java/datafu/pig/util/Coalesce.java [76:123]


  public Object exec(Tuple input) throws IOException
  {    
    if (input == null || input.size() == 0)
    {
      return null;
    }
    
    Byte type = (Byte)getInstanceProperties().get("type");
                
    for (Object o : input)
    {
      if (o != null)
      {
        if (strict)
        {
          return o;
        }
        else
        {
          try
          {
            switch (type)
            {
            case DataType.INTEGER:
              return DataType.toInteger(o);
            case DataType.LONG:
              return DataType.toLong(o);
            case DataType.DOUBLE:
              return DataType.toDouble(o); 
            case DataType.FLOAT:
              return DataType.toFloat(o);      
            default:
              return o;
            }
          }
          catch (Exception e)
          {
            DataFuException dfe = new DataFuException(e.getMessage(),e);
            dfe.setData(o);
            dfe.setFieldAliases(getFieldAliases());
            throw dfe;
          }
        }
      }
    }
    
    return null;
  }