In development I have an empty datastore.
Online I have a datastore with millions of entities.
In the development datastore (locally) I put one new entity (generating a new key).
Then I export the entity and put it in the online datastore (with the key generated locally). What is the risk that the key generated locally to have already been assigned to an entity in the online datastore?
Or would it be simpler to avoid collision by creating the keys locally like this:
for (int i = 0; i < data.size(); i++) {
Key k = KeyFactory.createKey(kind, new Date() + i);
// continue to creating and inserting entities...
}
Thanks.
From https://developers.google.com/appengine/docs/java/datastore/entities:
You must either generate all of the numeric keys manually (and in such a way that they will never collide) or use
allocateIds(). There is specifically no guarantee that anything you generate manually will not collide with an existing key, unless you use that function. The generated key ids are not like an auto increment field in a relational db which increment by one each time.