I have written custom function to decode base64 string.
I am getting issue if string is large it says "Index out of bound, max
length is 256"

It seems I can return only 256 characters.
Kindly help, Thanks in advance.

Code : for reference

@FunctionTemplate(
name = "Base64Conv",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL
)
public  class Base64Conv implements DrillSimpleFunc{

    @Param
    NullableVarCharHolder input;
    @Output
    VarCharHolder outDate;
    @Inject
    DrillBuf buffer;
    public void setup() {
        // TODO Auto-generated method stub

    }

    public void eval() {
        // TODO Auto-generated method stub
        try
        {
            String stringValue =
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start,
input.end, input.buffer);
            byte[] valueDecoded=
javax.xml.bind.DatatypeConverter.parseBase64Binary(stringValue);
             outDate.buffer = buffer;
             outDate.start = 0;
             outDate.end = valueDecoded.length;
             buffer.setBytes(0, valueDecoded);

        }
        catch(Exception e)
        {
//            return null;
        }


    }

}

Reply via email to