9.11.2 Mapping definition
(1) Format
<MappingDefinition ioType="{INPUT|OUTPUT}">
<source>
<streams>
<stream name="stream-name"
querygroup="query-group-name">
<column name="column-name"
type="{INT|SHORT|BYTE|LONG|BIG_DECIMAL|FLOAT|DOUBLE|STRING |DATE|TIME|TIMESTAMP}"/>
</stream>
</streams>
</source>
<target>
<streams>
<stream name="stream-name"
querygroup="query-group-name">
<column name="column-name"
type="{INT|SHORT|BYTE|LONG|BIG_DECIMAL|FLOAT|DOUBLE|STRING |DATE|TIME|TIMESTAMP}"/>
</stream>
</streams>
<records>
<record name="record-name">
<field name="field-name" type="{INT|SHORT|BYTE|LONG|BIG_DECIMAL|FLOAT|DOUBLE|STRING |DATE|TIME|TIMESTAMP}"/>
</records>
</target>
<intermediate>
<mappings source="source-name"
querygroup="query-group-name"
target="target-name">
<map source="source-path-expression"
function="built-in-function-name" argument1="argument-1"
argument2="argument-2" target="target-path-expression"/>
</mappings>
</intermediate>
</MappingDefinition> |
(2) Details of definition
- MappingDefinition tag (all definition information)
- Defines all mapping conversion definition information. You specify this definition only once.
- ioType="{INPUT|OUTPUT}"
- Specifies the type of standard adaptors being specified in this definition. This attribute cannot be omitted.
- The permitted values are as follows:
- INPUT
Specifies that mapping is being defined for input adaptors.
- OUTPUT
Specifies that mapping is being defined for output adaptors.
- source tag (mapping source definition)
- Defines information about the streams at the mapping source.
- As shown in the table below, the information to be specified in this tag depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the source tag |
---|
INPUT | Mapping between record and stream | Specify an empty-element tag |
Mapping between records |
OUTPUT | Mapping between record and stream | Specify the streams tag |
Mapping between records | Specify an empty-element tag |
- target tag (mapping target definition)
- Defines information about the streams or records at the mapping target.
- As shown in the table below, the information to be specified in this tag depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the target tag |
---|
INPUT | Mapping between record and stream | Specify the streams tag |
Mapping between records | Specify the records tag |
OUTPUT | Mapping between record and stream | Specify an empty-element tag |
Mapping between records | Specify the records tag |
- streams tag (stream group definition)
- Defines under the source or target tag information about the group of streams at the mapping source or target, respectively, when mapping is being performed between record and stream.
- If you specify this definition, you specify it only once.
- stream tag (stream definition)
- Defines information about a stream at the mapping source or target.
- You can specify a maximum of 1,024 stream definitions. This definition is mandatory.
- name="stream-name"
- Specifies the name of a stream, as 1 to 100 single-byte alphanumeric characters and the underscore (_). This name must begin with a single-byte alphabetic character. The specified pair of a stream name and a query group name must be unique within the streams tag. This attribute cannot be omitted.
- querygroup="query-group-name"
- Specifies the name of the query group, as 1 to 64 single-byte alphanumeric characters and the underscore (_). This name must begin with a single-byte alphabetic character. The specified pair of a stream name and a query group name must be unique within the streams tag. This attribute cannot be omitted.
- column tag (column definition)
- Defines information about the columns in the stream at the mapping source or target.
- You can specify a maximum of 3,000 column definitions. This definition is mandatory.
- name="column-name"
- Specifies the name of a column, as 1 to 100 single-byte alphanumeric characters and the underscore (_). This name must begin with a single-byte alphabetic character. The specified column name must be unique within the column definition in the streams tag. This attribute cannot be omitted.
- type="{INT|SHORT|BYTE|LONG|BIG_DECIMAL|FLOAT|DOUBLE|STRING|DATE|TIME|TIMESTAMP}"
- Specifies the column's data type, which must correspond to a CQL data type.
- For details about the values for this attribute and the corresponding CQL data types, see 9.11.1(6) Values of the type attribute and the corresponding Java and CQL data types.
- records tag (record group definition)
- Defines under the target tag information about a group of records at the mapping target when mapping is performed between records.
- If you specify this definition, you specify it only once.
- record tag (record definition)
- Defines information about a record at the mapping target. You can specify a maximum of 1,024 record definitions. This definition is mandatory.
- name="record-name"
- Specifies the name of a record, as 1 to 100 single-byte alphanumeric characters and the underscore (_). This record name must begin with a single-byte alphabetic character.
- You can specify this attribute only once for a record. This attribute cannot be omitted. This record name must be unique within the corresponding standard adaptor.
- field tag (field definition)
- Defines information about the fields in the record at the mapping target. You can specify a maximum of 3,000 field definitions. This definition is mandatory.
- name="field-name"
- Specifies the name of a field, as 1 to 100 single-byte alphanumeric characters and the underscore (_). This field name must begin with a single-byte alphabetic character. You can specify this attribute only once for a field. This attribute cannot be omitted. This field name must be unique within the corresponding record.
- type="{INT|SHORT|BYTE|LONG|BIG_DECIMAL|FLOAT|DOUBLE|STRING|DATE|TIME|TIMESTAMP}"
- Specifies the field's data type, which must corresponds to a Java data type. This attribute cannot be omitted.
- For details about the values for this attribute and the corresponding CQL data types, see 9.11.1(6) Values of the type attribute and the corresponding Java and CQL data types.
- intermediate tag (intermediate mapping definition)
- Defines information about mapping from the source to the target.
- You specify this definition only once.
- mappings tag (mapping group definition)
- Defines mapping information.
- You can specify a maximum of 1,024 mapping definitions. This definition is mandatory.
- source="source-name"
- Specifies a source stream name or record name, as 1 to 100 single-byte alphanumeric characters and the underscore (_). This attribute cannot be omitted.
- As shown in the table below, the information to be specified in this attribute depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the source attribute |
---|
INPUT | Mapping between record and stream | Specify the record name at the mapping source |
Mapping between records |
OUTPUT | Mapping between record and stream | Specify the stream name that was specified in the name attribute in the stream tag |
Mapping between records | Specify the record name at the mapping source |
- querygroup="query-group-name"
- Specifies, as 1 to 64 single-byte alphanumeric characters and the underscore (_), the name of the query group to which the source stream or target stream belongs when mapping is performed between record and stream. This name must begin with a single-byte alphabetic character. The specified pair of a query group name and a source name or the specified pair of a query group name and a target name must be unique within the mappings tag.
- As shown in the table below, the information to be specified in this attribute depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the querygroup attribute |
---|
INPUT | Mapping between record and stream | Specify the query group name in the streams tag under the target tag |
Mapping between records | Do not specify |
OUTPUT | Mapping between record and stream | Specify the query group name in the streams tag under the source tag |
Mapping between records | Do not specify |
- target="target-name"
- Specifies the stream name or record name at the mapping target, as 1 to 100 characters. The specified target name must be unique within the mappings tag. This attribute cannot be omitted.
- As shown in the table below, the information to be specified in this attribute depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the target attribute |
---|
INPUT | Mapping between record and stream | Specify the stream name that was specified in the name attribute in the stream tag |
Mapping between records | Specify the record name that was specified in the name attribute in the record tag |
OUTPUT | Mapping between record and stream | Specify the record name at the mapping target |
Mapping between records | Specify the record name that was specified in the name attribute in the record tag |
- map tag (mapping information definition)
- Defines mapping information. The order of the instances of this tag must match the order of the stream or record components for the mapping target. You can specify a maximum of 3,000 mapping information definitions. This definition is mandatory.
- source="source-path-expression"
- Specifies as a source path expression the name of a source field, as 1 to 1,024 characters. This attribute cannot be omitted.
- As shown in the table below, the information to be specified in this attribute depends on the value of the ioType attribute in the MappingDefinition tag and what is being mapped.
Value of ioType attribute | What is being mapped | Information to be specified in the source attribute |
---|
INPUT | Mapping between record and stream | Specify the name of a field that belongs to the record whose name was specified in the source attribute in the mappings tag |
Mapping between records |
OUTPUT | Mapping between record and stream | Specify the name of a field that belongs to the stream whose name was specified in the source attribute in the mappings tag |
Mapping between records | Specify the name of a field that belongs to the record whose name was specified in the source attribute in the mappings tag |
- function="built-in-function-name"
- When you perform mapping between records, you can use built-in functions in the function attribute in the map tag to acquire character strings or a time from a common record at the source and apply them to a common record at the target.
- You specify in this attribute the name of the built-in function to be used to acquire a character string or time. Note that this attribute cannot be specified for mapping between record and stream (mapping to a common record in the case of input streams, or mapping from a common record in the case of output streams).
- The values permitted for this attribute are as follows:
- regexsubstring
Specify this value to acquire a partial character string in regular expression from the input character string. The return value is a character string of the String type.
When you specify regexsubstring, specify arguments in the argument1 and argument2 attributes.
- getTupleTime
This value is permitted only for output adaptors. Specify it to acquire the time in a tuple that is output from the output stream by the output adaptor. The return value is a time of the TIMESTAMP data type (in milliseconds).
When you specify getTupleTime, there is no need to specify the argument1 or argument2 attribute.
Note that getTupleTime cannot be specified when the value of the ioType attribute in the MappingDefinition tag is INPUT.
- subTime
Specify this value to obtain the time difference between the time values in two fields. The smaller time value is subtracted from the larger time value to obtain the difference. The return value is a time of the LONG type (in milliseconds).
When you specify subTime, specify arguments in the argument1 and argument2 attributes.
- argument1="argument-1"
- Specifies the first argument of the built-in function specified in the function attribute.
- When regexsubstring is specified in the function attribute
Specifies the name of the String-type field that stores the input character string, expressed as 1 to 100 single-byte alphanumeric characters and the underscore (_).
- When subTime is specified in the function attribute
Specifies the name of the TIMESTAMP-type field that stores the time, expressed as 1 to 100 single-byte alphanumeric characters and the underscore (_).
- argument2="argument-2"
- Specifies the second argument of the built-in function specified in the function attribute.
- When regexsubstring is specified in the function attribute
Specify in the format shown below the condition for extracting a partial character string, as 2 to 1,024 characters:
[regular-expression] "("[regular-expression]")"[regular-expression] |
Because the java.util.regex.Pattern class is used to analyze the regular expression, you must specify a regular expression within the range supported by the java.util.regex.Pattern class.
If the input character string in the field specified in argument-1 matches the character string in the regular expression specified in argument-2, the character string that corresponds to the part enclosed in ( and ) is returned (String type). If they do not match, the null character is returned.
- When subTime is specified in the function attribute
Specify the name of the TIMESTAMP-type field that stores the time, expressed as 1 to 100 single-byte alphanumeric characters and the underscore (_).
- target="target-path-expression"
- Specifies as a target path expression the name of a target field, expressed as 1 to 100 single-byte alphanumeric characters and the underscore (_). This specified field name must be unique within the mappings tag. This attribute cannot be omitted.
- The value of this attribute depends on the value of the ioType attribute in the MappingDefinition tag, as described below.
- When INPUT is specified in the ioType attribute
Specify the name of a field that belongs to the named target stream or record.
- When OUTPUT is specified in the ioType attribute
Specify the name of a field that belongs to the named target record.
(3) Example
- Mapping between record and stream for input records
The following shows a coding example for performing mapping between record and stream by an input adaptor.
<?xml version="1.0" encoding="UTF-8"?>
<root:AdaptorCompositionDefinition
<!-- Omitted -->
xmlns:map="http://www.hitachi.co.jp/soft/xml/sdp/adaptor/definition/callback/MappingDefinition">
<!-- Omitted -->
<!-- CB definition for editing -->
<cb:DataEditCBDefinition class="jp.co.Hitachi.soft.sdp.adaptor.callback.dataedit.mapping.InputMappingCBImpl" name="editor1">
<!-- Mapping definition -->
<map:MappingDefinition ioType="INPUT">
<map:source/>
<map:target>
<map:streams>
<map:stream name="S1" querygroup="QG1">
<map:column name="id" type="INT"/>
<map:column name="time" type="STRING"/>
<map:column name="name" type="STRING"/>
<map:column name="val" type="INT"/>
</map:stream>
</map:streams>
</map:target>
<map:intermediate>
<map:mappings source="R1" querygroup="QG1" target="S1">
<map:map source="F1" target="id"/>
<map:map source="F2" target="time"/>
<map:map source="F3" target="name"/>
<map:map source="F5" target="val"/>
</map:mappings>
</map:intermediate>
</map:MappingDefinition>
</cb:DataEditCBDefinition> |
- Mapping between records for input records
The following shows a coding example for performing mapping between records by an input adaptor. This example uses built-in functions in the function attribute to acquire a character string in a regular expression and the difference between time values.
<?xml version="1.0" encoding="UTF-8"?>
<root:AdaptorCompositionDefinition
<!-- Omitted -->
xmlns:map="http://www.hitachi.co.jp/soft/xml/sdp/adaptor/definition/callback/MappingDefinition">
<!-- Omitted -->
<!-- CB definition for editing -->
<cb:DataEditCBDefinition class="jp.co.Hitachi.soft.sdp.adaptor.callback.dataedit.mapping.InputMappingCBImpl" name="editor1">
<!-- Mapping definition -->
<map:MappingDefinition ioType="INPUT">
<map:source/>
<map:target>
<map:records>
<map:record name="RECORD1">
<map:field name="id" type="INT"/>
<map:field name="F21" type="STRING"/>
<map:field name="F22" type="LONG"/>
</map:record>
</map:records>
</map:target>
<map:intermediate>
<map:mappings source="RECORD0" target="RECORD1">
<map:map source="F1" target="id"/>
<map:map function="regexsubstring" argument1="F11"
argument2=".*Data=([0-9]+).*" target="F21"/>
<map:map function="subTime" argument1="F12" argument2=F13" target="F22"/>
</map:mappings>
</map:intermediate>
</map:MappingDefinition>
</cb:DataEditCBDefinition> |
- Mapping between record and stream for output records
The following shows a coding example for performing mapping between record and stream by an output adaptor.
<?xml version="1.0" encoding="UTF-8"?>
<root:AdaptorCompositionDefinition
<!-- Omitted -->
xmlns:map="http://www.hitachi.co.jp/soft/xml/sdp/adaptor/definition/callback/MappingDefinition">
<!-- Omitted -->
<!-- CB definition for editing -->
<cb:DataEditCBDefinition class="jp.co.Hitachi.soft.sdp.adaptor.callback.dataedit.mapping.InputMappingCBImpl" name="editor1">
<!-- Mapping definition -->
<map:MappingDefinition ioType="INPUT">
<map:source>
<map:streams>
<map:stream name="S1" querygroup="QG1">
<map:column name="id" type="INT"/>
<map:column name="time" type="TIMESTAMP"/>
<map:column name="name" type="STRING"/>
</map:stream>
</map:streams>
</map:source>
<map:target/>
<map:intermediate>
<map:mappings source="S1" querygroup="QG1" target="RECORD1">
<map:map source="id" target="F21"/>
<map:map source="time" target="F22"/>
<map:map source="name" target="F23"/>
</map:mappings>
</map:intermediate>
</map:MappingDefinition>
</cb:DataEditCBDefinition> |
- Mapping between records for output records
The following shows a coding example for performing mapping between records by an output adaptor. This example uses built-in functions in the function attribute to acquire a character string in a regular expression, as well as times in a tuple and the difference between the times.
<?xml version="1.0" encoding="UTF-8"?>
<root:AdaptorCompositionDefinition
<!-- Omitted -->
xmlns:map="http://www.hitachi.co.jp/soft/xml/sdp/adaptor/definition/callback/MappingDefinition">
<!-- Omitted -->
<!-- CB definition for editing -->
<cb:DataEditCBDefinition class="jp.co.Hitachi.soft.sdp.adaptor.callback.dataedit.mapping.InputMappingCBImpl" name="editor1">
<!-- Mapping definition -->
<map:MappingDefinition ioType="INPUT">
<map:source/>
<map:target>
<map:records>
<map:record name="RECORD1">
<map:field name="F21" type="STRING"/>
<map:field name="F22" type="TIMESTAMP"/>
<map:field name="F23" type="LONG"/>
</map:record>
</map:records>
</map:target>
<map:intermediate>
<map:mappings source="RECORD0" target="RECORD1">
<map:map function="regexsubstring" argument1="F11"
argument2=".*Data=([0-9]+).*" target="F21"/>
<map:map function="getTupleTime" target="F22"/>
<map:map function="subTime" argument1="F12" argument2=F13" target="F23"/>
</map:mappings>
</map:intermediate>
</map:MappingDefinition>
</cb:DataEditCBDefinition> |