[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-08 Thread Alan Gates (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12697056#action_12697056
 ] 

Alan Gates commented on PIG-745:


I'm reviewing this patch.

 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz
 Attachments: PIG-745.patch


 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-08 Thread David Ciemiewicz (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12697094#action_12697094
 ] 

David Ciemiewicz commented on PIG-745:
--

Alan,

I realized several things.

1) The question of what to do about BOOLEAN case.  My original suggestion was 
to convert the BOOLEAN case to 1 and 0 but in the patch, I just used the 
Boolean.toString() function.  Not sure if that matters or not.

2) I didn't see other test cases for the other DataType.toInteger(), ... 
conversions so I didn't create one for DataType.toString().

3) We are just using the default conversion of Float.toString() and 
Double.toString().  I don't know if this is actually best since I don't know 
if these operations present the floating-point values in full precision or not. 
 At this point, it may not really matter so much as the primary reason for 
creating DataType.toString() is to allow string functions to operate on any 
data type (like in Perl) without generating cast errors.



 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz
 Attachments: PIG-745.patch


 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-08 Thread Alan Gates (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12697237#action_12697237
 ] 

Alan Gates commented on PIG-745:


Responses to comments:

1) Java's Boolean.toString() is probably the best choice.

2) Unit tests would be nice, but this is pretty basic and you're just calling 
various
java .toString functions.

3) If you're happy with it, it's good enough for now.  We can improve it later 
if people
ask for it.

4) Noted.


 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz
 Attachments: PIG-745.patch


 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-05 Thread David Ciemiewicz (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12695921#action_12695921
 ] 

David Ciemiewicz commented on PIG-745:
--

The more I think about this one, the more I realize that not having 
DataType.toString() is an oversight for the DataType package.


 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz

 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-05 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12695946#action_12695946
 ] 

Hadoop QA commented on PIG-745:
---

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12404681/PIG-745.patch
  against trunk revision 759376.

+1 @author.  The patch does not contain any @author tags.

-1 tests included.  The patch doesn't appear to include any new or modified 
tests.
Please justify why no tests are needed for this patch.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/19/testReport/
Findbugs warnings: 
http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/19/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/19/console

This message is automatically generated.

 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz
 Attachments: PIG-745.patch


 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-745) Please add DataTypes.toString() conversion function

2009-04-02 Thread David Ciemiewicz (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=12694893#action_12694893
 ] 

David Ciemiewicz commented on PIG-745:
--

Actually, the proposed function DataTypes.toString() is the following:
{code}
public static String toString(Object o) throws ExecException {
try {
switch (findType(o)) {
case BOOLEAN: if (((Boolean)o) == true) return new 
String('1'); else return new String('0');
case BYTE: return ((Byte)o).toString();
case INTEGER: return ((Integer)o).toString();
case LONG: return ((Long)o).toString();
case FLOAT: return ((Float)o).toString();
case DOUBLE: return ((Double)o).toString();
case BYTEARRAY: return ((DataByteArray)o).toString();
case CHARARRAY: return (String)o;
case NULL: return null;
case MAP:
case TUPLE:
case BAG:
case UNKNOWN:
default:
int errCode = 1071;
String msg = Cannot convert a  + 
findTypeName(o) +  to an String;
throw new ExecException(msg, errCode, 
PigException.INPUT);
}
}
catch (ExecException ee) { throw ee; }
catch (Exception e) {
int errCode = 2054; String msg = Internal error. Could 
not convert  + o +  to String.;
throw new ExecException(msg, errCode, PigException.BUG);
}
}
{code}

 Please add DataTypes.toString() conversion function
 ---

 Key: PIG-745
 URL: https://issues.apache.org/jira/browse/PIG-745
 Project: Pig
  Issue Type: Improvement
Reporter: David Ciemiewicz

 I'm doing some work in string manipulation UDFs and I've found that it would 
 be very convenient if I could always convert the argument to a chararray 
 (internally a Java String).
 For example TOLOWERCASE(arg) shouldn't really care whether arg is a 
 bytearray, chararray, int, long, double, or float, it should be treated as a 
 string and operated on.
 The simplest and most foolproof method would be if the DataTypes added a 
 static function of  DataTypes.toString which did all of the argument type 
 checking and provided consistent translation.
 I believe that this function might be coded as:
 public static String toString(Object o) throws ExecException {
 try {
   switch (findType(o)) {
   case BOOLEAN:
   if (((Boolean)o) == true) return new String('1');
   else return new String('0');
   case BYTE:
   return ((Byte)o).toString();
   case INTEGER:
   return ((Integer)o).toString();
   case LONG:
   return ((Long)o).toString();
   case FLOAT:
   return ((Float)o).toString();
   case DOUBLE:
   return ((Double)o).toString();
   case BYTEARRAY:
   return ((DataByteArray)o).toString();
   case CHARARRAY:
   return (String)o;
   case NULL:
   return null;
   case MAP:
   case TUPLE:
   case BAG:
   case UNKNOWN:
   default:
   int errCode = 1071;
   String msg = Cannot convert a  + findTypeName(o) +
to an String;
   throw new ExecException(msg, errCode, 
 PigException.INPUT);
   }
   } catch (ExecException ee) {
   throw ee;
   } catch (Exception e) {
   int errCode = 2054;
   String msg = Internal error. Could not convert  + o + 
  to String.;
   throw new ExecException(msg, errCode, PigException.BUG);
   }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.