private Result < Map < com . google . cloud . datastore . Key , Entity > > fetchPending ( ) { // We don't need to fetch anything that has been stuffed final Map < com . google . cloud . datastore . Key , Entity > combined = new HashMap <> ( ) ; Set < com . google . cloud . datastore . Key > fetch = new HashSet <> ( ) ; for ( com . google . cloud . datastore . Key key : pending ) { Entity ent = stuffed . get ( key ) ; if ( ent == null ) fetch . add ( key ) ; else combined . put ( key , ent ) ; } if ( fetch . isEmpty ( ) ) { return new ResultNow <> ( combined ) ; } else { final Result < Map < com . google . cloud . datastore . Key , Entity > > fetched = loadEngine . fetch ( fetch ) ; return ( ) -> { combined . putAll ( fetched . now ( ) ) ; return combined ; } ; } }
Possibly pulls some values from the stuffed collection