We don't need to return BYTE and SHORT, as everything which might
care widens to INT.
192240
private static int typeCode(Object a) {
        if (a instanceof java.lang.Integer) return INT;
        if (a instanceof java.lang.Double) return DOUBLE;
        if (a instanceof java.lang.Long) return LONG;
        if (a instanceof java.lang.Character) return CHAR;
        if (a instanceof java.lang.Float) return FLOAT;
        if ((a instanceof java.lang.Byte) || (a instanceof java.lang.Short)) return INT;
        return OTHER;
    }
1128569
private boolean valueLengthContains(int value, int index) {
    int initialValue = toIntUnsigned(getValue(index));
    int length = toIntUnsigned(getLength(index));

    return value <= initialValue + length;
  }
493078
private static long addUnsignedReturnOverflow(Slice left, Slice right, Slice result, boolean resultNegative)
    {
        // TODO: consider two 7 bytes operations
        int l0 = getInt(left, 0);
        int l1 = getInt(left, 1);
        int l2 = getInt(left, 2);
        int l3 = getInt(left, 3);

        int r0 = getInt(right, 0);
        int r1 = getInt(right, 1);
        int r2 = getInt(right, 2);
        int r3 = getInt(right, 3);

        long intermediateResult;
        intermediateResult = (l0 & LONG_MASK) + (r0 & LONG_MASK);

        int z0 = (int) intermediateResult;

        intermediateResult = (l1 & LONG_MASK) + (r1 & LONG_MASK) + (intermediateResult >>> 32);

        int z1 = (int) intermediateResult;

        intermediateResult = (l2 & LONG_MASK) + (r2 & LONG_MASK) + (intermediateResult >>> 32);

        int z2 = (int) intermediateResult;

        intermediateResult = (l3 & LONG_MASK) + (r3 & LONG_MASK) + (intermediateResult >>> 32);

        int z3 = (int) intermediateResult & (~SIGN_INT_MASK);

        pack(result, z0, z1, z2, z3, resultNegative);

        return intermediateResult >> 31;
    }
526970
public int expectUnsigned(int bytes) throws IOException {
        switch (bytes) {
            case 4:
                return expectUInt32();
            case 3:
                return expectUInt24();
            case 2:
                return expectUInt16();
            case 1:
                return expectUInt8();
        }
        throw new IllegalArgumentException("Unsupported byte count for unsigned: " + bytes);
    }
685457
public short expectShort() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            throw new IOException("Missing byte 1 to expected short");
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to expected short");
        }
        return (short) unshift2bytes(b1, b2);
    }
1314180
public static DataType typeFromTensorType(byte type, int elementSize) {
        if(type == Type.FloatingPoint) {
            return DataType.FLOAT;
        }
        else if(type == Type.Decimal) {
            return DataType.DOUBLE;
        }
        else if(type == Type.Int) {
            if(elementSize == 4) {
                return DataType.INT;
            }
            else if(elementSize == 8) {
                return DataType.LONG;
            }
        }
        else {
            throw new IllegalArgumentException("Only valid types are Type.Decimal and Type.Int");
        }

        throw new IllegalArgumentException("Unable to determine data type");
    }
810764
public boolean removeAll(CompactIntSet ints) {
        int oldSize = size();
        bitSet.andNot(ints.bitSet);
        return oldSize != size();
    }
712165
function intcheck(min, max) {
  //--int i;
  var i;
  i=this.intValueExact(); // [checks for non-0 decimal part]
  // Use same message as though intValueExact failed due to size
  if ((i<min)||(i>max))
   throw "intcheck(): Conversion overflow: "+i;
  return i;
  }
821341
@Override
    public int smallByteSize() {
        int bound = byteSize();
        ByteBuffer buf = ByteBuffer.allocate(bound);
        asSmallBytes(buf);
        return buf.position();
    }
1189836
private static int readShortLength(DataInput in) throws IOException {
        int length = (in.readByte() & 0xFF) << 8;
        return length | (in.readByte() & 0xFF);
    }
354578
private boolean lessThanOrEqual(
         byte[] a,
         byte[] b)
    {
         if (a.length <= b.length)
         {
             for (int i = 0; i != a.length; i++)
             {
                 int    l = a[i] & 0xff;
                 int    r = b[i] & 0xff;

                 if (r > l)
                 {
                     return true;
                 }
                 else if (l > r)
                 {
                     return false;
                 }
             }

             return true;
         }
         else
         {
             for (int i = 0; i != b.length; i++)
             {
                 int    l = a[i] & 0xff;
                 int    r = b[i] & 0xff;

                 if (r > l)
                 {
                     return true;
                 }
                 else if (l > r)
                 {
                     return false;
                 }
             }

             return false;
         }
    }
1115286
private static int readFully(InputStream in, ByteArrayOutputStream bout,
            int length) throws IOException {
        int read = 0;
        byte[] buffer = new byte[2048];
        while (length > 0) {
            int n = in.read(buffer, 0, length<2048?length:2048);
            if (n <= 0) {
                break;
            }
            bout.write(buffer, 0, n);
            read += n;
            length -= n;
        }
        return read;
    }
960188
def fixed_length(cls, l, allow_empty=False):
        """"""
        return cls(l, l, allow_empty=allow_empty)
248440
private int s2i(final byte[] bytes) {
    int num = 0;
    for (int i = 0; i < 4; i++) {
      num += (bytes[i] & 0xff) << ((3 - i) * 8);
    }
    return num;
  }
687903
static int wrap(int value, int max)
    {
        int result = value % max;
        if (result < 0) 
        {
            return result + (max > 0 ? max : - max);        
        }
        return result;
    }
19838
private static final long gatherPartialLongLE(final byte[] data, final int index, final int available) {
        if(available >= 4) {
            int i = gatherIntLE(data, index);
            long l = uintToLong(i);

            int left = available - 4;

            if(left == 0) {
                return l;
            }

            int i2 = gatherPartialIntLE(data, index + 4, left);

            l <<= (left << 3);
            l |= (long) i2;

            return l;
        } else {
            return (long) gatherPartialIntLE(data, index, available);
        }
    }
21831
private static final long gatherLongLE(final byte[] data, final int index) {
        int i1 = gatherIntLE(data, index);
        long l2 = gatherIntLE(data, index + 4);

        return uintToLong(i1) | (l2 << 32);
    }