Create an index table

Updated at:

HBase Ganos provides multiple built-in spatial indexes. You only need to insert spatio-temporal data and specify the index to create, without designing or building key-value pairs for HBase tables. Before you insert data, define the schema of the index table.

HBase Ganos supports four types of indexes for different query scenarios. You can create different types of indexes that are supported by HBase Ganos or create only a specific type of indexes. For example, if your applications query only surrounding objects, you need only to create Z2 indexes.

ID index

ID indexes are used to query data by the ID of a spatial object, referred to as FID. Each FID must be unique.

Z2/XZ2 indexes

Z2 and XZ2 indexes are used for spatial data queries, such as geo-fence queries and surrounding object queries. Z2 indexes apply to point objects, and XZ2 indexes apply to line and polygon objects.

Z3/XZ3 indexes

Z3 and XZ3 indexes are used for spatio-temporal data queries, such as historical trajectory queries within a specified spatial and temporal range. Z3 indexes apply to point objects, and XZ3 indexes apply to line and polygon objects.

XYZ index

XYZ indexes are three-dimensional indexes based on longitude, latitude, and elevation. XYZ indexes apply to point objects only.

Attribute index

Attribute indexes are used to query non-spatial attributes.

Create indexes

Perform the following steps to create an index:

  1. Define the spatio-temporal data type, which is SimpleFeatureType.

    1. Specify a schema name, which serves as an alias for the index table.

    2. Define the schema content, which includes columns for attributes, spatial objects (Geometry), and time.

    3. Configure other custom settings, including:

      a. Specify the compression algorithm.

      b. Specify whether to use the tiny well-known binary (TWKB) format.

      c. Create an index for a column.

  2. Create objects based on the defined SimpleFeatureType.

Examples

You can use different types of indexes that are supported by HBase Ganos or use only a specific type of index, as described in the preceding section. If your applications query only surrounding objects, you need only to create Z2 indexes. We recommend that you create all types of indexes to improve overall query performance, though this increases storage usage. To reduce storage usage, create only the index types you need. HBase Ganos provides built-in hints to specify indexes when you define SimpleFeatureType. Use the following syntax:

// sft is an instance of SimpleFeatureType.
sft.getUserData().put("geomesa.indices.enabled", "{index_name}:{col1}:{col2}:...,{index_name}:{col}");
            
Note
  • index_name must be one of the following constants: id, attr, z2, z3, xz2, xz3, or xyz.

  • col is a column defined in the SimpleFeatureType.

  • You can create multiple indexes and separate them with a ,.

  • You can add multiple columns to the same index, separating the index and each column with a :.

The following example creates three indexes: a z3 index on start and dtg, another z3 index on end and dtg, and an attr index on name and dtg.

sft.getUserData().put("geomesa.indices.enabled", "z3:start:dtg,z3:end:dtg,attr:name:dtg");