How Would I Retrieve An Embedded Entity With Repeated Properties Using Datastore Java Client
I created entities on datastore using the AppEngine SDK's python APIs and I'd like to retrieve them on Google Cloud Dataflow (Java). The entity's structure is something like this:
Solution 1:
Ok, got it. This is how I enabled it:
staticclassEmbeddedStringExtractorextendsDoFn<Entity, String> {
@OverridepublicvoidprocessElement(ProcessContext c) {
Map<String, Value> main_entity_map = DatastoreHelper.getPropertyMap(c.element());
List<Value> embedded_entity_values = entity.get("embedded_entity").getListValueList();
for (Valueembedded_entity_value: embedded_entity_values){
Entity embedded_entity = embedded_entity_value.getEntityValue();
Map<String, Value> embedded_map = DatastoreHelper.getPropertyMap(embedded_entity);
String embedded_name = DatastoreHelper.getString(embedded_map.get("name"));
}
// And then just c.output whatever you need.
}
}
Just needed to get used to the Java APIs.
Post a Comment for "How Would I Retrieve An Embedded Entity With Repeated Properties Using Datastore Java Client"