odps-sdk/odps-sdk-core/src/main/java/com/aliyun/odps/tunnel/hasher/DefaultHashFactory.java [332:402]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private static class TimestampHasher implements OdpsHasher<Instant> {

    @Override
    public Instant normalizeType(Object value) {
      if (value instanceof java.sql.Timestamp) {
        return ((Timestamp) value).toInstant();
      }
      if (value instanceof LocalDateTime) {
        return ((LocalDateTime) value).toInstant(ZoneOffset.UTC);
      }

      return OdpsHasher.super.normalizeType(value);
    }

    @Override
    public int hash(Instant val) {
      if (val == null) {
        return 0;
      }
      long seconds = val.getEpochSecond();
      int nanos = val.getNano();
      seconds <<= 30;
      seconds |= nanos;
      return basicLongHasher(seconds);
    }
  }

  /**
   * Interval Day to time type hash
   */
  private static class IntervalDayTimeHasher implements OdpsHasher<IntervalDayTime> {

    @Override
    public int hash(IntervalDayTime val) {
      if (val == null) {
        return 0;
      }

      long totalSec = val.getTotalSeconds();
      int nanos = val.getNanos();
      totalSec <<= 30;
      totalSec |= nanos;
      return basicLongHasher(totalSec);
    }
  }

  /**
   * Decimal type hash
   * for apsara::odps::RuntimeDecimalVal
   */
  private static class DecimalHasher implements OdpsHasher<DecimalHashObject> {

    @Override
    public int hash(DecimalHashObject obj) {
      if (obj == null) {
        return 0;
      }
      BigDecimal val = obj.val();
      int precision = obj.precision();
      int scale = obj.scale();
      BigInteger bi = castBigDecimal2BigInteger(val.toString(), precision, scale);
      if (isDecimal128(precision)) {
        // Reference to task/sql_task/execution_engine/ir/hash_ir.cpp:HashInt1284Row
        return basicLongHasher(bi.longValue()) + basicLongHasher(bi.shiftRight(64).longValue());
      }
      return basicLongHasher(bi.longValue());
    }

    // Reference to include/runtime_decimal_val.h:isDecimal128
    private boolean isDecimal128(int precision) {
      return precision > 18;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



odps-sdk/odps-sdk-core/src/main/java/com/aliyun/odps/tunnel/hasher/LegacyHashFactory.java [291:355]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private static class TimestampHasher implements OdpsHasher<Instant> {

    @Override
    public Instant normalizeType(Object value) {
      if (value instanceof java.sql.Timestamp) {
        return ((Timestamp) value).toInstant();
      }
      if (value instanceof LocalDateTime) {
        return ((LocalDateTime) value).toInstant(ZoneOffset.UTC);
      }
      return OdpsHasher.super.normalizeType(value);
    }

    @Override
    public int hash(Instant val) {
      if (val == null) {
        return 0;
      }
      long seconds = val.getEpochSecond();
      int nanos = val.getNano();
      seconds <<= 30;
      seconds |= nanos;
      return basicLongHasher(seconds);
    }
  }

  /**
   * Interval Day to time type hash
   */
  private static class IntervalDayTimeHasher implements OdpsHasher<IntervalDayTime> {

    @Override
    public int hash(IntervalDayTime val) {
      if (val == null) {
        return 0;
      }

      long totalSec = val.getTotalSeconds();
      int nanos = val.getNanos();
      totalSec <<= 30;
      totalSec |= nanos;
      return basicLongHasher(totalSec);
    }
  }

  private static class DecimalHasher implements OdpsHasher<DecimalHashObject> {
    @Override
    public int hash(DecimalHashObject obj) {
      if (obj == null) {
        return 0;
      }
      BigDecimal val = obj.val();
      int precision = obj.precision();
      int scale = obj.scale();
      BigInteger bi = castBigDecimal2BigInteger(val.toString(), precision, scale);
      if (isDecimal128(precision)) {
        // Reference to task/sql_task/execution_engine/ir/hash_ir.cpp:HashInt1284Row
        return basicLongHasher(bi.longValue()) + basicLongHasher(bi.shiftRight(64).longValue());
      }
      return basicLongHasher(bi.longValue());
    }

    // Reference to include/runtime_decimal_val.h:isDecimal128
    private boolean isDecimal128(int precision) {
      return precision > 18;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



