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 Entity
add
(FullEntity<?> entity) Datastore add operation: inserts the provided entity.add
(FullEntity<?>... entities) Datastore add operation: inserts the provided entities.final void
addWithDeferredIdAllocation
(FullEntity<?>... entities) Datastore add operation.protected void
final void
A datastore delete operation.protected abstract Datastore
protected String
getName()
boolean
isActive()
Returnstrue
if still active (write operations were not sent to the Datastore).protected DatastoreException
newInvalidRequest
(String msg, Object... params) final Entity
put
(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 void
putWithDeferredIdAllocation
(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 void
A Datastore update operation.protected void
-
Method Details
-
addWithDeferredIdAllocation
Description copied from interface:DatastoreBatchWriter
Datastore 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:
addWithDeferredIdAllocation
in interfaceDatastoreBatchWriter
-
add
Description copied from interface:DatastoreBatchWriter
Datastore add operation: inserts the provided entity. This method will automatically allocate an id if necessary. Ifentity
has 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:
add
in interfaceDatastoreBatchWriter
- Specified by:
add
in interfaceDatastoreWriter
- Parameters:
entity
- the entity to add- Returns:
- an
Entity
with 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:DatastoreBatchWriter
Datastore 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:
add
in interfaceDatastoreBatchWriter
- Specified by:
add
in interfaceDatastoreWriter
- Returns:
- a list of
Entity
ordered 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:DatastoreBatchWriter
A 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:
update
in interfaceDatastoreBatchWriter
- Specified by:
update
in interfaceDatastoreWriter
-
put
Description copied from interface:DatastoreBatchWriter
A 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:
put
in interfaceDatastoreBatchWriter
- Specified by:
put
in interfaceDatastoreWriter
- Parameters:
entity
- the entity to put- Returns:
- an
Entity
with 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:DatastoreBatchWriter
Datastore 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:
putWithDeferredIdAllocation
in interfaceDatastoreBatchWriter
-
put
Description copied from interface:DatastoreBatchWriter
A 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:
put
in interfaceDatastoreBatchWriter
- Specified by:
put
in 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:DatastoreBatchWriter
A 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:
delete
in interfaceDatastoreBatchWriter
- Specified by:
delete
in interfaceDatastoreWriter
-
isActive
public boolean isActive()Description copied from interface:DatastoreBatchWriter
Returnstrue
if still active (write operations were not sent to the Datastore).- Specified by:
isActive
in interfaceDatastoreBatchWriter
-
getName
-
toAdd
-
toAddAutoId
-
toUpdate
-
toPut
-
toDelete
-
deactivate
protected void deactivate() -
validateActive
protected void validateActive() -
newInvalidRequest
-
toMutationPbList
-
getDatastore
-