You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Akash Ashok <th...@gmail.com> on 2011/08/01 07:01:55 UTC

heapSize() implementation of KeyValue

Hi,
     I was going thru the heapSize() method in the class KeyValue and i
couldn't seem to understand a few things which are in bold below


  private byte [] bytes = null;
  private int offset = 0;
  private int length = 0;
  private int keyLength = 0;

  // the row cached
  private byte [] rowCache = null;

  // default value is 0, aka DNC
  private long memstoreTS = 0;
  * @return Timestamp
  */
  private long timestampCache = -1;


 public long heapSize() {
    return ClassSize.align(
    // Fixed Object size
    ClassSize.OBJECT +

*    // Why this ?????
    (2 * ClassSize.REFERENCE) +*

    // bytes Array
    ClassSize.align(ClassSize.ARRAY) +

    //Size of int length
    ClassSize.align(length) +

*    // Why this ?? There are only 2 ints leaving length which are int (
offset, length)
    (3 * Bytes.SIZEOF_INT) +
*
    // rowCache byte array
        ClassSize.align(ClassSize.ARRAY) +

    // Accounts for the longs memstoreTS and timestampCache
    (2 * Bytes.SIZEOF_LONG));
  }

Re: heapSize() implementation of KeyValue

Posted by Akash Ashok <th...@gmail.com>.
Sorry I think thats the length of the Array being taken care of not the size
of the int itself. My bad i confused it with size of the "int" itself.

I think that explains it. Thanks a lot :)


On Mon, Aug 1, 2011 at 10:51 AM, Akash Ashok <th...@gmail.com> wrote:

> Three integers are pasted in but "private int length" is already taken care
> of by
>
>  //Size of int length
> >    ClassSize.align(length) +
>
> So only 2 more integers are left right ?
>
>
> On Mon, Aug 1, 2011 at 10:37 AM, Ryan Rawson <ry...@gmail.com> wrote:
>
>> Each array is really a pointer to an array (hence the references),
>> then we are taking account of the overhead of the 'bytes' array
>> itself.
>>
>> And I see 3 integers pasted in, so things are looking good to me....
>>
>> On Sun, Jul 31, 2011 at 10:01 PM, Akash Ashok <th...@gmail.com>
>> wrote:
>> > Hi,
>> >     I was going thru the heapSize() method in the class KeyValue and i
>> > couldn't seem to understand a few things which are in bold below
>> >
>> >
>> >  private byte [] bytes = null;
>> >  private int offset = 0;
>> >  private int length = 0;
>> >  private int keyLength = 0;
>> >
>> >  // the row cached
>> >  private byte [] rowCache = null;
>> >
>> >  // default value is 0, aka DNC
>> >  private long memstoreTS = 0;
>> >  * @return Timestamp
>> >  */
>> >  private long timestampCache = -1;
>> >
>> >
>> >  public long heapSize() {
>> >    return ClassSize.align(
>> >    // Fixed Object size
>> >    ClassSize.OBJECT +
>> >
>> > *    // Why this ?????
>> >    (2 * ClassSize.REFERENCE) +*
>> >
>> >    // bytes Array
>> >    ClassSize.align(ClassSize.ARRAY) +
>> >
>> >    //Size of int length
>> >    ClassSize.align(length) +
>> >
>> > *    // Why this ?? There are only 2 ints leaving length which are int (
>> > offset, length)
>> >    (3 * Bytes.SIZEOF_INT) +
>> > *
>> >    // rowCache byte array
>> >        ClassSize.align(ClassSize.ARRAY) +
>> >
>> >    // Accounts for the longs memstoreTS and timestampCache
>> >    (2 * Bytes.SIZEOF_LONG));
>> >  }
>> >
>>
>
>

Re: heapSize() implementation of KeyValue

Posted by Akash Ashok <th...@gmail.com>.
Three integers are pasted in but "private int length" is already taken care
of by

 //Size of int length
>    ClassSize.align(length) +

So only 2 more integers are left right ?

On Mon, Aug 1, 2011 at 10:37 AM, Ryan Rawson <ry...@gmail.com> wrote:

> Each array is really a pointer to an array (hence the references),
> then we are taking account of the overhead of the 'bytes' array
> itself.
>
> And I see 3 integers pasted in, so things are looking good to me....
>
> On Sun, Jul 31, 2011 at 10:01 PM, Akash Ashok <th...@gmail.com>
> wrote:
> > Hi,
> >     I was going thru the heapSize() method in the class KeyValue and i
> > couldn't seem to understand a few things which are in bold below
> >
> >
> >  private byte [] bytes = null;
> >  private int offset = 0;
> >  private int length = 0;
> >  private int keyLength = 0;
> >
> >  // the row cached
> >  private byte [] rowCache = null;
> >
> >  // default value is 0, aka DNC
> >  private long memstoreTS = 0;
> >  * @return Timestamp
> >  */
> >  private long timestampCache = -1;
> >
> >
> >  public long heapSize() {
> >    return ClassSize.align(
> >    // Fixed Object size
> >    ClassSize.OBJECT +
> >
> > *    // Why this ?????
> >    (2 * ClassSize.REFERENCE) +*
> >
> >    // bytes Array
> >    ClassSize.align(ClassSize.ARRAY) +
> >
> >    //Size of int length
> >    ClassSize.align(length) +
> >
> > *    // Why this ?? There are only 2 ints leaving length which are int (
> > offset, length)
> >    (3 * Bytes.SIZEOF_INT) +
> > *
> >    // rowCache byte array
> >        ClassSize.align(ClassSize.ARRAY) +
> >
> >    // Accounts for the longs memstoreTS and timestampCache
> >    (2 * Bytes.SIZEOF_LONG));
> >  }
> >
>

Re: heapSize() implementation of KeyValue

Posted by Ryan Rawson <ry...@gmail.com>.
Each array is really a pointer to an array (hence the references),
then we are taking account of the overhead of the 'bytes' array
itself.

And I see 3 integers pasted in, so things are looking good to me....

On Sun, Jul 31, 2011 at 10:01 PM, Akash Ashok <th...@gmail.com> wrote:
> Hi,
>     I was going thru the heapSize() method in the class KeyValue and i
> couldn't seem to understand a few things which are in bold below
>
>
>  private byte [] bytes = null;
>  private int offset = 0;
>  private int length = 0;
>  private int keyLength = 0;
>
>  // the row cached
>  private byte [] rowCache = null;
>
>  // default value is 0, aka DNC
>  private long memstoreTS = 0;
>  * @return Timestamp
>  */
>  private long timestampCache = -1;
>
>
>  public long heapSize() {
>    return ClassSize.align(
>    // Fixed Object size
>    ClassSize.OBJECT +
>
> *    // Why this ?????
>    (2 * ClassSize.REFERENCE) +*
>
>    // bytes Array
>    ClassSize.align(ClassSize.ARRAY) +
>
>    //Size of int length
>    ClassSize.align(length) +
>
> *    // Why this ?? There are only 2 ints leaving length which are int (
> offset, length)
>    (3 * Bytes.SIZEOF_INT) +
> *
>    // rowCache byte array
>        ClassSize.align(ClassSize.ARRAY) +
>
>    // Accounts for the longs memstoreTS and timestampCache
>    (2 * Bytes.SIZEOF_LONG));
>  }
>