After you create an index table and a spatio-temporal object, you can call the writer operation to write data to your ApsaraDB for HBase database.

Write data of a single SimpleFeature object

You can use the SimpleFeatureWriter class in the GeoTools API to write data of a single SimpleFeature object to your ApsaraDB for HBase database. SimpleFeatureWriter supports transactions. You can call the getFeatureWriterAppend method of DataStore to obtain the attributes to be written and the locations of the attribute values.

SimpleFeatureType sft = ....;
SimpleFeatureWriter writer=(SimpleFeatureWriter)ds.getFeatureWriterAppend(sft.getTypeName(), Transaction.AUTO_COMMIT);
SimpleFeature toWrite=writer.next();
toWrite.setAttributes(feature.getAttributes());
toWrite.getUserData().putAll(feature.getUserData());
writer.write();
writer.close();

Write data of multiple SimpleFeature objects at a time

ApsaraDB for HBase Ganos (HBase Ganos) allows you to write multiple SimpleFeature objects at a time. You can use the SimpleFeatureStore class in the GeoTools API to write multiple SimpleFeature objects.

List<SimpleFeature> features=...
SimpleFeatureStore featureStore = (SimpleFeatureStore) ds.getFeatureSource(sft.getTypeName());
List<FeatureId> featureIds = featureStore.addFeatures(new ListFeatureCollection(sft,features));

For sample code, see Quick start.