Inside Drill we generally don't use that method for anything but debugging. I'm working on some other fixes and will roll in a change to correct this as well. You should be able to track it via DRILL-4246. In the meantime, a workaround is using the ByteBufUtil that Drill uses internally for this kind of thing:
DrillBuf myBuf = ... String bufAsString = ByteBufUtil.decodeString(myBuf.nioBuffer(), Charsets.UTF_8); -- Jacques Nadeau CTO and Co-Founder, Dremio On Fri, Jan 8, 2016 at 12:04 PM, Stefán Baxter <[email protected]> wrote: > So, > > This is happening due to changes made to DrillBuffer as a part of > Drill-4134 (53dcabeb83f53c8e29aff9c9282eaaa20a8b27ee) > > @Override > > public String toString(int index, int length, Charset charset) { > final String basics = > String.format("{DrillBuf[%d], udle identityHashCode == %d, > identityHashCode == %d}", > id, System.identityHashCode(byteBuf), > System.identityHashCode(refCnt)); > > if (length == 0) { > return basics; > } > > final ByteBuffer nioBuffer; > if (nioBufferCount() == 1) { > nioBuffer = nioBuffer(index, length); > } else { > nioBuffer = ByteBuffer.allocate(length); > getBytes(index, nioBuffer); > nioBuffer.flip(); > } > > return basics + '\n' + ByteBufUtil.decodeString(nioBuffer, charset); > } > > Now the returned value is prefixed with the *basics* part. > > I have no idea what the intention is here but it must be breaking more > code than just mine. > > Its also interesting that this signature is formatted/created every > time a value is fetched. > > Regards, > -Stefán > > > > > On Fri, Jan 8, 2016 at 7:48 PM, Stefán Baxter <[email protected]> > wrote: > > > Hi again, > > > > This code can be used to reproduce this behavior: > > > > @FunctionTemplate(name = "asEcho", scope = > FunctionTemplate.FunctionScope.SIMPLE, nulls = > FunctionTemplate.NullHandling.NULL_IF_NULL) > > public static class asEcho implements DrillSimpleFunc { > > > > @Param > > VarCharHolder input1; > > > > @Output > > VarCharHolder output; > > > > @Inject > > DrillBuf buffer; > > > > public void setup() { } > > > > public void eval() { > > String someValue = input1.buffer.toString(input1.start, > input1.end-input1.start, java.nio.charset.Charset.defaultCharset()); > > output.buffer = buffer.reallocIfNeeded(someValue.length()); > > for (Byte aByte : someValue.toString().getBytes()) > output.buffer.setByte(output.end ++, aByte); > > } > > } > > > > > > > > > > > > On Fri, Jan 8, 2016 at 7:43 PM, Stefán Baxter <[email protected] > > > > wrote: > > > >> Hi, > >> > >> This seems to have something to do with reading string values from a > >> VarCharHolder. > >> > >> Here is the code that has stopped working: > >> > >> String someValue = input2.buffer.toString(input2.start, > input2.end-input2 > >> .start, java.nio.charset.Charset.defaultCharset()) > >> > >> > >> It used to return only the string value but now it returns: > >> > >> {DrillBuf[77], udle identityHashCode == 1660956802, identityHashCode == > >> 343154168} > >> PT1H > >> > >> > >> The value is there in the second line (Seems to include a newline > >> character) > >> > >> Any ideas? > >> > >> Regards, > >> -Stefan > >> > >> > >> On Fri, Jan 8, 2016 at 7:24 PM, Stefán Baxter < > [email protected]> > >> wrote: > >> > >>> Hi, > >>> > >>> My UDFs have stopped working with the latest version of 1.5-SNAPSHOT > >>> (pulled just now). > >>> > >>> The error is: > >>> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for > >>> further details. > >>> Error: SYSTEM ERROR: IllegalArgumentException: Invalid format: > >>> "{DrillBuf[74], udle identityHash..." > >>> > >>> Fragment 1:5 > >>> > >>> [Error Id: 17b0165d-8ff3-4101-961a-0e40fdff0392 on Lightning:31010] > >>> (state=,code=0) > >>> > >>> > >>> Does anyone know what might be causing this? > >>> > >>> (The UDFs are compiled using the same target) > >>> > >>> Regards, > >>> -Stefán > >>> > >> > >> > > >
