Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()
      Starts asychronous fetching of the batch.
      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
      <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> 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.cloud.datastore.Entity ent)
      Stuffs an Entity into a place where values in the round can be obtained instead of going to the datastore.
      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
    • Method Detail

      • 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.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