You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@fluo.apache.org by keith-turner <gi...@git.apache.org> on 2017/04/26 20:55:32 UTC

[GitHub] incubator-fluo issue #827: Add copyTo() method to bytes

GitHub user keith-turner opened an issue:

    https://github.com/apache/incubator-fluo/issues/827

    Add copyTo() method to bytes

    For data serialization use cases, a user may want to copy multiple Bytes objects to a byte array.   The current options for that are to call Bytes.toArray() or use the Bytes.byteAt() method.  If Bytes had a `copyTo(byte[] dest, int offset)`   method then it could support this use case more efficiently.  The following is an example.
    
    ```java
    Bytes field1 = Bytes.of("foo");
    Bytes field2 = Bytes.of("bar");
    
    byte[] dest = new byte[field1.length() + field2.lenght() + 1];
    
    field1.copyTo(dest, 0);
    dest[field1.lenght()] = ':';
    field2.copyTo(dest, field1.lenght()+1);
    ```
    


----

----


---
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.
---

[GitHub] incubator-fluo issue #827: Add copyTo() method to bytes

Posted by mjwall <gi...@git.apache.org>.
Github user mjwall commented on the issue:

    https://github.com/apache/incubator-fluo/issues/827
  
    I can take a swing at this one.  Is there a way for us to assign issues in GH?


---
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.
---

[GitHub] incubator-fluo issue #827: Add copyTo() method to bytes

Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on the issue:

    https://github.com/apache/incubator-fluo/issues/827
  
    Not yet, but hopefully soon [INFRA-14121](https://issues.apache.org/jira/browse/INFRA-14121)


---
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.
---

[GitHub] incubator-fluo issue #827: Add copyTo() method to bytes

Posted by ctubbsii <gi...@git.apache.org>.
Github user ctubbsii commented on the issue:

    https://github.com/apache/incubator-fluo/issues/827
  
    Looking at this example, I'm wondering if the javadoc for any such method should make it a point to remind the user that the offset and length correspond to the UTF-8 encoded byte array form of any String/CharSequence that they may have used to construct the Bytes with, and may differ from the character offsets in the original string.


---
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.
---

[GitHub] incubator-fluo issue #827: Add copyTo() method to bytes

Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on the issue:

    https://github.com/apache/incubator-fluo/issues/827
  
    For the case where a subsequence of a Bytes object needs to be copied, I was thinking the `subsequence()` method could be used.  For example the following could copy the 1st 255 bytes of `b1` to `dest` starting at offset 1024.
    
    ```java 
    
    byte[] dest = ...
    
    Bytes b1;
    
    b1.subsequence(0,255).copyTo(dest, 1024);
    ```
    
    However, calling subsequence will allocate an intermediate Bytes object.  To avoid this, we could have a method like `copyTo(int sourceOffset,  byte[] dest, int destOffset, int len)` instead of `copyTo(byte[] dest, int offset)`.


---
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.
---