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

Procedure

Follow these steps to develop a Java program in MaxCompute Studio:
  1. Create a MaxCompute Java module.
  2. Develop a Java program based on one of the following topics:
  3. Package the Java program, upload the JAR package, and register a function.

Module directory

MaxCompute Studio automatically creates a module after you create a MaxCompute Java module. The module directory includes the following subdirectories:
  • examples: stores sample code. You can reference the sample code to develop a script for unit testing.
  • src/main/java: stores source code for Java program development.
  • warehouse: stores schemas and data of tables and resources for MaxCompute projects.
Module

warehouse directory

The warehouse directory stores the schemas and data of tables and resources for MaxCompute projects. These tables and resources are used to execute user-defined functions (UDFs) or MapReduce tasks. warehouse
  • The warehouse directory contains three levels of subdirectories. Level-1 subdirectories are named by project name. Level-2 subdirectories include _resources_ and _tables_. Each level-3 subdirectory under _tables_ is named by a table name and contains the _schema_ and data files.
  • In a _schema_ file, configure the project name, table name, and names and data types of columns. Separate each pair of column name and data type with a colon (:). If a partitioned table is used, you must specify partition key columns. In the preceding figure, wc_in1 is a non-partitioned table, and wc_in2 is a partitioned table.
  • In a data file, table data is stored in the CSV format based on the following rules:
    • In special characters, only commas (,), double quotation marks ("), and line breaks (\n or \r\n) are supported.
    • A comma (,) is used as a column delimiter. \n or \r\n is used as a row delimiter.
    • If a value in a column contains special characters, enclose the value in a pair of double quotation marks ("). For example, write 3,No as "3,No".
    • If a value in a column contains double quotation marks ("), use a pair of double quotation marks (") to escape each double quotation mark ("). For example, write a"b"c as "a""b""c".
    • \N indicates a NULL value. For a column of the STRING data type, write \N as """\N""".
    • Characters in the file are encoded in UTF-8.