Overview

更新时间:
复制 MD 格式

This topic describes how to develop a Java program by using MaxCompute Studio and describes related directories.

Procedure

  1. Create a MaxCompute Java module.

  2. Develop a Java program based on one of the following development paths:

  3. Package the Java program, upload the JAR package, and register a function.

Module directory

MaxCompute Studio automatically creates a module directory when you create a MaxCompute Java module. The directory contains three subdirectories:

  • examples: Sample code for unit testing. Reference this code when writing test scripts.

  • src/main/java: Source code for Java program development.

  • warehouse: Schemas and data for MaxCompute project tables and resources.


MyfirstProject C:\Users\Administrator\IdeaProjects\M
  .idea
  MyFristModule
    examples
    src
      main
        java
        resources
      test
    target
    MyFristModule.iml
    pom.xml
  scripts
  target
  warehouse
    example_project
      __resources__
      __tables__
        ads_log
        kmeans_in
        kmeans_out
        pagerank_in
        pagerank_out
        rs_out
        sssp_in
        sssp_out
        wc_in1
        wc_in2
        wc_out
  MyfirstProject.iml
  External Libraries
  Scratches and Consoles

Warehouse directory

The warehouse directory stores the schemas and data of tables and resources for MaxCompute projects. These tables and resources are used when executing user-defined functions (UDFs) or MapReduce tasks.

Directory structure

The warehouse directory has three levels:

  • Level 1: Named by project name.

  • Level 2: Contains two subdirectories — _resources_ and _tables_.

  • Level 3 (under _tables_): Named by table name. Each table directory contains a _schema_ file and one or more data files.

Schema file

In a schema file, configure the project name, table name, and the name and data type of each column. Separate each column name and data type with a colon (:).

If the table is partitioned, specify the partition key columns. In the example, wc_in1 is a non-partitioned table and wc_in2 is a partitioned table.

Data file

Data files use CSV format with UTF-8 encoding. The column delimiter is a comma (,) and the row delimiter is \n or \r\n.

Only three special characters are supported: commas (,), double quotation marks ("), and line breaks (\n or \r\n). Use the following escaping rules:

Value contains Write as Example
Comma (,) Enclose the value in double quotation marks 3,No"3,No"
Double quotation mark (") Escape each " with a pair of double quotation marks a"b"c"a""b""c"
NULL value \N
NULL value in a STRING column """\N"""