Package com.googlecode.objectify.impl
Class LoadEngine
java.lang.Object
com.googlecode.objectify.impl.LoadEngine
Represents one "batch" of loading. Get a number of Result<?> objects, then execute(). Some work is done
right away, some work is done on the first get(). There might be multiple rounds of execution to process
all the @Load groups, but that is invisible outside this class.
- Author:
- Jeff Schnitzer <[email protected]>
-
Constructor Summary
ConstructorsConstructorDescriptionLoadEngine
(ObjectifyImpl ofy, Session session, AsyncDatastoreReaderWriter datastore, LoadArrangement loadArrangement, com.google.common.collect.ImmutableSet<com.google.cloud.datastore.ReadOption> readOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Starts asychronous fetching of the batch.Fetch the keys from the async datastore using the current transaction context<T> T
load
(com.google.cloud.datastore.BaseEntity<com.google.cloud.datastore.Key> ent, LoadContext ctx) Converts a datastore entity into a typed pojo object<T> Result<T>
Gets the result, possibly from the session, putting it in the session if necessary.<T> Ref<T>
makeRef
(Key<?> rootEntity, LoadConditions loadConditions, Key<T> key) Create a Ref for the key, and maybe start a load operation depending on current load groups.boolean
shouldLoad
(LoadConditions loadConditions) void
stuff
(com.google.cloud.datastore.Entity ent) Stuffs an Entity into a place where values in the round can be obtained instead of going to the datastore.Asynchronously translate raw to processed; might produce successive load operations as refs are filled in
-
Constructor Details
-
LoadEngine
public LoadEngine(ObjectifyImpl ofy, Session session, AsyncDatastoreReaderWriter datastore, LoadArrangement loadArrangement, com.google.common.collect.ImmutableSet<com.google.cloud.datastore.ReadOption> readOptions)
-
-
Method Details
-
load
Gets the result, possibly from the session, putting it in the session if necessary. Also will recursively prepare the session with @Load parents as appropriate.- Throws:
NullPointerException
- if key is null
-
execute
public void execute()Starts asychronous fetching of the batch. -
makeRef
Create a Ref for the key, and maybe start a load operation depending on current load groups.- Parameters:
rootEntity
- is the entity key which holds this property (possibly through some level of embedded objects)
-
shouldLoad
- Returns:
- true if the specified property should be loaded in this batch
-
stuff
public void stuff(com.google.cloud.datastore.Entity ent) Stuffs an Entity into a place where values in the round can be obtained instead of going to the datastore. Called by non-hybrid queries to add results and eliminate batch fetching. -
translate
public Result<Map<Key<?>,Object>> translate(Result<Map<com.google.cloud.datastore.Key, com.google.cloud.datastore.Entity>> raw) Asynchronously translate raw to processed; might produce successive load operations as refs are filled in -
fetch
public Result<Map<com.google.cloud.datastore.Key,com.google.cloud.datastore.Entity>> fetch(Set<com.google.cloud.datastore.Key> keys) Fetch the keys from the async datastore using the current transaction context -
load
public <T> T load(com.google.cloud.datastore.BaseEntity<com.google.cloud.datastore.Key> ent, LoadContext ctx) Converts a datastore entity into a typed pojo object- Returns:
- an assembled pojo, or the Entity itself if the kind is not registered, or null if the input value was null
-