@SuppressFBWarnings(value = {"SF_SWITCH_FALLTHROUGH", "SF_SWITCH_NO_DEFAULT"}, justification = "Intentional fall through")
    public byte fastUpdateFromInternalStorage(byte[] internalStorage) {
        byte signum = 0;
        int skip = 0;
        this.count = 0;
        // Skip over any leading 0s or 0xFFs
        byte firstByte = internalStorage[0];
        if (firstByte == 0 || firstByte == -1) {
            while((skip < internalStorage.length) &&
              (internalStorage[skip] == firstByte)) {
                ++skip;
            }
        }
        if (skip == internalStorage.length) {
          // The entire storage is 0x00s or 0xFFs
          // 0x00s means is 0
          // 0xFFs means is -1
          assert (firstByte == 0 || firstByte == -1);
          if (firstByte == -1) {
             signum = -1;
             this.count = 1;
             this.v[0] = 1;
          }
          else {
            signum = 0;
          }
        }
        else {
            // We skipped over leading 0x00s and 0xFFs
            // Important, signum is given by the firstByte, not by byte[keep]!
            signum = (firstByte < 0) ? (byte) -1 : (byte) 1;

            // Now we read the big-endian compacted two's complement int parts
            // Compacted means they are stripped of leading 0x00s and 0xFFs
            // This is why we do the intLength/pos tricks bellow
            // 'length' is all the bytes we have to read, after we skip 'skip'
            // 'pos' is where to start reading the current int
            // 'intLength' is how many bytes we read for the current int

            int length = internalStorage.length - skip;
            int pos = skip;
            int intLength = 0;
            switch(length) {
            case 16: ++intLength; //intentional fall through
            case 15: ++intLength;
            case 14: ++intLength;
            case 13: ++intLength;
                v[3] = fastUpdateIntFromInternalStorage(internalStorage, signum, pos, intLength);
                ++this.count;
                pos += intLength;
                intLength = 0;
                //intentional fall through
            case 12: ++intLength; //intentional fall through
            case 11: ++intLength;
            case 10: ++intLength;
            case 9: ++intLength;
                v[2] = fastUpdateIntFromInternalStorage(internalStorage, signum, pos, intLength);
                ++this.count;
                pos += intLength;
                intLength = 0;
                //intentional fall through
            case 8: ++intLength; //intentional fall through
            case 7: ++intLength;
            case 6: ++intLength;
            case 5: ++intLength;
                v[1] = fastUpdateIntFromInternalStorage(internalStorage, signum, pos, intLength);
                ++this.count;
                pos += intLength;
                intLength = 0;
                //intentional fall through
            case 4: ++intLength; //intentional fall through
            case 3: ++intLength;
            case 2: ++intLength;
            case 1: ++intLength;
                v[0] = fastUpdateIntFromInternalStorage(internalStorage, signum, pos, intLength);
                ++this.count;
                break;
            default:
                // This should not happen
                throw new RuntimeException("Impossible HiveDecimal internal storage length!");
            }
            if (signum == -1) {
                // So far we've read the one's complement
                // add 1 to turn it into two's complement
                for(int i = 0; i < this.count; ++i) {
                    if (v[i] != 0) {
                        v[i] = (int)((v[i] & 0xFFFFFFFFL) + 1);
                        if (v[i] != 0) {
                            break;
                        }
                    }
                }
            }
        }
        return signum;
    }
Updates this value from a serialized unscaled {@link java.math.BigInteger} representation.
This is used for fast update of a Decimal128 from a HiveDecimalWritable internal storage.
@param internalStorage
@return
common/src/java/org/apache/hadoop/hive/common/type/UnsignedInt128.java