drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcmcote <...@git.apache.org>
Subject [GitHub] drill pull request #512: Drill 4573 fix issue with unicode chars
Date Thu, 09 Jun 2016 01:39:03 GMT
Github user jcmcote commented on a diff in the pull request:

    https://github.com/apache/drill/pull/512#discussion_r66370984
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSequenceWrapper.java
---
    @@ -17,13 +17,52 @@
      */
     package org.apache.drill.exec.expr.fn.impl;
     
    +import java.nio.ByteBuffer;
    +import java.nio.CharBuffer;
    +import java.nio.charset.CharacterCodingException;
    +import java.nio.charset.Charset;
    +import java.nio.charset.CharsetDecoder;
    +import java.nio.charset.CoderResult;
    +import java.util.regex.Matcher;
    +
     import io.netty.buffer.DrillBuf;
     
    +/**
    + * A CharSequence is a readable sequence of char values. This interface provides
    + * uniform, read-only access to many different kinds of char sequences. A char
    + * value represents a character in the Basic Multilingual Plane (BMP) or a
    + * surrogate. Refer to Unicode Character Representation for details.<br>
    + * Specifically this implementation of the CharSequence adapts a Drill
    + * {@link DrillBuf} to the CharSequence. The implementation is meant to be
    + * re-used that is allocated once and then passed DrillBuf to adapt. This can be
    + * handy to exploit API that consume CharSequence avoiding the need to create
    + * string objects.
    + *
    + */
     public class CharSequenceWrapper implements CharSequence {
     
    +    // The adapted drill buffer (in the case of US-ASCII)
    +    private DrillBuf buffer;
    +    // The converted bytes in the case of non ASCII
    +    private CharBuffer charBuffer;
    --- End diff --
    
    The CharSequenceWrapper does the same work as the Java String. That is convert the utf-8
bytes to a sequence of chars.
    However it re-uses the CharBuffer instead of constantly allocating new arrays and letting
them garbage collect. This will eliminate lots of churn in the GC.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message