public final class DatastoreServiceConfig
extends java.lang.Object
DatastoreServiceConfig
object
is to statically import DatastoreServiceConfig.Builder
.* and invoke a static creation
method followed by an instance mutator (if needed):
import static com.google.appengine.api.datastore.DatastoreServiceConfig.Builder.*; import com.google.appengine.api.datastore.ReadPolicy.Consistency; ... // eventually consistent reads DatastoreServiceConfig config = withReadPolicy(new ReadPolicy(Consistency.EVENTUAL)); // eventually consistent reads with a 5 second deadline DatastoreServiceConfig config = withReadPolicy(new ReadPolicy(Consistency.EVENTUAL)).deadline(5.0);
Modifier and Type | Class and Description |
---|---|
static class |
DatastoreServiceConfig.Builder
Contains static creation methods for
DatastoreServiceConfig . |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATASTORE_EMPTY_LIST_SUPPORT
This is the name of a system property that determines how the Java SDK writes/reads empty lists
to/from Datastore.
|
Modifier and Type | Method and Description |
---|---|
DatastoreServiceConfig |
deadline(double deadline)
Sets the deadline, in seconds, for all rpcs initiated by the
DatastoreService with which this config is associated. |
java.lang.Double |
getDeadline() |
static boolean |
getEmptyListSupport()
Returns whether or not empty list support is enabled; see
DATASTORE_EMPTY_LIST_SUPPORT . |
ImplicitTransactionManagementPolicy |
getImplicitTransactionManagementPolicy() |
java.lang.Integer |
getMaxEntityGroupsPerRpc() |
ReadPolicy |
getReadPolicy() |
DatastoreServiceConfig |
implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy p)
Sets the implicit transaction management policy.
|
DatastoreServiceConfig |
maxEntityGroupsPerRpc(int maxEntityGroupsPerRpc)
Sets the maximum number of entity groups that can be represented in a
single rpc.
|
DatastoreServiceConfig |
readPolicy(ReadPolicy readPolicy)
Sets the read policy.
|
public static final java.lang.String DATASTORE_EMPTY_LIST_SUPPORT
Historically Datastore has not had the ability to represent an empty list in its persistent store. Different SDKs have made different decisions on what to write to Datastore when a client attempts to insert an empty list to the persistent store. The Java SDK has historically written both empty lists and null values as null values to the persistent store.
With the release of this flag, Datastore can now represent empty lists within its persistent store. This means that Datastore SDKs can distinguish between empty lists and null values. This property controls whether this SDK writes an empty list as empty list or null to the persistent store.
A note on queries: Null values can be indexed by Datastore which means they can interact with queries. For example queries that find all entities with null values or order by a property will include null values. Empty lists are not indexable by Datastore and so cannot appear in similar queries.
Thus, if this flag was unset (the old behavior) and an empty list was stored into the persistent store, it could appear in query results because it was really stored as a null value.
If this flag is set (the new behavior) and an empty list is stored into the persistent store, it will not appear it query results because it is stored as an empty list.
When this variable is set to anything other than "true" the system provides legacy behavior.
When this variable is set to "true":
Collection.isEmpty()
) are written as empty list to Datastore
Collection
.
It is strongly recommended that this property be set to true in order to provide compatibility
with other Datastore SDK's, as well as future versions of Datastore.
To set the flag:
System.setProperty(DatastoreServiceConfig.DATASTORE_EMPTY_LIST_SUPPORT,
Boolean.TRUE.toString());
public static boolean getEmptyListSupport()
DATASTORE_EMPTY_LIST_SUPPORT
.public DatastoreServiceConfig implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy p)
p
- the implicit transaction management policy to set.this
(for chaining)public DatastoreServiceConfig readPolicy(ReadPolicy readPolicy)
readPolicy
- the read policy to set.this
(for chaining)public DatastoreServiceConfig deadline(double deadline)
DatastoreService
with which this config is associated.deadline
- the deadline to set.this
(for chaining)java.lang.IllegalArgumentException
- if deadline is not positivepublic DatastoreServiceConfig maxEntityGroupsPerRpc(int maxEntityGroupsPerRpc)
maxEntityGroupsPerRpc
- the maximum number of entity groups per rpcthis
(for chaining)java.lang.IllegalArgumentException
- if maxEntityGroupsPerRpc is not greater
than zeropublic ImplicitTransactionManagementPolicy getImplicitTransactionManagementPolicy()
ImplicitTransactionManagementPolicy
to use.public ReadPolicy getReadPolicy()
ReadPolicy
to use.public java.lang.Integer getMaxEntityGroupsPerRpc()
public java.lang.Double getDeadline()
null
.