@Override public FloatValue copy(FloatValue from, FloatValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public FloatValue copy(FloatValue from, FloatValue reuse) { reuse.setValue(from.getValue()); return reuse; }
@Override public int parseField(byte[] bytes, int startPos, int limit, char delim, FloatValue reusable) { int i = startPos; final byte delByte = (byte) delim; while (i < limit && bytes[i] != delByte) { i++; } String str = new String(bytes, startPos, i-startPos); try { float value = Float.parseFloat(str); reusable.setValue(value); this.result = reusable; return (i == limit) ? limit : i+1; } catch (NumberFormatException e) { setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR); return -1; } }
@Override public int parseField(byte[] bytes, int startPos, int limit, char delim, FloatValue reusable) { int i = startPos; final byte delByte = (byte) delim; while (i < limit && bytes[i] != delByte) { i++; } String str = new String(bytes, startPos, i-startPos); try { float value = Float.parseFloat(str); reusable.setValue(value); this.result = reusable; return (i == limit) ? limit : i+1; } catch (NumberFormatException e) { setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR); return -1; } }
private final Value convertAvroPrimitiveToValue(Type type, Object avroRecord) { switch (type) { case STRING: sString.setValue((CharSequence) avroRecord); return sString; case INT: sInt.setValue((Integer) avroRecord); return sInt; case BOOLEAN: sBool.setValue((Boolean) avroRecord); return sBool; case DOUBLE: sDouble.setValue((Double) avroRecord); return sDouble; case FLOAT: sFloat.setValue((Float) avroRecord); return sFloat; case LONG: sLong.setValue((Long) avroRecord); return sLong; case NULL: return NullValue.getInstance(); default: throw new RuntimeException( "Type " + type + " for AvroInputFormat is not implemented. Open an issue on GitHub."); } }