ApsaraDB for HBase Ganos (HBase Ganos) has multiple built-in spatial indexes. You need only to insert -temporal data at the frontend and specify the index that you want to create. You do not need to design or build key-value pairs for your ApsaraDB for HBase tables. Before you insert data into an index table, define the schema of the index table.

HBase Ganos supports four types of indexes to meet the requirements in different 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 indexes

ID indexes are suitable for scenarios in which IDs of spatial objects are used to query data. The ID of a spatial object is referred to as FID. Each FID must be unique.

Z2 and XZ2 indexes

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

Z3 and XZ3 indexes

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

XYZ indexes

XYZ indexes are three-dimensional indexes. The dimensions are longitude, latitude, and elevation information. XYZ indexes are used to query only point objects.

Attribute indexes

Attribute indexes are used to query other attributes.

Create indexes

Perform the following steps to create an index:

  1. Use SimpleFeatureType to define a spatio-temporal schema.
    1. Specify the name of the schema. A schema refers to an index table.
    2. Specify the content of the schema. The content specifies the columns for attribute data, geometry data, and date data.
    3. You can also customize the following configurations:

      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 spatio-temporal objects based on the defined spatial or spatio-temporal schema.

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 the overall performance of data queries. However, this increases storage usage. If you want to reduce the storage usage of indexes, create only specific types of indexes as needed. HBase Ganos provides built-in hints. You can use hints to specify indexes when you define SimpleFeatureType. You can use the following syntax:

//sft specifies a SimpleFeatureType instance.
sft.getUserData().put("geomesa.indices.enabled", "{index_name}:{col1}:{col2}:...,{index_name}:{col}");
            
Note
  • Valid values of index_name: id, attr, z2, z3, xz2, xz3, and xyz.
  • col specifies the columns that are specified in SimpleFeatureType.
  • You can create one or more indexes. Separate indexes with commas (,).
  • If you want to add multiple columns to an index, separate the index and column names with colons (:).
In the following example, two Z3 indexes and one attribute index are created. One Z3 index is created on the start and dtg columns, and the other Z3 index is created on the end and dtg columns. The attribute index is created on the name and dtg columns.
sft.getUserData().put("geomesa.indices.enabled", "z3:start:dtg,z3:end:dtg,attr:name:dtg");