long validatedLong(long longValue, String typeName, boolean isUnSigned) {
      switch (typeName) {
      case serdeConstants.BIGINT_TYPE_NAME:
        isValid = !isUnSigned || (longValue >= 0);
        break;
      case serdeConstants.INT_TYPE_NAME:
        isValid = ((longValue <= Integer.MAX_VALUE) &&
                   (longValue >= (isUnSigned ? 0 : Integer.MIN_VALUE)));
        break;
      case serdeConstants.SMALLINT_TYPE_NAME:
        isValid = ((longValue <= Short.MAX_VALUE) &&
                   (longValue >= (isUnSigned ? 0 : Short.MIN_VALUE)));
        break;
      case serdeConstants.TINYINT_TYPE_NAME:
        isValid = ((longValue <= Byte.MAX_VALUE) &&
                   (longValue >= (isUnSigned ? 0 : Byte.MIN_VALUE)));
        break;
      default:
        isValid = true;
      }

      if (isValid) {
        return longValue;
      } else {
        return 0;
      }
    }
Helper function to validate long data.  Sets the isValid to true if the data is valid
for the type it will be read in, otherwise false.
@param longValue input value of long type to be validated.
@param typeName the hivetype to be used to read the longValue
@param isUnSigned true when longValue is unsigned parquet type
@return 0 if the data is invalid, other longValue
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/vector/ParquetDataColumnReaderFactory.java