public static Object[] toArray(final Object value, final String fieldName, final DataType elementDataType) { return toArray(value, fieldName, elementDataType, StandardCharsets.UTF_8); }
@Override public Object[] getAsArray(final String fieldName) { return DataTypeUtils.toArray(getValue(fieldName), fieldName, null, StandardCharsets.UTF_8); }
@Override public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { if (!(fv.getValue() instanceof String)) { throw new IllegalArgumentException("Argument supplied to toBytes must be a String"); } final Charset charset = getCharset(this.charsetSegment, context); final byte[] bytesValue; Byte[] src = (Byte[]) DataTypeUtils.toArray(fv.getValue(), fv.getField().getFieldName(), RecordFieldType.BYTE.getDataType(), charset); bytesValue = new byte[src.length]; for (int i = 0; i < src.length; i++) { bytesValue[i] = src[i]; } return new StandardFieldValue(bytesValue, fv.getField(), fv.getParent().orElse(null)); }); }
return toTimestamp(value, timestampFormat, fieldName); case ARRAY: return toArray(value, fieldName, ((ArrayDataType)dataType).getElementType(), charset); case MAP: return toMap(value, fieldName);
public static Object[] toArray(final Object value, final String fieldName, final DataType elementDataType) { return toArray(value, fieldName, elementDataType, StandardCharsets.UTF_8); }
@Override public Object[] getAsArray(final String fieldName) { return DataTypeUtils.toArray(getValue(fieldName), fieldName, null, StandardCharsets.UTF_8); }
@Override public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { if (!(fv.getValue() instanceof String)) { throw new IllegalArgumentException("Argument supplied to toBytes must be a String"); } final Charset charset = getCharset(this.charsetSegment, context); final byte[] bytesValue; Byte[] src = (Byte[]) DataTypeUtils.toArray(fv.getValue(), fv.getField().getFieldName(), RecordFieldType.BYTE.getDataType(), charset); bytesValue = new byte[src.length]; for (int i = 0; i < src.length; i++) { bytesValue[i] = src[i]; } return new StandardFieldValue(bytesValue, fv.getField(), fv.getParent().orElse(null)); }); }
return toTimestamp(value, timestampFormat, fieldName); case ARRAY: return toArray(value, fieldName, ((ArrayDataType)dataType).getElementType(), charset); case MAP: return toMap(value, fieldName);