MultiLevelReader
Short Description |
Ports |
Metadata |
MultiLevelReader Attributes |
Details |
Best Practices |
Compatibility |
See also |
Short Description
MultiLevelReader reads data from flat files with a heterogeneous structure.
Component | Data source | Input ports | Output ports | Each to all outputs | Different to different outputs | Transformation | Transf. req. | Java | CTL | Auto-propagated metadata |
---|---|---|---|---|---|---|---|---|---|---|
MultiLevelReader | flat file | 1 | 1-n | ⨯ | ✓ | ✓ | ✓ | ✓ | ⨯ | ⨯ |
Ports
Port type | Number | Required | Description | Metadata |
---|---|---|---|---|
Input | 0 | ⨯ | For port reading. See Reading from Input Port. | One field (byte , cbyte , string ). |
Output | 0 | ✓ | For correct data records | Any(Out0) |
1-N | ⨯ | For correct data records | Any(Out1-OutN) |
Metadata
MultiLevelReader does not propagate metadata.
MultiLevelReader has no metadata template.
Metadata on all output ports can use Autofilling Functions.
source_timestamp
and source_size
functions work only
when reading from a file directly (if the file is an archive or it is stored in a remote location,
timestamp will be empty and size will be 0).
MultiLevelReader Attributes
Attribute | Req | Description | Possible values |
---|---|---|---|
Basic | |||
File URL | yes | Attribute specifying what data source(s) will be read (flat file, input port, dictionary). See Supported File URL Formats for Readers. | |
Charset | Encoding of records that are read. The default encoding depends on DEFAULT_CHARSET_DECODER in defaultProperties. | UTF-8 | <other encodings> | |
Data policy | Determines what should be done when an error occurs. For more information, see Data Policy. | Strict (default) | Lenient | |
Selector code | [1] | Transformation of rows of input data file to data records written in the graph in Java. | |
Selector URL | [1] | The name of an external file, including the path, defining the transformation of rows of input data file to data records written in Java. | |
Selector class | [1] | The name of an external class defining the transformation of rows of input data file to data records. | PrefixMultiLevelSelector (default) | other class |
Selector properties |
The list of the | ||
Advanced | |||
Number of skipped records | Number of records to be skipped continuously throughout all source files. See Selecting Input Records. | 0-N | |
Max number of records | Maximum number of records to be read continuously throughout all source files. See Selecting Input Records. | 0-N | |
Number of skipped records per source | Number of records to be skipped from each source file. See Selecting Input Records. | Same as in Metadata (default) | 0-N | |
Max number of records per source | Maximum number of records to be read from each source file. See Selecting Input Records. | 0-N | |
[1]
If you do not define any of these three attributes,
the default Selector class
(
|
For more information, see Java Interfaces for MultiLevelReader.
For detailed information about transformations, see Defining Transformations.
Details
MultiLevelReader reads information from flat files with a heterogeneous and complicated structure (local or remote which are delimited, fixed-length, or mixed). It can also read data from compressed flat files, input port, or dictionary.
Unlike FlatFileReader or the two deprecated readers (DelimitedDataReader and FixLenDataReader), MultiLevelReader can read data from flat files whose structure contains different structures including both delimited and fixed length data records even with different numbers of fields and different data types. It can separate different types of data records and send them through different connected output ports. Input files can also contain non-record data.
Component also uses the Data policy option. For more detailed information, see Data Policy.
Consider using a newer ComplexDataReader component if you find some limitation of this component.
Selector Properties
You also need to set some series of parameters that should be used (Selector properties).
They map individual types of data records to output ports.
All of the properties must have the form of a list of the
key=value
expressions separated by a semicolon.
The whole sequence is in curly brackets.
To specify these Selector properties,
you can use the dialog that opens after clicking the button in this attribute row.
By clicking the button in this dialog,
you can add new key-value pairs.
Then you only need to change both the default name and the default value.
Each value must be the number of the port through which data records should be sent out.
Each key is a series of characters from the beginning of the row
contained in the flat file that enable differentiate groups of records.
Java Interfaces for MultiLevelReader
Following are the methods of the MultiLevelSelector
interface:
int choose(CharBuffer data, DataRecord[] lastParsedRecords)
A method that peeks into
CharBuffer
and reads characters until it can either determine metadata of the record which it reads, and thus return an index to metadata pool specified ininit()
method, or runs out of data returningMultiLevelSelector.MORE_DATA
.
void finished()
Called at the end of selector processing after all input data records were processed.
void init(DataRecordMetadata[] metadata, Properties properties)
Initializes this selector.
int lookAheadCharacters()
Returns the number of characters needed to decide the (next) record type. Usually it can be any fixed number of characters, but dynamic lookahead size, depending on previous record type, is supported and encouraged whenever possible.
int nextRecordOffset()
Each call to
choose()
can instrument the parent to skip a certain number of characters before attempting to parse a record according to metadata returned inchoose()
method.
void postProcess(int metadataIndex, DataRecord[] records)
In this method, the selector can modify the parsed record before it is sent to a corresponding output port.
int recoverToNextRecord(CharBuffer data)
This method instruments the selector to find the offset of the next record which is possibly parsable.
void reset()
Resets this selector completely. This method is called once, before each run of the graph.
void resetRecord()
Resets the internal state of the selector (if any). This method is called each time a new choice needs to be made.
You can use Public CloverDX API in this component too.
Best Practices
We recommend users to explicitly specify Charset.
Compatibility
Version | Compatibility Notice |
---|---|
2.2 | MultilevelReader is available since 2.2. |