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.
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.
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
.
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
|
getInstance(String appId, String namespace)
public static AdminDatastoreService getInstance(String appId, String namespace)
Returns an AdminUtils instance for the given appId
and namespace
.
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
|
allocateIds(String kind, long num)
public Future<KeyRange> allocateIds(String kind, long num)
beginTransaction()
public Future<Transaction> beginTransaction()
beginTransaction(TransactionOptions options)
public Future<Transaction> beginTransaction(TransactionOptions options)
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
|
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[]
|
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>
|
delete(Key[] keys)
public Future<Void> delete(Key[] keys)
Parameter |
Name |
Description |
keys |
Key[]
|
delete(Iterable<Key> keys)
public Future<Void> delete(Iterable<Key> keys)
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
|
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>
|
get(Key key)
public Future<Entity> get(Key key)
Parameter |
Name |
Description |
key |
Key
|
get(Iterable<Key> keys)
public Future<Map<Key,Entity>> get(Iterable<Key> keys)
getActiveTransactions()
public Collection<Transaction> getActiveTransactions()
Returns all Transactions started by this thread upon which no attempt to commit or
rollback has been made.
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.
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.
getDatastoreAttributes()
public Future<DatastoreAttributes> getDatastoreAttributes()
getIndexes()
public Future<Map<Index,Index.IndexState>> getIndexes()
getNamespace()
public String getNamespace()
Returns |
Type |
Description |
String |
|
minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)
public Index minimumCompositeIndexForQuery(Query query, Collection<Index> indexes)
Returns |
Type |
Description |
Index |
|
minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)
public Set<Index> minimumCompositeIndexesForQuery(Query query, Collection<Index> indexes)
newEntityBuilder(String kind)
public AdminDatastoreService.EntityBuilder newEntityBuilder(String kind)
Parameter |
Name |
Description |
kind |
String
|
newKeyBuilder(String kind)
public AdminDatastoreService.KeyBuilder newKeyBuilder(String kind)
Parameter |
Name |
Description |
kind |
String
|
newQueryBuilder()
public AdminDatastoreService.QueryBuilder newQueryBuilder()
newQueryBuilder(String kind)
public AdminDatastoreService.QueryBuilder newQueryBuilder(String kind)
Parameter |
Name |
Description |
kind |
String
|
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
|
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.
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
|
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>
|
put(Entity entity)
public Future<Key> put(Entity entity)
Parameter |
Name |
Description |
entity |
Entity
|
put(Iterable<Entity> entities)
public Future<List<Key>> put(Iterable<Entity> entities)