private int getSize(int pos, PrimitiveCategory category) {
    switch (category) {
    case VOID:
    case BOOLEAN:
    case BYTE:
    case SHORT:
    case INT:
    case LONG:
    case FLOAT:
    case DOUBLE:
      return javaSizePrimitiveType;
    case STRING:
      keyPositionsSize.add(Integer.valueOf(pos));
      return javaObjectOverHead;
    case BINARY:
      keyPositionsSize.add(Integer.valueOf(pos));
      return javaObjectOverHead;
    case TIMESTAMP:
    case TIMESTAMPLOCALTZ:
      return javaObjectOverHead + javaSizePrimitiveType;
    default:
      return javaSizeUnknownType;
    }
  }
The size of the element at position 'pos' is returned, if possible. If the
datatype is of variable length, STRING, a list of such key positions is
maintained, and the size for such positions is then actually calculated at
runtime.

@param pos
         the position of the key
@return the size of this datatype
ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java