Delete spatiotemporal objects
Lindorm GanosBase supports three methods for deleting spatio-temporal objects: TTL-based expiration, deletion by spatio-temporal range, and deletion by object ID. Each method applies to different index configurations.
Choose a deletion method
| Method | Supported index types | Affects other indexes | Use when |
|---|---|---|---|
| TTL-based expiration | All index tables | Yes (set TTL per table) | Automatically purge data older than a fixed time threshold |
| Delete by spatio-temporal range | z2/xz2 and z3/xz3 only | Risk of inconsistency with attribute indexes | Only spatio-temporal index tables exist in the database |
| Delete by object ID | ID index table only | Does not delete data from other index tables | Only one ID index table exists in the database |
Back up your index table data before deleting.
Delete by TTL
Lindorm GanosBase uses the Time to Live (TTL) feature of ApsaraDB for HBase to automatically expire data. You can use HBase Shell to modify the TTL attribute of the spatio-temporal index table to delete expired data.
If multiple index tables exist, set TTL on each table separately. The TTL value is in seconds.
Example: Delete data older than 5 minutes (300 seconds) from a spatio-temporal index table xxx_z3 and an attribute index table xxx_attr:
Alter 'xxx_z3',{NAME=>'d',TTL=>300}
Alter 'xxx_attr',{NAME=>'d',TTL=>300}Delete by spatio-temporal range
This method applies only to z2/xz2 and z3/xz3 spatio-temporal index tables.
If the database contains an attribute index table, deleting by spatio-temporal range leaves the attribute index table unchanged. This causes inconsistency between the spatio-temporal index tables and the attribute index table. Only use this method when the database contains spatio-temporal index tables only.
Procedure:
Configure a filter to identify the objects to delete. Use the same filter syntax as for queries — the filter string must comply with Extended Common Query Language (ECQL) syntax.
Call
SimpleFeatureStore.removeFeatures()from GeoTools to delete matching objects.
/**
* Delete spatio-temporal objects that match the specified filter.
* @param schema the schema name
* @param filterString the ECQL filter string; if blank, all objects are deleted
*/
public void removeByFilter(String schema, String filterString) throws Exception {
SimpleFeatureStore fs = (SimpleFeatureStore) ds.getFeatureSource(schema);
// If filterString is blank, all spatio-temporal objects are deleted.
if (StringUtils.isEmpty(filterString)) {
fs.removeFeatures(Filter.INCLUDE);
return;
}
Filter filterToDelete = ECQL.toFilter(filterString);
fs.removeFeatures(filterToDelete);
}Delete by object ID
This method deletes data only from the index table associated with the specified ID. Data in other index tables is not affected.
Only use this method when the database contains a single ID index table. If multiple index tables exist, other indexes retain the data for the deleted object.
Call SimpleFeatureStore.removeFeatures() with an ID filter built using FilterFactory2:
public void removeById(String schema, String simpleFeatureId) throws Exception {
// Build an ID filter using FilterFactory2.
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
Filter filterToDelete = ff.id(ff.featureId(simpleFeatureId));
SimpleFeatureStore fs = (SimpleFeatureStore) ds.getFeatureSource(schema);
fs.removeFeatures(filterToDelete);
}