Write data of spatio-temporal objects
Updated at:
After you create an index table and a spatio-temporal object, call the data write API to write data to ApsaraDB for HBase.
Write data of a single SimpleFeature object
The SimpleFeatureWriter class in the GeoTools API writes a single SimpleFeature object to ApsaraDB for HBase. SimpleFeatureWriter supports transactions. 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) supports batch writes. Use the SimpleFeatureStore class in the GeoTools API to write multiple SimpleFeature objects at a time.
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.
Is this page helpful?