Hi everyone,
I resolved this. After looking around for similar issues, I found this thread:
 
|   |
|   |   |   |   |   |
| Re: UDF - Access Tuple Column Values By NameThanks James. Thanks,KathirOn 
Wed, May 6, 2015 at 2:37 PM, James Taylor <... |
|  |
| View on mail-archives.apache.org | Preview by Yahoo |
|  |
|   |


I was incorrectly using ImmutableBytesWritable's get() method. Using 
copyBytes() on ptr did the job!
Sincerely,Anchal 


     On Monday, August 3, 2015 12:38 PM, Anchal Agrawal <[email protected]> 
wrote:
   

 Hi,
I'm writing a UDF that accesses a bytearray in a Phoenix view's column and 
returns the long value by applying HBase's Bytes.toBytes() method. I'm having 
issues grabbing the bytearray stored in the column. 

Phoenix view of an existing HBase table: create view "view_name" (pk VARBINARY 
PRIMARY KEY, "cf"."col" VARBINARY);UDF: create function getLong(VARBINARY) 
returns LONG as 'mypackage.getLong';Usage: select pk, getLong("col") from 
"view_name";

In the UDF's evaluate() method, I've tried accessing the column value with 
Tuple's getValue() methods and Cell's getValueArray() method, but I'm not 
getting the expected values. I've looked at built-in UDFs such as 
ToNumberFunction. Some functions implement the readFields() and write() 
methods, while some don't. Is my UDF supposed to implement these? So far, I've 
been trying to access the column values in the evaluate() method through the 
Cell and Tuple classes.

What's the best way to grab a column's value in a UDF? I appreciate your help.
Thanks,Anchal


  

Reply via email to