accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Turner <ke...@deenlo.com>
Subject Re: Key.getColumnFamilyAsBytes - comments about suggested new method?
Date Tue, 13 Nov 2012 21:15:22 GMT
When you get a field from Key as Text, it copies data.  You can avoid
this copy with key.getColumnFamilyData().toArray() .... As currently
implemented this will not copy the column family byte array.  It the
implementation of key were to change in the future (i.e. if key were
to use a single byte array like it used to), it may copy the byte
array.

Keith


On Tue, Nov 13, 2012 at 3:25 PM, David Medinets
<david.medinets@gmail.com> wrote:
> In Key.java, I see this:
>
>   public Text getColumnFamily(Text cf) {
>     cf.set(colFamily, 0, colFamily.length);
>     return cf;
>   }
>
>   public Text getColumnFamily() {
>     return getColumnFamily(new Text());
>   }
>
> in TabletServerBatchDeleter, I see this:
>
>         Mutation m = new Mutation(k.getRow());
>         m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), new
> ColumnVisibility(k.getColumnVisibility()), k.getTimestamp());
>
> The change I recently committed would allow using byte arrays as
> arguments to putDelete. It seems adding a method to Key like the
> following would eliminate creating the Text object:
>
>   public byte[] getColumnFamilyAsBytes() {
>     byte[] buffer = new byte[colFamily.length];
>     System.arraycopy(colFamily, 0, buffer, 0, colFamily.length);
>     return buffer;
>   }
>
> I don't want to head down a twisty windy path removing Text objects
> but does it make sense to reduce reliance on them?

Mime
View raw message