Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] Upsert feature in Geomesa?

There actually is one other thing that may be useful - the way geomesa is implemented, you can sometimes do an appending write, which will overwrite any existing feature. There are a few caveats though:

* You have to know the feature ID for the existing feature, and use the same one
* You can't read the existing feature and modify it, you have to overwrite the whole thing
* If any of your 'indexable' attributes change, you will end up with duplicate data. Indexable attributes are generally the default geometry, date, and any attribute indexed fields
* I've tested this with our Accumulo implementation - other back-ends may or may not work the same (though I'd expect HBase at least to work fine)
* It's implementation dependent, so the behavior may change out from under you unexpectedly (though I would say for the foreseeable future that's not very likely)

Doing updates this way is also much faster, as it's a single write instead of a read/delete/write.

Thanks,

Emilio

On 01/22/2018 11:45 AM, Emilio Lahr-Vivaz wrote:
modifyFeatures may be useful, but it won't add new features, and it doesn't report back if something changed. In terms of effect, it's equivalent to the SQL 'update table foo set colA = bar where colB = baz'.

As you say, I don't believe the geotools API supports upsert. The equivalent would be something like:

val updater = ds.getFeatureWriter(typeName, filter, Transaction.AUTO_COMMIT)
if (updater.hasNext) {
   // modify update feature
} else {
   val appender = ds.getFeatureWriterAppend(typeName, Transaction.AUTO_COMMIT)
   // add to appender
}

If doing batches, you could keep a reference to the appender instead of creating one each time.

Any implementation we added would essentially be a convenience wrapper around that. I don't believe there are any major optimizations we could make, so I'm not sure it's worthwhile to do something outside the geotools API unless a lot of people want it.

Thanks,

Emilio


On 01/22/2018 10:58 AM, Jim Hughes wrote:
Hi Jason,

In terms of implementation, upserts would end up being a delete followed by an insert.  I think the GeoTools DataStore API does have a modifyFeatures call which may provide some of the convenience you are looking for here.

Cheers,

Jim

On 01/18/2018 02:59 PM, Jason Koh wrote:
Hi,

I wonder if Geomesa is going to have the upsert feature. I want to update the value of a certain query if the query pattern exists, else insert. Geotools seems not supporting this though. I understand it doesn't have to be prioritized, but just curious.

Thanks!


With regards,
Jason Koh


_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geomesa-users




_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geomesa-users



_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geomesa-users


Back to the top