phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anchal Agrawal <>
Subject UDF - accessing column not in PK
Date Mon, 03 Aug 2015 19:36:33 GMT
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

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

View raw message