All Products
Search
Document Center

Lindorm:Getting Started

Last Updated:Sep 02, 2022

After Lindorm Ganos is activated, you can call Ganos API operations to develop applications.

Procedure

  1. Download the sample code package lindorm-ganos-sample.

  2. Go to the lindorm-sample directory after the package is downloaded and decompressed, and execute the following statement:

    mvn install -Dmaven.test.skip=true -s ../settings.xml

    After the compilation is successful, lindorm-sample-1.0.0.jar is generated in the target directory.

  3. Understand the sample code. In the following example, automatic identification system (AIS) data is used to show how to write and query trajectory data.

    • Main: the entry point for the sample program.

      Specify operations and parameters in a JSON file. For more information, see the sample JSON file sample_template.json.

    • Writer: writes data to Lindorm Ganos. Two write modes are supported:

      • WRITER: uses a single thread to write data. Connect to Lindorm Ganos, define a schema, create a spatiotemporal index table, read the sample data, and then write the sample data to Lindorm Ganos.

      • PWRITER: uses multiple threads to write data. Connect to Lindorm Ganos, define a schema, and then create a spatiotemporal index table. Specify the number of threads. Each thread generates random N AIS points in the specified range and writes the AIS points to the table that is created. You must specify parameters in a JSON file. For more information, see the sample JSON file write_template.json.

    • Reader: the query interface that is used to query AIS data that is written by the writer. Two query modes are supported:

      • READER: In this query mode, you can run the queries that contain fixed parameters. The queries include attribute queries, spatial queries, and spatiotemporal queries.

      • UDFQUERY: In this query mode, you can specify parameters in a JSON file and specify query conditions to run a spatial query, spatiotemporal query, or attribute query. For more information, see the sample JSON file query_template.json.

  4. Use the sample code. In the following example, the zk_address parameter is set to the endpoint that is used for the ApsaraDB for HBase API for Java to connect to the wide table engine LindormTable.

    • Write data

      In the sample_template.json file, set the parameters that are required to write data.

      {
        "operation" : "WRITER",
        "zk_address" : $your_zk_address,
        "catalog" : "example",
        "schema" : "ship"
      }

      Execute the following sample statement to write data:

      java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json

      By default, four index tables (indexes on the id, z2, z3, and attr columns) whose schema is ship are created. If you want to create a specified index table, perform the steps that are described in Create an index table.

    • Query data

      Set query parameters in the sample_template.json file. Use the default query range in the sample code.

      {
        "operation" : "READER",
        "zk_address" : $your_zk_address,
        "catalog" : "example",
        "schema" : "ship"
      }

      You can also set the filter_string parameter to specify a query range.

      {
        "operation" : "READER",
        "filter_string" : "bbox(geom, 20, 20, 40, 40)"
        "zk_address" : $your_zk_address,
        "catalog" : "example",
        "schema" : "ship"
      }

      Execute the following sample statement to query data:

      java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json
    • Write data in parallel

      Use PWRITER.
      {
        "operation" : "PWRITER",
        "zk_address" : $your_zk_address,
        "catalog" : "example",
        "schema" : "ship",
        "write_template_file" : "src_root/src/main/java/com/aliyun/apsaradb/lindorm/ganos/sample/write_template.json"
      }
    • Run a custom query

      Use UDFQUERY.
      {
        "operation" : "UDFQUERY",
        "zk_address" : $your_zk_address,
        "catalog" : "example",
        "schema" : "ship",
        "query_template_file" : "src_root/src/main/java/com/aliyun/apsaradb/lindorm/ganos/sample/query_template.json"
      }