accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Dailey (JIRA)" <>
Subject [jira] [Commented] (ACCUMULO-2817) Add offset and limit arguments to byte array Encoder.decode method
Date Thu, 19 Feb 2015 01:53:12 GMT


Matt Dailey commented on ACCUMULO-2817:

Realized I need to add in bounds checking to all of the {{decode(byte[], int, int)}} impls.

So, two design questions:

1.  Bounds checking wouldn't be necessary for when {{decode(byte[])}} calls the other method,
so would it be a good idea to do the following, or is this over-optimizing?

    public T decode(byte[] b) {
      return decodeUnchecked(b, 0, b.length);

    /** @since 1.7.0 */
    public T decode(byte[] b, int offset, int len) throws ValueFormatException {
      if (offset + len > b.length) {
        throw new ValueFormatException(String.format(
                "offset + length %d exceeds byte array length %d", (offset+len), b.length));
      } else {
        return decodeUnchecked(b, offset, len);

    /** @since 1.7.0 */
    public T decodeUnchecked(byte[] b, int offset, int len) {

2.  Do we agree it would be prudent to make a {{public abstract class AbstractEncoder<T>
implements Encoder<T>}} that has the above boilerplate {{decode(byte[], int, int)}}
and {{decode(byte[])}} methods?

> Add offset and limit arguments to byte array Encoder.decode method
> ------------------------------------------------------------------
>                 Key: ACCUMULO-2817
>                 URL:
>             Project: Accumulo
>          Issue Type: Improvement
>          Components: client
>            Reporter: Josh Elser
>            Assignee: Matt Dailey
>              Labels: newbie
>             Fix For: 1.7.0
>         Attachments: ACCUMULO-2817.patch
> Similar to ACCUMULO-2445, but presently the encoder only works on complete byte arrays.
This forces an extra copy of the data when it is located in an array that contains other information
(e.g. a composite key).
> It would be nice to be able to provide offset and length arguments to {{Encoder.decode}}
so that users can avoid the additional arraycopy.
> Changing to a ByteBuffer instead of byte array argument would also be acceptable, but
more churn on the API that, unless it's happening globally, I would rather avoid. It would
also incur the penalty for that extra Object, which while minimal alone, could be significant
if decoding every value in a table, for example.

This message was sent by Atlassian JIRA

View raw message