Ganos is developed with multiple built-in spatial indexes. Users only need to input spatial data at the frontend, and then specify the index to be created. They do not need to worry about how HBase key-value pairs are designed and built.

Before you import data, you must define the schema of the index table.

Index types

Ganos supports four types of indexes to meet the requirements of different scenarios. You can choose to create all of the supported types of indexes or only some of them. In a scenario that only involves surrounding object queries, you only need to create Z2 indexes.

ID indexes

ID indexes are applicable to scenarios where feature IDs (FIDs) of spatial objects are used to query data. FIDs must be unique.

Z2/XZ2 indexes

Z2 and XZ2 indexes are suitable for spatial data queries, such as geofence queries and surrounding object queries. Z2 indexes are created on "Point" objects and XZ2 indexes are created on "Line" and "Plane" objects.

Z3/XZ3 indexes

Z3 and XZ3 indexes are suitable for spatial-temporal data queries, for example, historical trajectory queries within a specified spatial range or temporal range. Z3 indexes are created on "point" objects and XZ3 indexes are created on "line" and "plane" objects.

XYZ indexes

XYZ indexes are three-dimensional indexes including longitude, latitude, and elevation information. Currently, XYZ indexes are created on "Point" objects.

Attribute indexes

Attribute indexes are suitable for attribute queries.

Create an index

Follow these steps to create an index:

  1. Use SimpleFeatureType to define a spatio-temporal schema.
    1. Specify the name of the schema. You can consider it the name of an index table.
    2. Specify the content of the schema, which includes the definitions of attributes, geometries, and dates.
    3. You can also customize the following information:
      1. Specify the compression algorithm.
      2. Specify whether to use the tiny well-known binary (TWKB) format.
      3. Create an index on a specified column.
  2. Create geometries based on the defined spatio-temporal schema.

Note: You can reference the Write class in the sample code of the Quick start topic. The preceding settings are all wrapped in this class.

Example

As described in the preceding section, you can use different types of indexes in Ganos or use only a specific type of indexes. In a scenario that only involves surrounding object queries, you only need to create Z2 indexes. We recommend that you use all types of indexes to improve the overall performance of data queries. However, this consumes storage space. You can also choose index types based on the actual scenario to save storage space. Ganos is developed with built-in Hints. Hints are used to specify indexes when you define a SimpleFeatureType. The syntax is as follows:

//sft specifies a SimpleFeatureType instance.
sft.getUserData().put("geomesa.indices.enabled", "{index_name}:{col1}:{col2}:...,{index_name}:{col}");
			
  • Assign one of the following constants to index_name: id, attr, z2, z3, xz2, xz3, and xyz.
  • col specifies the columns defined in SimpleFeatureType.
  • You can create one or more indexes, and separate them with commas (,).
  • If you want to add multiple columns to an index, separate the index name and column names with colons (:).

In the following example, two types of indexes are created: z3 and attr. A z3 index is created on the start and dtg columns, and another z3 index is created on the end and dtg columns. An attr index is created on the name and dtg columns.

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