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
Name Description
config DatastoreServiceConfig
appId String
Returns
Type Description
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
Name Description
config DatastoreServiceConfig
appId String
namespace String
Returns
Type Description
AdminDatastoreService

getInstance(String appId)

public static AdminDatastoreService getInstance(String appId)

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

Parameter
Name Description
appId String
Returns
Type Description
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
Name Description
appId String
namespace String
Returns
Type Description
AdminDatastoreService

Methods

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

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

allocateIds(String kind, long num)

public Future<KeyRange> allocateIds(String kind, long num)
Parameters
Name Description
kind String
num long
Returns
Type Description
Future<KeyRange>

beginTransaction()

public Future<Transaction> beginTransaction()
Returns
Type Description
Future<Transaction>

beginTransaction(TransactionOptions options)

public Future<Transaction> beginTransaction(TransactionOptions options)
Parameter
Name Description
options TransactionOptions
Returns
Type Description
Future<Transaction>

compositeIndexForQuery(Query query)

public Index compositeIndexForQuery(Query query)
Parameter
Name Description
query Query
Returns
Type Description
Index

compositeIndexesForQuery(Query query)

public Set<Index> compositeIndexesForQuery(Query query)
Parameter
Name Description
query Query
Returns
Type Description
Set<Index>

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

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

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

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

delete(Key[] keys)

public Future<Void> delete(Key[] keys)
Parameter
Name Description
keys Key[]
Returns
Type Description
Future<Void>

delete(Iterable<Key> keys)

public Future<Void> delete(Iterable<Key> keys)
Parameter
Name Description
keys Iterable<Key>
Returns
Type Description
Future<Void>

get(@Nullable Transaction txn, Key key)

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

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

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

get(Key key)

public Future<Entity> get(Key key)
Parameter
Name Description
key Key
Returns
Type Description
Future<Entity>

get(Iterable<Key> keys)

public Future<Map<Key,Entity>> get(Iterable<Key> keys)
Parameter
Name Description
keys Iterable<Key>
Returns
Type Description
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
Type Description
Collection<Transaction>

getAppId()

public String getAppId()
Returns
Type Description
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
Type Description
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
Name Description
returnedIfNoTxn Transaction
Returns
Type Description
Transaction

getDatastoreAttributes()

public Future<DatastoreAttributes> getDatastoreAttributes()
Returns
Type Description
Future<DatastoreAttributes>

getIndexes()

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

getNamespace()

public String getNamespace()
Returns
Type Description
String

minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)

public Index minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)
Parameters
Name Description
query Query
indexes Collection<Index>
Returns
Type Description
Index

minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)

public Set<Index> minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)
Parameters
Name Description
query Query
indexes Collection<Index>
Returns
Type Description
Set<Index>

newEntityBuilder(String kind)

public AdminDatastoreService.EntityBuilder newEntityBuilder(String kind)
Parameter
Name Description
kind String
Returns
Type Description
AdminDatastoreService.EntityBuilder

newKeyBuilder(String kind)

public AdminDatastoreService.KeyBuilder newKeyBuilder(String kind)
Parameter
Name Description
kind String
Returns
Type Description
AdminDatastoreService.KeyBuilder

newQueryBuilder()

public AdminDatastoreService.QueryBuilder newQueryBuilder()
Returns
Type Description
AdminDatastoreService.QueryBuilder

newQueryBuilder(String kind)

public AdminDatastoreService.QueryBuilder newQueryBuilder(String kind)
Parameter
Name Description
kind String
Returns
Type Description
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
Name Description
query Query
Returns
Type Description
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
Name Description
txn Transaction
query Query
Returns
Type Description
PreparedQuery

put(@Nullable Transaction txn, Entity entity)

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

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

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

put(Entity entity)

public Future<Key> put(Entity entity)
Parameter
Name Description
entity Entity
Returns
Type Description
Future<Key>

put(Iterable<Entity> entities)

public Future<List<Key>> put(Iterable<Entity> entities)
Parameter
Name Description
entities Iterable<Entity>
Returns
Type Description
Future<List<Key>>