/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @return int the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. The second argument specifies the radix to use when parsing * the value. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @param radix * the base to use for conversion. * @return the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length, int radix) { return parseInt(bytes, start, length, radix, false); }
/** * Parses the string argument as if it was a byte value and returns the * result. Throws NumberFormatException if the string does not represent a * single byte quantity. The second argument specifies the radix to use when * parsing the value. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a single byte quantity. * @param radix * the radix to use when parsing. * @param trim * whether to trim leading/trailing whitespace * @return byte the value represented by the argument * @throws NumberFormatException * if the argument could not be parsed as a byte quantity. */ public static byte parseByte(byte[] bytes, int start, int length, int radix, boolean trim) { int intValue = LazyInteger.parseInt(bytes, start, length, radix, trim); byte result = (byte) intValue; if (result == intValue) { return result; } throw new NumberFormatException(); }
/** * Parses the string argument as if it was a short value and returns the * result. Throws NumberFormatException if the string does not represent a * single short quantity. The second argument specifies the radix to use when * parsing the value. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a short quantity. * @param radix * the radix to use when parsing. * @param trim * whether to trim leading/trailing whitespace * @return short the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a short quantity. */ public static short parseShort(byte[] bytes, int start, int length, int radix, boolean trim) { int intValue = LazyInteger.parseInt(bytes, start, length, radix, trim); short result = (short) intValue; if (result == intValue) { return result; } throw new NumberFormatException(); }
/** * Convert from string to an integer. This is called for CAST(... AS INT) * * @param i * The string value to convert * @return IntWritable */ public IntWritable evaluate(Text i) { if (i == null) { return null; } else { if (!LazyUtils.isNumberMaybe(i.getBytes(), 0, i.getLength())) { return null; } try { intWritable.set(LazyInteger .parseInt(i.getBytes(), 0, i.getLength(), 10, true)); return intWritable; } catch (NumberFormatException e) { // MySQL returns 0 if the string is not a well-formed numeric value. // return IntWritable.valueOf(0); // But we decided to return NULL instead, which is more conservative. return null; } } }
/** * Convert from string to an integer. This is called for CAST(... AS INT) * * @param i * The string value to convert * @return IntWritable */ public IntWritable evaluate(Text i) { if (i == null) { return null; } else { if (!LazyUtils.isNumberMaybe(i.getBytes(), 0, i.getLength())) { return null; } try { intWritable.set(LazyInteger .parseInt(i.getBytes(), 0, i.getLength(), 10)); return intWritable; } catch (NumberFormatException e) { // MySQL returns 0 if the string is not a well-formed numeric value. // return IntWritable.valueOf(0); // But we decided to return NULL instead, which is more conservative. return null; } } }
@Override public void init(ByteArrayRef bytes, int start, int length) { if (!LazyUtils.isNumberMaybe(bytes.getData(), start, length)) { isNull = true; return; } try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "INT"); } }
if (soi.preferWritable()) { Text t = soi.getPrimitiveWritableObject(o); result = LazyInteger.parseInt(t.getBytes(), 0, t.getLength()); } else { String s = soi.getPrimitiveJavaObject(o);
return; outputColVector.vector[batchIndex] = LazyInteger.parseInt(bytes, start, length, 10); break; case LONG:
return; outV.vector[batchIndex] = LazyInteger.parseInt(bytes, start, length, 10); break; case LONG:
return false; currentInt = LazyInteger.parseInt(bytes, fieldStart, fieldLength, 10); return true; case LONG:
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @return int the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @return int the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @return int the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }
/** * Parses the string argument as if it was an int value and returns the * result. Throws NumberFormatException if the string does not represent an * int quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of an int quantity. * @return int the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as an int quantity. */ public static int parseInt(byte[] bytes, int start, int length) { return parseInt(bytes, start, length, 10); }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; } }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "INT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "INT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "INT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { if (!LazyUtils.isNumberMaybe(bytes.getData(), start, length)) { isNull = true; return; } try { data.set(parseInt(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "INT"); } }