You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Sandeep Dugar <sd...@gainsight.com> on 2016/09/26 16:55:16 UTC

UDF IndexOutOfBoundsException for large String

Hi ,

I am trying to write a UDF for which the input is text, possibly with 1K characters.

I am trying to get the string value from NullableVarcharHolder via the function org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer);

This is resulting in error msg as below:

Error: SYSTEM ERROR: IndexOutOfBoundsException: index: 0, length: 257 (expected: range(0, 256))

Fragment 1:0 


Questions:

1. What should be data type for large input string? Is NullableVarcharHolder correct approach?
2. How to get it into string in such scenarios?


-
Thanks,
Sandeep

Re: UDF IndexOutOfBoundsException for large String

Posted by Gautam Parai <gp...@maprtech.com>.
Can you try the following

@Param

FieldReader in;

int type = in.getType().getMinorType().getNumber();

*if (*type == org.apache.drill.common.types.TypeProtos.MinorType.
VARCHAR_VALUE) {

    String res = in.readText().toString();
}

and see if it resolves your issue?


On Mon, Sep 26, 2016 at 9:55 AM, Sandeep Dugar <sd...@gainsight.com> wrote:

> Hi ,
>
> I am trying to write a UDF for which the input is text, possibly with 1K
> characters.
>
> I am trying to get the string value from NullableVarcharHolder via the
> function org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start,
> input.end, input.buffer);
>
> This is resulting in error msg as below:
>
> Error: SYSTEM ERROR: IndexOutOfBoundsException: index: 0, length: 257
> (expected: range(0, 256))
>
> Fragment 1:0
>
>
> Questions:
>
> 1. What should be data type for large input string? Is
> NullableVarcharHolder correct approach?
> 2. How to get it into string in such scenarios?
>
>
> -
> Thanks,
> Sandeep

Re: UDF IndexOutOfBoundsException for large String

Posted by Jinfeng Ni <jn...@apache.org>.
It might be related to the way you allocate buffer for your text input
in your UDF. It would be helpful if you can share the UDF code to help
people understand the problem.


On Mon, Sep 26, 2016 at 9:55 AM, Sandeep Dugar <sd...@gainsight.com> wrote:
> Hi ,
>
> I am trying to write a UDF for which the input is text, possibly with 1K characters.
>
> I am trying to get the string value from NullableVarcharHolder via the function org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer);
>
> This is resulting in error msg as below:
>
> Error: SYSTEM ERROR: IndexOutOfBoundsException: index: 0, length: 257 (expected: range(0, 256))
>
> Fragment 1:0
>
>
> Questions:
>
> 1. What should be data type for large input string? Is NullableVarcharHolder correct approach?
> 2. How to get it into string in such scenarios?
>
>
> -
> Thanks,
> Sandeep