On this page

Combining Rowkeys

Updated on 2022-11-18 GMT+08:00

Scenario

You can combine rowkeys in a customized manner. Combining rowkeys using BulkLoad is to process some column names in a customized manner using some rules and combine them to generate a new rowkey.

NOTE:

The column name consists of letters, digits, and underscores and cannot contain any special characters.

Configuration Method

Details about how to set configuration.xml to combine rowkeys are as follows:

For example, combine column SMS_ID, the second to fourth characters of column SMS_NAME, and the reverse of column SMS_SERAIL.

 <columns> 
                         <column index="1" type="int">SMS_ID</column> 
                         <column index="2" type="string">SMS_NAME</column> 
                         <column index="3" type="string">SMS_ADDRESS</column> 
                 </columns> 
                 <rowkey> 
                        SMS_ID+'_'+substring(SMS_NAME,1,4)+'_'+reverse(SMS_ADDRESS)
                 </rowkey>     
Table 1 Rowkey segment process functions

Function Prototype

Description

Example

format(data,"DataType")

Used to format string data.

For example, format(data,"0.000") is used to input data in "0.000" format.

converse(data,"yyyy-MM-dd","yyyyMMdd")

Used to convert the date format.

For example, converse(data,"yyyy-MM-dd","yyyyMMdd") is used change the date format from "yyyy-MM-dd" to "yyyyMMdd".

rand

Used to generate a random number. Only the int type is supported.

None

replace(data,"A","B")

Used to replace data.

replace(data,"A","B") is used to replace A with B.

reverse(data)

Used to reverse a character string.

For example, reverse(ABC) is used reverse "ABC" to "CBA".

substring(data,Length1,Length2), or substring(data,Length3)

Used to subtract a character string.

For example, substring(data,1,5), or substring(data,3) is used to subtract [1,5) or [3,data.length) from the data character string.

to_number("data")

Used to convert a character string into a numeric value. The Long type numeric value is supported.

For example, to_number("123") is used to convert "123" into 123. Note that "data" must be a numerical value.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback