On Jan 19, 11:08 am, "[email protected]" <[email protected]> wrote: > On Jan 4, 9:08 pm, Andy <[email protected]> wrote: > > > I'm new to sharding and am a little stuck on how to implement the toy > > problem below. Basically I have a many-to-one relationship between a > > Company and Employees, and I want shards which are partitioned > > according to company name. My naive approach is to replicate and > > rename the tables. > > > (1) Is there a better approach? > > (2) How do I switch context effectively to use the correct > > my request handlers? > > I think you do not need multiple model definitions. Reading through > this > threadhttp://www.google.com/url?sa=D&q=http://groups.google.com/group/googl... > i think the solution to your problem could be to use named sharding > counters. Take a look at the > articlehttp://code.google.com/intl/de-DE/appengine/articles/sharding_counter... > especially the GeneralCounterShard code. Basically you can shard any > instance of your model separately. > > If you are familiar with Django i will post about how to use sharding > counters on App Engine using native Django > onhttp://allbuttonspressed.blogspot.com/ > today. Maybe this can help you too. > > Bye, > Thomas
I forgot to say that the name for your GeneralCounterShard can be the company name. Bye, Thomas > ----------http://allbuttonspressed.blogspot.com/http://bitbucket.org/wkornewald/djangoappengine/http://bitbucket.org/wkornewald/django-nonrel/wiki/Home > > > Thanks! > > Andy > > > # (from my models.py) > > # # I start with these two models, then shard by company > > # class Company(db.Model): > > # name=db.StringProperty(required=True) > > # > > # class Employee(db.Model): > > # lastname=db.StringProperty(required=True) > > # company=db.ReferenceProperty(Company, > > collection_name='employees') > > > # Company 'Foo' and it's employees > > class Company_Foo(db.Model): > > name=db.StringProperty(required=True) > > > class Employee_Foo(db.Model): > > lastname=db.StringProperty(required=True) > > company=db.ReferenceProperty(Company_Foo, > > collection_name='employees') > > > # company 'Bar' and it's employees > > class Company_Bar(db.Model): > > name=db.StringProperty(required=True) > > > class Employee_Bar(db.Model): > > lastname=db.StringProperty(required=True) > > company=db.ReferenceProperty(Company_Bar, > > collection_name='employees') > > > # (from my handlers.py) > > # other imports here > > from models import * # potentially hundreds of model shards!? > > > def MyHandler(webpp.RequestHandler): > > def post(self): > > company_id=get_from_request(self) > > if company_id == 'Foo': > > my_emp=Employee_Foo.gql(...) > > else: > > my_emp=Employee_Bar.gql(...) > >
-- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
