I don't know if the requirement are the same but here's something I came up
with that might be of use to you as well.

If I need to mark a group of entities as having some common trait (the trait
could be read or unread in your case) in response to an action the user has
taken upon a group of entieis (not an entity group but the number of
entities in a group with a common trait and the number can vary depending
upon your use case) I would create special 'trait' entities. For a trait of
'read' for instance each trait entity would have 2 longs representing the
range of entity ids of all the entities sharing the trait. When marking a
group of entities, lets say 5000 of them, as read I would create a trait
entity that has the 2 longs, the first long equaling the id of the 1st
entity in the group and the second long the id of the last entity of the
group. When determining if an entity is read I would check for a trait
record whose 2 longs encompassed the id of the entity in question. If it
existed I would use that to determine its read state and if no trait entity
existed that encompassed the entity in question I would use the actual
entity's read state field. A conflict exists when an entity is encompassed
by a trait entity and whose own read field contradicts the state indicated
by the trait. In those cases I check the actual entity's monotonic counter
field and if it is greater than the monotonic field value of the trait
entity then the actual entity's read field overrules the trait entity. A
simple model follows. Please note that I am using Objectify ORM:

trait:

class Trait implements Serializable {

long serialVersionUID = 1L;

@Id
Long id;                                 // autogenerated

String a;                                // common attribute such as read,
unread, etc and
                                            // can be used to query for
trait entities of a specific
                                            // attribute type such as read,
unread, yes, no, hot, cold,
                                            // etc.


long r1;                                // key id of 1st entity in the group
long r2;                                // key id of last entity in the
group

long m;                                 // monotonic value  set when created
and never modified thereafter

.
.
.
}

class Email implements Serializable {

long serialVersionUID = 1L;

@Id
Long id;

boolean read;

long m;                                 // monotonic value set when entity
is created and
                                            // only updated if the user
reads or unreads

.
.
.

}

Like I said, I don't know if this fits your use case but it worked in mine
and it is very light weight.

Jeff


On Mon, Jan 10, 2011 at 1:27 AM, nischalshetty <nischalshett...@gmail.com>wrote:

> My bad. I forgot to mention, there would be an option where I show just the
> 'unread' tweets to the user or just the 'read' tweets. When I show all
> tweets, your example would work perfectly fine. But what about the other two
> scenarios? Any pointers would help. I use GAE/J.
>
> -N
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to google-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>



-- 
*Jeff Schwartz*

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

Reply via email to