private int getSize(int pos, Class<?> c, Field f) {
    if (c.isPrimitive()
        || c.isInstance(Boolean.valueOf(true))
        || c.isInstance(Byte.valueOf((byte) 0))
        || c.isInstance(Short.valueOf((short) 0))
        || c.isInstance(Integer.valueOf(0))
        || c.isInstance(Long.valueOf(0))
        || c.isInstance(Float.valueOf(0)) || c.isInstance(Double.valueOf(0))) {
      return javaSizePrimitiveType;
    }

    if (c.isInstance(new Timestamp(0)) || c.isInstance(new TimestampTZ())) {
      return javaObjectOverHead + javaSizePrimitiveType;
    }

    if (c.isInstance(new String()) || c.isInstance(new ByteArrayRef())) {
      if (aggrPositions[pos] == null) {
        aggrPositions[pos] = new ArrayList<Field>();
      }
      aggrPositions[pos].add(f);
      return javaObjectOverHead;
    }

    return javaSizeUnknownType;
  }
The size of the element at position 'pos' is returned, if possible. If the
field is of variable length, STRING, a list of such field names for the
field position is maintained, and the size for such positions is then
actually calculated at runtime.

@param pos
         the position of the key
@param c
         the type of the key
@param f
         the field to be added
@return the size of this datatype
ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java