Package com.google.cloud.datastore
Class BaseDatastoreBatchWriter
java.lang.Object
com.google.cloud.datastore.BaseDatastoreBatchWriter
- All Implemented Interfaces:
DatastoreBatchWriter,DatastoreWriter
Base class for DatastoreBatchWriter.
-
Method Summary
Modifier and TypeMethodDescriptionfinal Entityadd(FullEntity<?> entity) Datastore add operation: inserts the provided entity.add(FullEntity<?>... entities) Datastore add operation: inserts the provided entities.final voidaddWithDeferredIdAllocation(FullEntity<?>... entities) Datastore add operation.protected voidfinal voidA datastore delete operation.protected abstract Datastoreprotected StringgetName()booleanisActive()Returnstrueif still active (write operations were not sent to the Datastore).protected DatastoreExceptionnewInvalidRequest(String msg, Object... params) final Entityput(FullEntity<?> entity) A Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it otherwise.put(FullEntity<?>... entities) A Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it otherwise.final voidputWithDeferredIdAllocation(FullEntity<?>... entities) Datastore put operation.protected Map<Key,FullEntity<Key>> toAdd()protected List<FullEntity<IncompleteKey>>toDelete()protected Map<Key,FullEntity<Key>> toPut()protected Map<Key,FullEntity<Key>> toUpdate()final voidA Datastore update operation.protected void
-
Method Details
-
addWithDeferredIdAllocation
Description copied from interface:DatastoreBatchWriterDatastore add operation. This method will also allocate id for any entity with an incomplete key. As opposed toDatastoreBatchWriter.add(FullEntity)andDatastoreBatchWriter.add(FullEntity...), this method will defer any necessary id allocation to submit time.- Specified by:
addWithDeferredIdAllocationin interfaceDatastoreBatchWriter
-
add
Description copied from interface:DatastoreBatchWriterDatastore add operation: inserts the provided entity. This method will automatically allocate an id if necessary. Ifentityhas a complete key and was already marked for deletion in this writer, the operation will be changed toDatastoreBatchWriter.put(com.google.cloud.datastore.FullEntity<?>).- Specified by:
addin interfaceDatastoreBatchWriter- Specified by:
addin interfaceDatastoreWriter- Parameters:
entity- the entity to add- Returns:
- an
Entitywith the same properties and a key that is either newly allocated or the same one if key is already complete
-
add
Description copied from interface:DatastoreBatchWriterDatastore add operation: inserts the provided entities. This method will automatically allocate id for any entity with an incomplete key. For entities with complete keys that were marked for deletion in this writer the operation will be changed toDatastoreBatchWriter.put(com.google.cloud.datastore.FullEntity<?>).- Specified by:
addin interfaceDatastoreBatchWriter- Specified by:
addin interfaceDatastoreWriter- Returns:
- a list of
Entityordered by input with the same properties and a key that is either newly allocated or the same one if was already complete - See Also:
-
update
Description copied from interface:DatastoreBatchWriterA Datastore update operation. The operation will fail if an entity with the same key does not already exist. This operation will be converted toDatastoreBatchWriter.put(com.google.cloud.datastore.FullEntity<?>)operation for entities that were already added or put in this writer.- Specified by:
updatein interfaceDatastoreBatchWriter- Specified by:
updatein interfaceDatastoreWriter
-
put
Description copied from interface:DatastoreBatchWriterA Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it otherwise. This method will automatically allocate an id if necessary. This operation will also remove from this writer any prior writes for the same entity.- Specified by:
putin interfaceDatastoreBatchWriter- Specified by:
putin interfaceDatastoreWriter- Parameters:
entity- the entity to put- Returns:
- an
Entitywith the same properties and a key that is either newly allocated or the same one if key is already complete
-
putWithDeferredIdAllocation
Description copied from interface:DatastoreBatchWriterDatastore put operation. This method will also allocate id for any entity with an incomplete key. As opposed toDatastoreBatchWriter.put(FullEntity)andDatastoreBatchWriter.put(FullEntity...), this method will defer any necessary id allocation to submit time.- Specified by:
putWithDeferredIdAllocationin interfaceDatastoreBatchWriter
-
put
Description copied from interface:DatastoreBatchWriterA Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it otherwise. This method will automatically allocate id for any entity with an incomplete key. This operation will also remove from this writer any prior writes for the same entities.- Specified by:
putin interfaceDatastoreBatchWriter- Specified by:
putin interfaceDatastoreWriter- Returns:
- a list of updated or inserted
Entity, ordered by input. Returned keys are either newly allocated or the same one if was already complete.
-
delete
Description copied from interface:DatastoreBatchWriterA datastore delete operation. It is OK to request the deletion of a non-existing key. This operation will also remove from this batch any prior writes for entities with the same keys.- Specified by:
deletein interfaceDatastoreBatchWriter- Specified by:
deletein interfaceDatastoreWriter
-
isActive
public boolean isActive()Description copied from interface:DatastoreBatchWriterReturnstrueif still active (write operations were not sent to the Datastore).- Specified by:
isActivein interfaceDatastoreBatchWriter
-
getName
-
toAdd
-
toAddAutoId
-
toUpdate
-
toPut
-
toDelete
-
deactivate
protected void deactivate() -
validateActive
protected void validateActive() -
newInvalidRequest
-
toMutationPbList
-
getDatastore
-