Streams

See below for more advanced operations you can perform on streams; for example, convert a record-type stream to a CSV-type stream.

Combining Streams in Containers

A container combines multiple streams. Most often, you use containers transparently, just like single streams; this section explains more about stream containers to show the common tasks of processing multiple data sources with a component.

For example, you can loop over each CSV file in a folder or process the CSV records as a single result set in memory.

Example: Processing a Container as a Result Set

The example flow inserts CSV files to a database using the following components: FileGet, Mapper, and RDBPut.

This flow uses the FileGet, Mapper, and RDBPut components.

Configuring the FileGet Component

Set the following properties to configure the FileGet component to output a container.

Walking through the Example

Follow this flow to process 3 CSV files with 3 records, 5 records, and 10 records, respectively.

  1. The FileGet component reads the data from files matching the pattern "*.csv." It combines the 3 resulting streams into a container.
  2. In the Mapper component, you map the inputs to outputs, just like you connect a single input stream.
  3. The RDBPut component processes the 18 records as a single stream, instead of performing the same operation on three separate streams.

Shared Functionality with Streams

The example highlights the features that containers share with single streams:

Additional Functionality and Limitations

Containers have the following differences from single streams:

Converting Stream Types

You can use the Converter component to convert compatible stream types; for example, you can convert a CSV stream to a binary stream. You could then store the whole CSV stream in a flow variable.

Note

  • Not all type conversions are valid.

  • When converting a stream type that can define multiple fields into another stream type that can also define multiple fields, you can't change the number of the fields or the field names. Note that this doesn't apply when you are converting a stream to a type that has a single field (MIME, HTML, text, and binary).

Stream type conversion table, from row x to column y.
Input/Output Binary *1 Text *2 HTML *3 CSV FixedLength XML Record ParameterList MIME *8
Binary ○ *4 ○ *6 ○ *7 × ×
Text ○ *4 ○ *6 ○ *7 × ×
HTML × × ○ *7 × ×
CSV × ○ *5 ○ *5 × ○ *5 ×
FixedLength × ○ *5 ○ *5 × ○ *5 ×
XML × × ○ *9 × ×
Record × ○ *5 ○ *5 ○ *1 ○ *5 × ○ *1
ParameterList × ○ *5 ○ *5 ○ *1 ○ *5 × ○ *1
MIME × × × × × ×

*1 The stream's binary value is used to convert binary to binary.

*2 The stream's string value is used to convert to a text stream.

*3 The HTML stream resulting from conversion isn't validated.

*4 Binary and text streams can be converted to CSV when the input data is in the CSV format.

*5 When converting across CSV, FixedLength, Record, and ParameterList streams, the fields are matched by index instead of their names. Note that the field definitions can't be changed.

*6 Binary and text streams can be converted to FixedLength when the input data conforms to the field definitions.

*7 Binary, text, and HTML streams can be converted to XML the input data is in the XML format.

*8 The conversion to MIME data adds the appropriate MIME header according to the stream type.

*9 An XML input stream is passed to an XML output stream without any changes. The input stream's field definitions will not be converted into the field definitions of the output XML stream.

Representing Stream Data

There are 3 ways to represent the data in any stream. Components use these representations to manipulate the data:

The following sections describe each stream type's 3 representations:

XML

Back to Representing Stream Data

CSV

Back to Representing Stream Data

FixedLength

Back to Representing Stream Data

Record

Back to Representing Stream Data

ParameterList

Back to Representing Stream Data

MIME

Back to Representing Stream Data

Text, HTML

Back to Representing Stream Data

Binary

Back to Representing Stream Data

Converting Field Data Types

When a value is assigned to a field or a variable by the Mapper component, the data type will be converted implicitly. If a value that can't be converted is assigned, an error will occur.

Data type conversion table, from row x to column y.
Input/Output Boolean Integer Decimal Double String Binary*1 DateTime
Boolean - ○*2 ○*2 ○*2 ○*3 ×
Integer ○*4 - ○*5
Decimal ○*4 - ○*5
Double ○*4 ○*11 - ○*5
String ○*6 △*9 △*9 △*9 - △*10
Binary *7 -
DateTime × ○*5 ○*5 ○*5 ○*8 -

○=can be converted. △=depends on the format. ×=can't be converted.

*1 Conversions to binary: the data is first converted to a string and then to bytes by the system's encoding.

*2 Boolean to numeric type conversions: True converts to 1 and False converts to 0.

*3 Boolean to string conversions: True converts to the string "true" and False converts to the string "false".

*4 Numeric type to boolean conversions: 0 converts to False and other values convert to true.

*5 Numeric to datetime conversions: you can convert values in milliseconds that count from 00:00:00 GMT January 1st 1970.

*6 String to boolean conversions: the conversion is not case sensitive.

*7 Conversions to binary: data is converted to binary after it has been stringified using the system's encoding.

*8 Datetime to string conversions: the standard date format in the Flow Service is "yyyy-MM-dd'T'HH:mm:ss'.'sss z".

*9 String to numeric conversions: only decimal numbers is valid. The Flow Service will ignore any blanks before and after the number.

*10 String to datetime conversions: refer to Formatting Datetimes, below.

*11 Double to integer conversions: the digits after the decimal point are truncated.

Note

  • No matter what the data type is, null can be converted successfully into every type.

  • If conversion fails in the Mapper component, an error will happen.

Formatting Datetimes

The standard datetime format in the Flow Service is the "yyyy-MM-dd'T'HH:mm:ss'.'SSS z" format defined in ISO 8601. This format is used when the datetime type is output as a string. z represents the time zone, and is recorded as "JST", "+0900", "GMT-01:00", etc. If the time zone is omitted, the datetime value is processed as the local time.

You can also use the following formats to specify a datetime value as a string:

yyyy-MM-dd'T'HH:mm:ss z
yyyy-MM-dd'T'HH:mm:ss'.'SSS z

Note that the Z format specifier specifies UTC time in the following format:

yyyyMMdd'T'HHmmss'.'SSSZ
This format is processed as GMT.

To the top of this page