[GitHub] incubator-flink pull request: Serialized String comparison, Unicod...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: Serialized String comparison, Unicod...

zentol
Github user zentol commented on the pull request:

    https://github.com/apache/incubator-flink/pull/4#issuecomment-46499365
 
    ok i was right after all :)
    the readUnicodeCharAsByteArray could look like this
    ```
    private static byte[] readUnicodeCharAsByteArray(DataInput in) throws IOException {
    byte a;
    if ((a = in.readByte()) >= HIGH_BIT) {
    byte b;
    if ((b = in.readByte()) >= HIGH_BIT) {
    byte c;
    if ((c = in.readByte()) >= HIGH_BIT) {
    byte d = in.readByte();
    return new byte[]{a,b,c,d};
    }
    return new byte[]{0,a,b,c};
    }
    return new byte[]{0,0,a,b};
    }
    return new byte[]{0,0,0,a};
    }
    ```
    and the string one like this
    ```
    public static final byte[] readUnicodeStringAsByteArray(DataInput in) throws IOException {
    int len = readLength(in);
   
    ByteArrayOutputStream out = new ByteArrayOutputStream(len);
   
    if(len==0) {
    return new byte[0];
    }
   
    for (int i = 0; i < len; i++) {
    out.write(readUnicodeCharAsByteArray(in));
    }
    return out.toByteArray();
    }
    ```


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---