phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anchal Agrawal <anc...@yahoo-inc.com>
Subject Re: UDF - accessing column not in PK
Date Wed, 05 Aug 2015 18:52:27 GMT
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 <anchal@yahoo-inc.com> 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


  
Mime
View raw message