Github user chaithu14 commented on a diff in the pull request:

    https://github.com/apache/apex-malhar/pull/324#discussion_r68559313
  
    --- Diff: 
library/src/main/java/org/apache/apex/malhar/lib/utils/serde/SliceUtils.java ---
    @@ -0,0 +1,52 @@
    +package org.apache.apex.malhar.lib.utils.serde;
    +
    +import com.datatorrent.netlet.util.Slice;
    +
    +public class SliceUtils
    +{
    +  private SliceUtils()
    +  {
    +  }
    +
    +  public static byte[] concatenate(byte[] a, byte[] b)
    +  {
    +    byte[] output = new byte[a.length + b.length];
    +
    +    System.arraycopy(a, 0, output, 0, a.length);
    +    System.arraycopy(b, 0, output, a.length, b.length);
    +    return output;
    +  }
    +
    +  public static Slice concatenate(Slice a, Slice b)
    +  {
    +    int size = a.length + b.length;
    +    byte[] bytes = new byte[size];
    +
    +    System.arraycopy(a.buffer, a.offset, bytes, 0, a.length);
    +    System.arraycopy(b.buffer, b.offset, bytes, a.length, b.length);
    +
    +    return new Slice(bytes);
    +  }
    +
    +  public static Slice concatenate(byte[] a, Slice b)
    +  {
    +    int size = a.length + b.length;
    +    byte[] bytes = new byte[size];
    +
    +    System.arraycopy(a, 0, bytes, 0, a.length);
    +    System.arraycopy(b.buffer, b.offset, bytes, a.length, b.length);
    +
    +    return new Slice(bytes);
    +  }
    +
    +  public static Slice concatenate(Slice a, byte[] b)
    +  {
    +    int size = a.length + b.length;
    +    byte[] bytes = new byte[size];
    +
    +    System.arraycopy(a, a.offset, bytes, 0, a.length);
    --- End diff --
    
    a.buffer instead of a.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to