/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was an long value and returns the * result. Throws NumberFormatException if the string does not represent an * long 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 long 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 long quantity. */ public static long parseLong(byte[] bytes, int start, int length, int radix) { return parseLong(bytes, start, length, radix, false); }
/** * Convert from string to a long. This is called for CAST(... AS BIGINT) * * @param i * The string value to convert * @return LongWritable */ public LongWritable evaluate(Text i) { if (i == null) { return null; } else { if (!LazyUtils.isNumberMaybe(i.getBytes(), 0, i.getLength())) { return null; } try { longWritable .set(LazyLong.parseLong(i.getBytes(), 0, i.getLength(), 10, true)); return longWritable; } catch (NumberFormatException e) { // MySQL returns 0 if the string is not a well-formed numeric value. // return LongWritable.valueOf(0); // But we decided to return NULL instead, which is more conservative. return null; } } }
/** * Convert from string to a long. This is called for CAST(... AS BIGINT) * * @param i * The string value to convert * @return LongWritable */ public LongWritable evaluate(Text i) { if (i == null) { return null; } else { if (!LazyUtils.isNumberMaybe(i.getBytes(), 0, i.getLength())) { return null; } try { longWritable .set(LazyLong.parseLong(i.getBytes(), 0, i.getLength(), 10)); return longWritable; } catch (NumberFormatException e) { // MySQL returns 0 if the string is not a well-formed numeric value. // return LongWritable.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(parseLong(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "BIGINT"); } }
return; outputColVector.vector[batchIndex] = LazyLong.parseLong(bytes, start, length, 10); break; default:
if (soi.preferWritable()) { Text t = soi.getPrimitiveWritableObject(o); result = LazyLong.parseLong(t.getBytes(), 0, t.getLength()); } else { String s = soi.getPrimitiveJavaObject(o);
return; outV.vector[batchIndex] = LazyLong.parseLong(bytes, start, length, 10); break; default:
return false; currentLong = LazyLong.parseLong(bytes, fieldStart, fieldLength, 10); return true; case FLOAT:
/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was a long value and returns the * result. Throws NumberFormatException if the string does not represent a * long quantity. * * @param bytes * @param start * @param length * a UTF-8 encoded string representation of a long quantity. * @return long the value represented by the argument * @exception NumberFormatException * if the argument could not be parsed as a long quantity. */ public static long parseLong(byte[] bytes, int start, int length) { return parseLong(bytes, start, length, 10); }
/** * Parses the string argument as if it was an long value and returns the * result. Throws NumberFormatException if the string does not represent an * long 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 long 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 long quantity. */ public static long parseLong(byte[] bytes, int start, int length, int radix) { return parseLong(bytes, start, length, radix, false); }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseLong(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(parseLong(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "BIGINT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseLong(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "BIGINT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { try { data.set(parseLong(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "BIGINT"); } }
@Override public void init(ByteArrayRef bytes, int start, int length) { if (!LazyUtils.isNumberMaybe(bytes.getData(), start, length)) { isNull = true; return; } try { data.set(parseLong(bytes.getData(), start, length, 10)); isNull = false; } catch (NumberFormatException e) { isNull = true; logExceptionMessage(bytes, start, length, "BIGINT"); } }