All the scalar fields coming out of HBase are of VARBIARY type and hence input type (field Param) will be passed in a VarBinaryHolder.
Please take a look at similar function implementations[1] which decode primitive types encoded using HBase OrderedBytes encoding. [1] https://reviews.apache.org/r/36558/diff/1#index_header On Sat, Jul 18, 2015 at 7:36 PM, Jim Bates <[email protected]> wrote: > VarCharHolder, as its name indicates, will contain a VarChar data type. > Assuming you are using a DrillSimpleFunc you will need to have a param > specified as a for a VarCharHolder. Below is a simple class to revive and > return a varchar object. If you post what you are doing we can correct it > for you quickly. > > > public class MySimpleFunctions { > > @FunctionTemplate(name = "ExampleVarCharUDF", isRandom = true,scope = > FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.NULL_IF_NULL) > public class ExampleVarCharUDF implements DrillSimpleFunc { > > @Param VarCharHolder in; > @Inject DrillBuf buffer; > @Output VarCharHolder out; > > public void setup() { > > } > > public void eval() { > String inputStr = > > org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(in.start, > in.end, in.buffer); > String outputStr = inputStr + " I added some stuff to my input"; > out.buffer = buffer; > out.start = 0; > out.end = outputStr.toByteArray().length; > out.buffer.setBytes(0, outputStr.toByteArray()); > } > } > > } > > On Sat, Jul 18, 2015 at 8:41 PM, George Lu <[email protected]> wrote: > > > Hey all, > > > > I would like to write some custom function for HBase, such as json string > > operation and Time convert, I know the tutorial on the website, but I > feel > > it is kinda easy and only covers the skeletons, has anyone has experience > > in writing custom function for HBase, what is the input data type > > (VarCharHolder?). > > Can we add more tutorial? > > > > Thanks! > > > > George Lu > > >
