You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bookkeeper.apache.org by "Ivan Kelly (JIRA)" <ji...@apache.org> on 2011/07/14 10:40:00 UTC

[jira] [Commented] (BOOKKEEPER-33) Add length and offset parameter to addEntry

    [ https://issues.apache.org/jira/browse/BOOKKEEPER-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13065114#comment-13065114 ] 

Ivan Kelly commented on BOOKKEEPER-33:
--------------------------------------

{quote}
// from Utkarsh on dev list
Is it worth using ByteBuffer instead of passing around offset and limit
separately?
{quote}
I wouldn't like to have 
{code}
  public long addEntry(byte[] data) throws InterruptedException, BKException {
{code}
and
{code}
  public long addEntry(ByteBuffer data) throws InterruptedException, BKException {
{code}

This looks a little imbalanced to me. I'd prefer to either have only the ByteBuffer call, or to have:
{code}
  public long addEntry(byte[] data) throws InterruptedException, BKException {
  public long addEntry(byte[] data, int offset, int length) throws InterruptedException, BKException {
{code}

Internally we could use bytebuffers easily though.

> Add length and offset parameter to addEntry
> -------------------------------------------
>
>                 Key: BOOKKEEPER-33
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-33
>             Project: Bookkeeper
>          Issue Type: Improvement
>            Reporter: Ivan Kelly
>
> <from email to dev list>
> I'm having an issue with the LedgerHandle#addEntry api.
> [1] best illustrates it. I'm buffering namenode transactions in the stream and only transmitting when either flush is called or I have enough data to pass my threshold. This means I have a byte buffer in my class which I fill up as new transactions come in. When I transmit, I set this buffer as an entry to bookkeeper. I.e. N whole namenode transactions will be contained in 1 single bk entry. 
> The problem is this byte buffer (DataOutputBuffer in this case). I reuse the same buffer over and over. But this buffer has a fixed size. If I transmit before it is full, the whole buffer size will be transmitted anyhow. If the buffer is being reused, this will retransmit old transactions out of order. For example, in the first use, the buffer fills with, [a,b,c,d,e] and adds this as an entry and resets the byte buffer. Then transaction f is  added and flushed, in this case [f,b,c,d,e] is not transmitted. 
> What I need is the ability to set offset and length in the byte[] passed to addEntry. Is there a reason this wasn't added in the initial implementation? If not, and if you agree this is a valid usecase, ill open a JIRA and add this functionality. Im getting around this now by doing an extra Array.copyOf which is less than ideal.
> </from email>

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira