Updated on 2022-09-14 GMT+08:00

Configuring the Hcatalog Sample Project

Scenario

To run the HCatalog interface example codes of the Hive component of MRS, perform the following operations.

The following uses the development of an application for connecting the Hive service in HCatalog mode on Windows as an example.

Procedure

  1. Obtain the sample project folder hcatalog-example in the src\hive-examples directory where the sample code is decompressed. For details, see Obtaining Sample Projects from Huawei Mirrors.
  2. Import the example project to the IntelliJ IDEA development environment.

    1. On the IntelliJ IDEA menu bar, choose File > Open.... The Open File or Project window is displayed.
    2. In the displayed window, select the folder hcatalog-example, and click OK. On Windows, the path cannot contain any space.

  3. Set the IntelliJ IDEA text file coding format to prevent garbled characters.

    1. On the IntelliJ IDEA menu bar, choose File > Settings. The Settings window is displayed.
    2. Choose Editor > File Encodings from the navigation tree. In the Project Encoding area and Global Encoding area, set the value to UTF-8, click Apply, and click OK, as shown in Figure 1.
      Figure 1 Setting the IntelliJ IDEA coding format

  4. Set the JDK of the project.

    1. On the IntelliJ IDEA menu bar, choose File > Settings.... The Settings window is displayed.
    2. Choose Build, Execution, Deployment > Compiler > Java Compiler, select 8 from the Project bytecode version drop-down list box. Change the value of Target bytecode version to 8 for hive-jdbc-example.

    3. Click Apply and OK.
    4. On the IntelliJ IDEA menu bar, choose File > Project Structure.... The Project Structure window is displayed.
    5. Select SDKs, click the plus sign (+), and select JDK.

    6. On the Select Home Directory for JDK page that is displayed, select the JDK directory and click OK.
    7. After selecting the JDK, click Apply.
    8. Select Project, select the JDK added in SDKs from the Project SDK drop-down list box, and select 8 - Lambdas, type annotations etc. from the Project language level drop-down list box.

    9. Click Apply.
    10. Choose Modules. On the Source page, change the value of Language level to 8 - Lambdas, type annotations etc.

    11. On the Dependencies page, change the value of Module SDK to the JDK added in SDKs.

    12. Click Apply and OK.

  5. Configure Maven.

    1. Add the configuration information such as the address of the open-source image repository to the setting.xml configuration file of the local Maven by referring to Configuring Huawei Open-Source Mirrors.
    2. On the IntelliJ IDEA page, select File > Settings > Build, Execution, Deployment > Build Tools > Maven, select Override next to User settings file, and change the value of User settings file to the directory where the settings.xml file is stored. Ensure that the directory is <Local Maven installation directory>\conf\settings.xml.
      Figure 2 Directory for storing the settings.xml file
    3. Click the drop-down list next to Maven home directory and select the Maven installation directory.
    4. Click Apply, and then click OK.