Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill, mail # dev - Implementation of the upper() function

Copy link to this message
Implementation of the upper() function
Tanujit Ghosh 2013-08-24, 11:35
Hi All,

I put together a simple implementation of the upper() string function.

Few questions

1. Is this the correct way, just wanted to understand to understand the
ByteBuf and whether we should be doing the setBytes with the string.
Another obvious optimization that can consider the byte as number and then
intrepret to ascii value and if it falls int he lower change change the
value to higher value.
Just wanted to know what is the way that would be better.

2. It would be helpful to get an explainatin on the bytebuf and how its
wrapped around in the vector and holder objects and how this is supposed to
be shared.
  @FunctionTemplate(name = "uppercase", scope FunctionTemplate.FunctionScope.SIMPLE,
              nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
  public static class UpperString implements DrillFunc {

    @Param  VarCharHolder input;
    @Output VarCharHolder out;

    public void setup(RecordBatch b){}

    public void eval(){
      out.buffer = input.buffer;
      out.start = input.start;
      out.end = input.end;

      String inputStr = input.toString().toUpperCase();
      out.buffer.setBytes(input.start, inputStr.getBytes());

    public static class Provider implements CallProvider {
      public FunctionDefinition[] getFunctionDefintions() {
        return new FunctionDefinition[] {
            new BasicArgumentValidator(new

            new OutputTypeDeterminer.SameAsFirstInput(),
Thanks and Regards,