Hi,

Is it possible to get an index at the point an ordered property
changes in a query result? (this is more a theoretical question as I'm
pretty sure the answer is no). Something like:

   class Truck {
       String clr1;
       String clr2;
   }

   select from Truck where clr1='red' order by clr2;

app engine will start feeding me the records ordered by the indexed
attribute 'clr2':

   Foo.clr2 = 'blue'
   Foo.clr2 = 'blue'
   Foo.clr2 = 'blue'
   Foo.clr2 = 'silver'
   Foo.clr2 = 'white'
   Foo.clr2 = 'white'
   ...
   ...

since the results are indexed on clr2, is it possible to 'jump' to the
next index at which clr2 changes in the result set, given a previous
index? I don't think there is any concept of a numeric 'index' in a
result set, because the entire result set is read from the datastore
on demand (not generated in a massive collection etc). Something like
this would be almost ideal:

   // rough pseudocode:
   int index = 0;
   int indexNext = 0;
   String lastclr2 = 'white';
   while (indexNext != -1) {
       indexNext = query.jump(lastclr2);
       if (indexNext != -1) {
           println("You have " + (nextIndex - index) " instances of "
+ lastclr2 + "!");
           index = nextIndex;
           lastclr2 = query.getAttrAt('clr2', indexNext);
       }
   }

I'd like to see:

  You have 3 instances of blue!
  You have 1 instances of silver!
  You have 2 instances of white!

I'm trying to answer dynamic count questions, like:

  What's the count breakdown of Truck instances when the primary color
is red?:
        2 have a secondary color of white
        3 have a secondary color of blue
        1 have a secondary color of silver

The app engine solution to this scenario is to write out counters up-
front to optimize our reads (and I like this approach and am using it
in a few places in my app already).

In the case where I don't know all possible combinations of counters
needed, or the set of counters needed is so large that it would become
a bottleneck in the system, I'm not sure that there is an answer.

The above isn't perfect, even if it could work - for example, I'd
usually only be interested in knowing the top 10 most frequently
occurring color combinations. The above would really require me to
jump through the entire datastore, then do a final sorting after all
counts are tallied.

Any thoughts?

Thanks!

-- 
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