Class AdminDatastoreService (2.0.0)

public final class AdminDatastoreService implements AsyncDatastoreService

An AsyncDatastoreService implementation that is pinned to a specific appId and namesapce. This implementation ignores the "current" appId provided by ApiProxy.getCurrentEnvironment().getAppId() and the "current" namespace provided by NamespaceManager.get(). Note, this is particularly important in the following methods:

In addition this class provides ways to create Query, Entity and Key that are pinned to the same appId/namespace.

Note: users should not access this class directly.

Inheritance

java.lang.Object > AdminDatastoreService

Static Methods

getInstance(DatastoreServiceConfig config, String appId)

public static AdminDatastoreService getInstance(DatastoreServiceConfig config, String appId)

Returns an AdminUtils instance for the given appId and the "" (empty) namespace.

Parameters
NameDescription
configDatastoreServiceConfig
appIdString
Returns
TypeDescription
AdminDatastoreService

getInstance(DatastoreServiceConfig config, String appId, String namespace)

public static AdminDatastoreService getInstance(DatastoreServiceConfig config, String appId, String namespace)

Returns an AdminUtils instance for the given appId and namespace.

Parameters
NameDescription
configDatastoreServiceConfig
appIdString
namespaceString
Returns
TypeDescription
AdminDatastoreService

getInstance(String appId)

public static AdminDatastoreService getInstance(String appId)

Returns an AdminUtils instance for the given appId and the "" (empty) namespace.

Parameter
NameDescription
appIdString
Returns
TypeDescription
AdminDatastoreService

getInstance(String appId, String namespace)

public static AdminDatastoreService getInstance(String appId, String namespace)

Returns an AdminUtils instance for the given appId and namespace.

Parameters
NameDescription
appIdString
namespaceString
Returns
TypeDescription
AdminDatastoreService

Methods

allocateIds(@Nullable Key parent, String kind, long num)

public Future<KeyRange> allocateIds(@Nullable Key parent, String kind, long num)
Parameters
NameDescription
parent@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Key
kindString
numlong
Returns
TypeDescription
Future<KeyRange>

allocateIds(String kind, long num)

public Future<KeyRange> allocateIds(String kind, long num)
Parameters
NameDescription
kindString
numlong
Returns
TypeDescription
Future<KeyRange>

beginTransaction()

public Future<Transaction> beginTransaction()
Returns
TypeDescription
Future<Transaction>

beginTransaction(TransactionOptions options)

public Future<Transaction> beginTransaction(TransactionOptions options)
Parameter
NameDescription
optionsTransactionOptions
Returns
TypeDescription
Future<Transaction>

compositeIndexForQuery(Query query)

public Index compositeIndexForQuery(Query query)
Parameter
NameDescription
queryQuery
Returns
TypeDescription
Index

compositeIndexesForQuery(Query query)

public Set<Index> compositeIndexesForQuery(Query query)
Parameter
NameDescription
queryQuery
Returns
TypeDescription
Set<Index>

delete(@Nullable Transaction txn, Key[] keys)

public Future<Void> delete(@Nullable Transaction txn, Key[] keys)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
keysKey[]
Returns
TypeDescription
Future<Void>

delete(@Nullable Transaction txn, Iterable<Key> keys)

public Future<Void> delete(@Nullable Transaction txn, Iterable<Key> keys)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
keysIterable<Key>
Returns
TypeDescription
Future<Void>

delete(Key[] keys)

public Future<Void> delete(Key[] keys)
Parameter
NameDescription
keysKey[]
Returns
TypeDescription
Future<Void>

delete(Iterable<Key> keys)

public Future<Void> delete(Iterable<Key> keys)
Parameter
NameDescription
keysIterable<Key>
Returns
TypeDescription
Future<Void>

get(@Nullable Transaction txn, Key key)

public Future<Entity> get(@Nullable Transaction txn, Key key)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
keyKey
Returns
TypeDescription
Future<Entity>

get(@Nullable Transaction txn, Iterable<Key> keys)

public Future<Map<Key,Entity>> get(@Nullable Transaction txn, Iterable<Key> keys)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
keysIterable<Key>
Returns
TypeDescription
Future<Map<Key,Entity>>

get(Key key)

public Future<Entity> get(Key key)
Parameter
NameDescription
keyKey
Returns
TypeDescription
Future<Entity>

get(Iterable<Key> keys)

public Future<Map<Key,Entity>> get(Iterable<Key> keys)
Parameter
NameDescription
keysIterable<Key>
Returns
TypeDescription
Future<Map<Key,Entity>>

getActiveTransactions()

public Collection<Transaction> getActiveTransactions()

Returns all Transactions started by this thread upon which no attempt to commit or rollback has been made.

Returns
TypeDescription
Collection<Transaction>

getAppId()

public String getAppId()
Returns
TypeDescription
String

getCurrentTransaction()

public Transaction getCurrentTransaction()

Returns the current transaction for this thread, or throws an exception if there is no current transaction. The current transaction is defined as the result of the most recent, same-thread invocation of beginTransaction() that has not been committed or rolled back.

Use this method for when you expect there to be a current transaction and consider it an error if there isn't.

Returns
TypeDescription
Transaction

getCurrentTransaction(Transaction returnedIfNoTxn)

public Transaction getCurrentTransaction(Transaction returnedIfNoTxn)

Returns the current transaction for this thread, or returns the parameter if there is no current transaction. You can use null or provide your own object to represent null. See #getCurrentTransaction() for a definition of "current transaction."

Use this method when you're not sure if there is a current transaction.

Parameter
NameDescription
returnedIfNoTxnTransaction
Returns
TypeDescription
Transaction

getDatastoreAttributes()

public Future<DatastoreAttributes> getDatastoreAttributes()
Returns
TypeDescription
Future<DatastoreAttributes>

getIndexes()

public Future<Map<Index,Index.IndexState>> getIndexes()
Returns
TypeDescription
Future<Map<Index,IndexState>>

getNamespace()

public String getNamespace()
Returns
TypeDescription
String

minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)

public Index minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)
Parameters
NameDescription
queryQuery
indexesCollection<Index>
Returns
TypeDescription
Index

minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)

public Set<Index> minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)
Parameters
NameDescription
queryQuery
indexesCollection<Index>
Returns
TypeDescription
Set<Index>

newEntityBuilder(String kind)

public AdminDatastoreService.EntityBuilder newEntityBuilder(String kind)
Parameter
NameDescription
kindString
Returns
TypeDescription
AdminDatastoreService.EntityBuilder

newKeyBuilder(String kind)

public AdminDatastoreService.KeyBuilder newKeyBuilder(String kind)
Parameter
NameDescription
kindString
Returns
TypeDescription
AdminDatastoreService.KeyBuilder

newQueryBuilder()

public AdminDatastoreService.QueryBuilder newQueryBuilder()
Returns
TypeDescription
AdminDatastoreService.QueryBuilder

newQueryBuilder(String kind)

public AdminDatastoreService.QueryBuilder newQueryBuilder(String kind)
Parameter
NameDescription
kindString
Returns
TypeDescription
AdminDatastoreService.QueryBuilder

prepare(Query query)

public PreparedQuery prepare(Query query)

Prepares a query for execution.

This method returns a PreparedQuery which can be used to execute and retrieve results from the datastore for query.

This operation will not execute in a transaction even if there is a current transaction and the provided query is an ancestor query. This operation also ignores the ImplicitTransactionManagementPolicy. If you are preparing an ancestory query and you want it to execute in a transaction, use #prepare(Transaction, Query).

Parameter
NameDescription
queryQuery
Returns
TypeDescription
PreparedQuery

prepare(Transaction txn, Query query)

public PreparedQuery prepare(Transaction txn, Query query)

Exhibits the same behavior as #prepare(Query), but executes within the provided transaction. It is up to the caller to commit or rollback. Transaction can be null.

Parameters
NameDescription
txnTransaction
queryQuery
Returns
TypeDescription
PreparedQuery

put(@Nullable Transaction txn, Entity entity)

public Future<Key> put(@Nullable Transaction txn, Entity entity)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
entityEntity
Returns
TypeDescription
Future<Key>

put(@Nullable Transaction txn, Iterable<Entity> entities)

public Future<List<Key>> put(@Nullable Transaction txn, Iterable<Entity> entities)
Parameters
NameDescription
txn@org.checkerframework.checker.nullness.qual.Nullable com.google.appengine.api.datastore.Transaction
entitiesIterable<Entity>
Returns
TypeDescription
Future<List<Key>>

put(Entity entity)

public Future<Key> put(Entity entity)
Parameter
NameDescription
entityEntity
Returns
TypeDescription
Future<Key>

put(Iterable<Entity> entities)

public Future<List<Key>> put(Iterable<Entity> entities)
Parameter
NameDescription
entitiesIterable<Entity>
Returns
TypeDescription
Future<List<Key>>