Create an index table

Updated at:

HBase Ganos API uses index tables to store and query data. You can call the createSchema (SimpleFeatureType) method of the DataStore class to create an index. SimpleFeatureType specifies the schema of a SimpleFeature object in HBase Ganos. A SimpleFeatureType object consists of a set of common attributes. HBase Ganos supports all standard types of GeoTools attributes and extends some attribute types. You can use the SimpleFeatureTypes class provided by GeoMesa to create a SimpleFeatureTypes instance in HBase Ganos.

1. Create a SimpleFeatureType object.

The ApsaraDB for HBase Ganos (HBase Ganos) API uses index tables to store and query data. You can call the createSchema (SimpleFeatureType) method of the DataStore class to create an index. SimpleFeatureType specifies the schema of a SimpleFeature object in HBase Ganos. A SimpleFeatureType object consists of a set of common attributes. HBase Ganos supports all standard types of GeoTools attributes and extends some attribute types. You can use the SimpleFeatureTypes class provided by GeoMesa to create a SimpleFeatureTypes instance in HBase Ganos.

import org.locationtech.geomesa.utils.interop.SimpleFeatureTypes;

SimpleFeatureTypes.createType("sft_name", "dtg:Date,*geom:Point:srid=4326,name1:type1,name2,type2,...,nameN,typeN"); 

In the preceding example, a SimpleFeatureType object named sft_name is created. This SimpleFeatureType object contains the dtg column of the DATE type, the geom column that stores spatial data, and several attribute columns such as name1 and name2. The geometry specified in this example is a point, and the geometry uses the coordinate reference system 4326.

The following table describes the data types supported by HBase Ganos.

HBase Ganos data type

Java data type

Creating indexes supported

String

java.lang.String

Yes

Integer

java.lang.Integer

Yes

Double

java.lang.Double

Yes

Long

java.lang.Long

Yes

Float

java.lang.Float

Yes

Boolean

java.lang.Boolean

Yes

UUID

java.util.UUID

Yes

Date

java.util.Date

Yes

Timestamp

java.sql.Timestamp

Yes

Point

org.locationtech.jts.geom.Point

Yes

LineString

org.locationtech.jts.geom.LineString

Yes

Polygon

org.locationtech.jts.geom.Polygon

Yes

MultiPoint

org.locationtech.jts.geom.MultiPoint

Yes

MultiLineString

org.locationtech.jts.geom.MultiLineString

Yes

MultiPolygon

org.locationtech.jts.geom.MultiPolygon

Yes

GeometryCollection

org.locationtech.jts.geom.GeometryCollection

Yes

Geometry

org.locationtech.jts.geom.Geometry

Yes

List[A]

java.util.List

Yes

Map[A,B]

java.util.Map<a, b=""></a,>

No

Bytes

byte[]

No

Note:

  1. The geom attribute is required. You can create an index for only one spatial data column at a time. The indexed column is applied to primary spatio-temporal index systems that are Z2, Z3, XZ2, and XZ3.

  2. A column of the DATE data type can be used as a primary spatio-temporal index or a common attribute index.

2. Specify index parameters.

When you create an index, you can set static attributes for the SimpleFeatureType object to configure the required parameters.

  • Create indexes on the specified attribute column. HBase Ganos allows you to create indexes on common attribute columns. This can improve the query efficiency when the date and the geometry are not specified. For example, you can use the following code to create an index on the name column:

    SimpleFeatureType sft = ...
    sft.getDescriptor("name").getUserData().put("index", "true");
  • Specify a compression algorithm. To specify a compression algorithm, you can use the getUserData method of the SimpleFeatureType class or configure a compression algorithm in your CLI. The supported compression algorithms are snappy, lzo, gz, bzip2, lz4, and zstd.

SimpleFeatureType sft = ....;
sft.getUserData().put("geomesa.table.compression.enabled", "true");
sft.getUserData().put("geomesa.table.compression.type", "snappy");