public static Object getNonWritablePrimitiveObject(Object object, TypeInfo typeInfo,
      ObjectInspector objectInspector) {

    PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo;
    switch (primitiveTypeInfo.getPrimitiveCategory()) {
    case BOOLEAN:
      if (object instanceof Boolean) {
        return object;
      } else {
        return ((WritableBooleanObjectInspector) objectInspector).get(object);
      }
    case BYTE:
      if (object instanceof Byte) {
        return object;
      } else {
        return ((WritableByteObjectInspector) objectInspector).get(object);
      }
    case SHORT:
      if (object instanceof Short) {
        return object;
      } else {
        return ((WritableShortObjectInspector) objectInspector).get(object);
      }
    case INT:
      if (object instanceof Integer) {
        return object;
      } else {
        return ((WritableIntObjectInspector) objectInspector).get(object);
      }
    case LONG:
      if (object instanceof Long) {
        return object;
      } else {
        return ((WritableLongObjectInspector) objectInspector).get(object);
      }
    case FLOAT:
      if (object instanceof Float) {
        return object;
      } else {
        return ((WritableFloatObjectInspector) objectInspector).get(object);
      }
    case DOUBLE:
      if (object instanceof Double) {
        return object;
      } else {
        return ((WritableDoubleObjectInspector) objectInspector).get(object);
      }
    case STRING:
      if (object instanceof String) {
        return object;
      } else {
        return ((WritableStringObjectInspector) objectInspector).getPrimitiveJavaObject(object);
      }
    case DATE:
      if (object instanceof Date) {
        return object;
      } else {
        return ((WritableDateObjectInspector) objectInspector).getPrimitiveJavaObject(object);
      }
    case TIMESTAMP:
      if (object instanceof Timestamp) {
        return object;
      } else if (object instanceof org.apache.hadoop.hive.common.type.Timestamp) {
        return object;
      } else {
        return ((WritableTimestampObjectInspector) objectInspector).getPrimitiveJavaObject(object);
      }
    case DECIMAL:
      if (object instanceof HiveDecimal) {
        return object;
      } else {
        WritableHiveDecimalObjectInspector writableDecimalObjectInspector =
            new WritableHiveDecimalObjectInspector((DecimalTypeInfo) primitiveTypeInfo);
        return writableDecimalObjectInspector.getPrimitiveJavaObject(object);
      }
    case VARCHAR:
      if (object instanceof HiveVarchar) {
        return object;
      } else {
        WritableHiveVarcharObjectInspector writableVarcharObjectInspector =
            new WritableHiveVarcharObjectInspector( (VarcharTypeInfo) primitiveTypeInfo);
        return writableVarcharObjectInspector.getPrimitiveJavaObject(object);
      }
    case CHAR:
      if (object instanceof HiveChar) {
        return object;
      } else {
        WritableHiveCharObjectInspector writableCharObjectInspector =
            new WritableHiveCharObjectInspector( (CharTypeInfo) primitiveTypeInfo);
        return writableCharObjectInspector.getPrimitiveJavaObject(object);
      }
    case INTERVAL_YEAR_MONTH:
      if (object instanceof HiveIntervalYearMonth) {
        return object;
      } else {
        return ((WritableHiveIntervalYearMonthObjectInspector) objectInspector).getPrimitiveJavaObject(object);
      }
    case INTERVAL_DAY_TIME:
      if (object instanceof HiveIntervalDayTime) {
        return object;
      } else {
        return ((WritableHiveIntervalDayTimeObjectInspector) objectInspector).getPrimitiveJavaObject(object);
      }
    case BINARY:
    default:
      throw new RuntimeException(
          "Unexpected primitive category " + primitiveTypeInfo.getPrimitiveCategory());
    }
  }
Generate object inspector and random row object[].
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/VectorRandomRowSource.java