title: Get datastore entity inside dataflow pipeline step
body: <p>I'm trying to setup a dataflow pipeline that </p>
  
  <ol>
  <li>reads entities from datastore, </li>
  <li>and for each entity found, look up a different entity to extract a property,</li>
  <li>and use that property value to update the original entity.</li>
  </ol>
  
  <p>How can I look up a specific entity given a Read?  Or is there some better way of doing this?</p>
  
  <p>Here's what I have so far:</p>
  
  <pre class="lang-java prettyprint-override"><code>static class LookupOtherEntityFn extends DoFn&lt;Entity, Entity&gt; {
  
      private Entity LookupOtherEntityFn(Entity sourceEntity) {
          final Key someOtherEntityKey = sourceEntity.getPropertiesMap()
                  .get("otherEntityKey")
                  .getKeyValue();
          final DatastoreV1.Read read = DatastoreIO.v1()
                  .read(); // ...... (uses someOtherEntityKey in query)
  
          // **************************
          // How do I retrieve the entity given a Read?
          // **************************
  
      }
  
      @ProcessElement
      public void processElement(ProcessContext c) {
          c.output(createBackupEntity(c.element()));
      }
  
  }
  
  Pipeline p = Pipeline.create(options);
  
  p.apply(DatastoreIO.v1().read()...)
      .apply(ParDo.of(new LookupOtherEntityFn()))
       .apply(ParDo.of(new CreateUpdatedEntityFn())
       .apply(DatastoreIO.v1().write()...);
  
  p.run();
  </code></pre>