Step 2. Create Mapper and Reducer Functions

Last updated: 2021-03-19 15:15:22

    Creating Mapper Function

    Creating in console through template function

    1. Log in to the SCF console and select Function Service on the left sidebar.
    2. At the top of the Function Service page, select the Beijing region and click Create to enter the function creating page and configure the function as shown below:
      • Creation method: select Template.
      • Fuzzy search: enter "map_function", search, and select the "map_function" template.
        Click Learn More in the template to view relevant information in the Template Details pop-up window, which can be downloaded.
    3. Click Next. The function name is automatically generated by default and can be modified as needed. Follow the prompts to configure the execution role:
      • Execution Role: check Enable. Configure and use SCF template role is selected here as an example as shown below:
      • Configure and use SCF template role: select this option and the system will automatically create and select an SCF template execution role associated with full access permissions of COS.
      • Use the existing role: you need to select an existing role that contains the above permissions in the drop-down list.

        Note:

        During execution, the function will use the execution role to get a temporary key to manipulate relevant Tencent Cloud resources.

    4. Click to expand the Function Code tab, where you can browse the code information. If you want to modify the parameter values such as variables, you can modify and save them online.

    Configuring COS trigger

    1. In the Trigger Configurations section, select Custom and enter relevant information according to the displayed parameters as shown below:

      Main parameters are as follows:
      • Trigger Method: select COS trigger.
      • COS Bucket: select srcmr.
      • Event Type: select All Creation Events.
    2. Click Complete.

    Creating Reducer Function

    Creating in console through template function

    1. Log in to the SCF console and select Function Service on the left sidebar.
    2. At the top of the Function Service page, select the Beijing region and click Create to enter the function creating page and configure the function as shown below:
      • Creation method: select Template.
      • Fuzzy search: enter "reduce_function", search, and select the "reduce_function" template.
        Click Learn More in the template to view relevant information in the Template Details pop-up window, which can be downloaded.
    3. Click Next. The function name is automatically generated by default and can be modified as needed. Follow the prompts to configure the execution role:
      • Execution Role: check Enable. Configure and use SCF template role is selected here as an example as shown below:
      • Configure and use SCF template role: select this option and the system will automatically create and select an SCF template execution role associated with full access permissions of COS.
      • Use the existing role: you need to select an existing role that contains the above permissions in the drop-down list.
    4. Click to expand the Function Code tab, where you can browse the code information. If you want to modify the parameter values such as variables, you can modify and save them online.

    Configuring COS trigger

    1. In the Trigger Configurations section, select Custom and enter relevant information according to the displayed parameters as shown below:

      Main parameters include:
      • Trigger Method: select COS trigger.
      • COS Bucket: select middlestagebucket.
      • Event Type: select All Creation Events.
    2. Click Complete.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help