This guide walks through writing and querying automatic identification system (AIS) trajectory data with Lindorm Ganos using a sample Java application.
Prerequisites
Before you begin, make sure you have:
-
Lindorm Ganos activated
-
Java and Maven installed
-
The
zk_addressendpoint for your LindormTable instance
Step 1: Download and build the sample package
Download the lindorm-ganos-sample package, then extract it.
From the lindorm-sample directory, run:
mvn install -Dmaven.test.skip=true -s ../settings.xml
A successful build produces lindorm-sample-1.0.0.jar in the target directory.
Step 2: Write data
All operations use sample_template.json to pass the operation type and connection parameters to the JAR.
To write data using a single thread, set operation to WRITER in sample_template.json:
{
"operation": "WRITER",
"zk_address": "<your_zk_address>",
"catalog": "example",
"schema": "ship"
}
| Parameter | Description |
|---|---|
zk_address |
The endpoint used by the ApsaraDB for HBase API for Java to connect to LindormTable. |
catalog |
The catalog (namespace) to write data into. |
schema |
The schema name. The default schema ship creates four spatiotemporal index tables with indexes on the id, z2, z3, and attr columns. To use a custom index table instead, see Create an index table. |
Run the sample:
java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json
Write data in parallel
To write data across multiple threads, set operation to PWRITER. Each thread generates a random set of AIS points within a specified range and writes them to the index table.
{
"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"
}
Specify parameters in write_template.json. A reference write_template.json is included in the sample package.
Run the sample:
java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json
Step 3: Query data
Run a fixed query
To run attribute, spatial, and spatiotemporal queries with default parameters, set operation to READER:
{
"operation": "READER",
"zk_address": "<your_zk_address>",
"catalog": "example",
"schema": "ship"
}
To filter by a bounding box, add a filter_string parameter:
{
"operation": "READER",
"filter_string": "bbox(geom, 20, 20, 40, 40)",
"zk_address": "<your_zk_address>",
"catalog": "example",
"schema": "ship"
}
bbox(geom, 20, 20, 40, 40) restricts results to points within the bounding box defined by coordinates (20, 20) and (40, 40).
Run the sample:
java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json
Run a custom query
To define a custom spatial, spatiotemporal, or attribute query with parameters from a JSON file, set operation to 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"
}
Specify query conditions in query_template.json. A reference query_template.json is included in the sample package.
Run the sample:
java -jar lindorm-sample-1.0.0.jar path_to_sample/sample_template.json
What's next
-
Create an index table — define a custom spatiotemporal index table instead of using the defaults