hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/Unsigned16.java
/**
   * Multiple the current number by a 16 byte unsigned integer. Overflow is not
   * detected and the result is the low 16 bytes of the result. The numbers 
   * are divided into 32 and 31 bit chunks so that the product of two chucks
   * fits in the unsigned 63 bits of a long.
   * @param b the other number
   */
Multiple the current number by a 16 byte unsigned integer. Overflow is not
detected and the result is the low 16 bytes of the result. The numbers
are divided into 32 and 31 bit chunks so that the product of two chucks
fits in the unsigned 63 bits of a long.
@param b the other number
Multiple the current number by a 16 byte unsigned integer . Overflow is not detected and the result is the low 16 bytes of the result . The numbers are divided into 32 and 31 bit chunks so that the product of two chucks fits in the unsigned 63 bits of a long . @param b the other number
void multiply(Unsigned16 b) {
    long[] left = new long[4];
    left[0] = lo8 & 0xffffffffl;
    left[1] = lo8 >>> 32;
    left[2] = hi8 & 0xffffffffl;
    left[3] = hi8 >>> 32;
    long[] right = new long[5];
    right[0] = b.lo8 & 0x7fffffffl;
    right[1] = (b.lo8 >>> 31) & 0x7fffffffl;
    right[2] = (b.lo8 >>> 62) + ((b.hi8 & 0x1fffffffl) << 2);
    right[3] = (b.hi8 >>> 29) & 0x7fffffffl;
    right[4] = (b.hi8 >>> 60);
    set(0);
    Unsigned16 tmp = new Unsigned16();
    for(int l=0; l < 4; ++l) {
      for (int r=0; r < 5; ++r) {
        long prod = left[l] * right[r];
        if (prod != 0) {
          int off = l*32 + r*31;
          tmp.set(prod);
          tmp.shiftLeft(off);
          add(tmp);
        }
      }
    }
  }
void multiply ( Unsigned16 b ) { long [ ] left = new long [ 4 ] ; left [ 0 ] = lo8 & 0xffffffffl ; left [ 1 ] = lo8 >>> 32 ; left [ 2 ] = hi8 & 0xffffffffl ; left [ 3 ] = hi8 >>> 32 ; long [ ] right = new long [ 5 ] ; right [ 0 ] = b . lo8 & 0x7fffffffl ; right [ 1 ] = ( b . lo8 >>> 31 ) & 0x7fffffffl ; right [ 2 ] = ( b . lo8 >>> 62 ) + ( ( b . hi8 & 0x1fffffffl ) << 2 ) ; right [ 3 ] = ( b . hi8 >>> 29 ) & 0x7fffffffl ; right [ 4 ] = ( b . hi8 >>> 60 ) ; set ( 0 ) ; Unsigned16 tmp = new Unsigned16 ( ) ; for ( int l = 0 ; l < 4 ; ++ l ) { for ( int r = 0 ; r < 5 ; ++ r ) { long prod = left [ l ] * right [ r ] ; if ( prod != 0 ) { int off = l * 32 + r * 31 ; tmp . set ( prod ) ; tmp . shiftLeft ( off ) ; add ( tmp ) ; } } } }
Multiple the current number by a 16 byte unsigned integer.
Multiple the current number by a 16 byte unsigned integer .
// divide the left into 4 32 bit chunks // divide the right into 5 31 bit chunks // clear the cur value