Class LoadEngine

java.lang.Object
com.googlecode.objectify.impl.LoadEngine

public class LoadEngine
extends Object
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
  • Constructor Summary

    Constructors
    Constructor
    Description
    LoadEngine​(ObjectifyImpl<?> ofy, Session session, com.google.appengine.api.datastore.AsyncDatastoreService ads, LoadArrangement loadArrangement)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Starts asychronous fetching of the batch.
    Result<Map<com.google.appengine.api.datastore.Key,​com.google.appengine.api.datastore.Entity>>
    fetch​(Set<com.google.appengine.api.datastore.Key> keys)
    Fetch the keys from the async datastore using the current transaction context
     
     
    <T> T
    load​(com.google.appengine.api.datastore.Entity ent, LoadContext ctx)
    Converts a datastore entity into a typed pojo object
    <T> Result<T>
    load​(Key<T> key)
    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.appengine.api.datastore.Entity ent)
    Stuffs an Entity into a place where values in the round can be obtained instead of going to the datastore.
    translate​(Result<Map<com.google.appengine.api.datastore.Key,​com.google.appengine.api.datastore.Entity>> raw)
    Asynchronously translate raw to processed; might produce successive load operations as refs are filled in

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • load

      public <T> Result<T> load(Key<T> key)
      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

      public <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.
      Parameters:
      rootEntity - is the entity key which holds this property (possibly through some level of embedded objects)
    • shouldLoad

      public boolean shouldLoad(LoadConditions loadConditions)
      Returns:
      true if the specified property should be loaded in this batch
    • stuff

      public void stuff(com.google.appengine.api.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.appengine.api.datastore.Key,​com.google.appengine.api.datastore.Entity>> raw)
      Asynchronously translate raw to processed; might produce successive load operations as refs are filled in
    • fetch

      public Result<Map<com.google.appengine.api.datastore.Key,​com.google.appengine.api.datastore.Entity>> fetch(Set<com.google.appengine.api.datastore.Key> keys)
      Fetch the keys from the async datastore using the current transaction context
    • load

      public <T> T load(com.google.appengine.api.datastore.Entity 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
    • getSession

      public Session getSession()
    • getLoadArrangement

      public LoadArrangement getLoadArrangement()