- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Morphlines - converting a byte array field to a UTF-8 string
Created 09-30-2014 06:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got a record in Morphlines that includes a byte array field. I want to convert that to a UTF-8 string, i.e. the equivalent of String(field, "UTF-8) in Java.
I can see the readClob command exists, but that works on a whole record rather than a single field. Is there an alternative?
Appreciate that I should have stored my data differently, but it's not my format and that's what ETL tools (morphlines) are for! 😉
Thanks in advance.
Created 09-30-2014 11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
java {
code: """
String str = new String((byte[]) record.getFirstValue("myInputField"), "UTF-8");
record.put("myOutputField", str);
return getChild().process(record); // pass record to next command in chain
"""
}
Wolfgang.
Created 09-30-2014 11:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
java {
code: """
String str = new String((byte[]) record.getFirstValue("myInputField"), "UTF-8");
record.put("myOutputField", str);
return getChild().process(record); // pass record to next command in chain
"""
}
Wolfgang.
Created 09-30-2014 01:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect, thanks for this.
I was also having a look at something like:
{ setValues { _attachment_body : "@{myInputField}" } } { readClob { charSet : "UTF-8" } }
Out of interest, are there any disadvantages with that approach?
Thanks.
Created 09-30-2014 01:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wolfgang.
Created 10-20-2014 04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, what kind of source you use to get attachment_body? Is it possible to use HttpSource as a source and morphlinesolrsink to process accepted payload (xml data)
Created 07-11-2018 11:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While reading parquet file, How to convert Parquet DECIMAL datatype to String.
