Hi:

Following is my sketch for the Message and MessageIndex. Please advise
and if possible, sketch out the Java version of set intersection from
the presentation. Have not time to try anything yet; but the design is
very significant for proper data modeling. The JDO version of the
presentation uses query.setFilter("receivers == 'foo'") which i do not
see in the API.

public class MessageIndex { // create MessageIndex to the parent Message
  private Key parent; private String keyKind; private long id;

  @PrimaryKey
  @Persistent(ValueStrategy = IdGeneratorStrategy.IDENTITY)
  private KeyFactory.createKey(parent, keyKind, id) key;

  @Persistent private List<String> receivers;

  // constructor to create MessageIndex linked to Message
  public MessageIndex(Key parent, String keyKind, long id) {
    this.parent = parent; this.keyKind = keyKind; this id = id;
}

public class Message {
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Key key

  @Persistent private String sender;
  @Persistent private String body;

  // a user create a message to a list of receivers
  public static Message createMessage(String userId, String body,
List<String> receivers) {
    tx.begin()
    this.body = body;
    MessageIndex index = new MessageIndex(key, key,getKind(), key.getId
());
    index.setReceivers(receivers);
    tx.commit();
  }

  // query to get all messages sent to a user "foo"
  public List<Message> getMessagesSentToUserId(String userId) {
    List<Message> results = null
      tx.begin();
        Query q = pm.newQuery(MessageIndex.class);
        q.addFilter("receivers", Query.FilterOperator.EQUAL, "foo");
        q.setKeyOnly();
        // query the Message for all messages filtered by parent of
MessageIndex key
        Query query = pm.newQuery(Message.class);
        query.addFilter("key", Query.FilterOperator.EQUAL, "q.execute
().getParent()");
        results = (List<Message>) query.execute();
      tx.commit();
  }
}

Thanks
Duong BaTien
DBGROUPS and BudhNet

On Wed, 2010-01-13 at 16:26 -0800, Jason (Google) wrote:
> It's been awhile since I've seen this video, so I'll have to go back
> to re-watch it in order to answer your question completely, but I'd be
> interested in seeing what you've sketched out so far and happy to give
> you my feedback on it.
> 
> 
> - Jason
> 
> On Tue, Jan 12, 2010 at 3:52 PM, Duong BaTien <duong.bat...@gmail.com>
> wrote:
>         Hi Jason, the author Brett Slatkin and others:
>         
>         1) For the list property, the video shows simple example of
>         standard 1:n
>         Message Receivers in python and Java. It then demonstrates a
>         very
>         efficient technique of Message and MessageIndex with the query
>         of
>         MessageIndex in python (NO Java from then on). I look at both
>         the low
>         level datastore with Query.setKeyOnly() and the query "select
>         id from"
>         to get the results of List<Key>, then go through the loop to
>         get the
>         receivers. I may miss something, since the python code looks
>         so clean.
>         But once you are in any environment, it is very expensive to
>         switch.
>         This technique has major impact in data modeling.
>         
>         2) Again for the set intersection, the python code looks so
>         clean. I
>         roughly sketch what need to be done on the Java side with
>         either low
>         level of datastore or with JDO. It is still not elegant as the
>         shown
>         codes. The demos are also in python. Again, the technique of
>         merge join
>         will have very significant impact on data modeling that GAE
>         may surpass
>         other platforms.
>         
>         Haven't put enough time in it yet, I wonder if any one has
>         worked out
>         the demos in Java and suggested best practices in data
>         modeling for a
>         complex large application. The job Brett Slatkin sets out to
>         do has not
>         completed without the Java codes since GAE now supports Java.
>         
>         Thanks
>         Duong BaTien
>         DBGROUPS and BudhNet
>         
>         
>         
>         On Tue, 2010-01-12 at 14:13 -0800, Jason (Google) wrote:
>         > Can you be more specific about what you're trying to
>         accomplish so we
>         > don't have to search through the video to find what you're
>         looking
>         > for? Or, at least provide a timeline reference that we can
>         refer to in
>         > the video. :)
>         >
>         >
>         > Thanks,
>         > - Jason
>         >
>         > On Mon, Jan 11, 2010 at 7:29 AM, Duong BaTien
>         <duong.bat...@gmail.com>
>         > wrote:
>         >         Hi:
>         >
>         >         Is there any blog and/or note to apply list
>         properties and
>         >         merge-join in
>         >         python as in the following talk and demos
>         >
>         
> http://code.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html
>  using Java and JDO?
>         >
>         >         Thanks
>         >         Duong BaTien
>         >         DBGROUPS and BudhNet
>         >
>         >
>         >
>         >         --
>         >         You received this message because you are subscribed
>         to the
>         >         Google Groups "Google App Engine for Java" group.
>         >         To post to this group, send email to google-
>         appengine-
>         >         j...@googlegroups.com.
>         >         To unsubscribe from this group, send email to
>         google-
>         >         appengine-java+unsubscr...@googlegroups.com.
>         >         For more options, visit this group at
>         >         http://groups.google.com/group/google-appengine-
>         java?hl=en.
>         >
>         >
>         >
>         >
>         >
>         
>         > --
>         
>         > You received this message because you are subscribed to the
>         Google
>         > Groups "Google App Engine for Java" group.
>         > To post to this group, send email to google-appengine-
>         > j...@googlegroups.com.
>         > To unsubscribe from this group, send email to google-
>         appengine-java
>         > +unsubscr...@googlegroups.com.
>         > For more options, visit this group at
>         > http://groups.google.com/group/google-appengine-java?hl=en.
>         
>         
>         
>         --
>         You received this message because you are subscribed to the
>         Google Groups "Google App Engine for Java" group.
>         To post to this group, send email to google-appengine-
>         j...@googlegroups.com.
>         To unsubscribe from this group, send email to google-
>         appengine-java+unsubscr...@googlegroups.com.
>         For more options, visit this group at
>         http://groups.google.com/group/google-appengine-java?hl=en.
>         
>         
>         
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Google App Engine for Java" group.
> To post to this group, send email to google-appengine-
> j...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengine-java
> +unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to