google-code-export / twig-persist

Automatically exported from code.google.com/p/twig-persist
1 stars 1 forks source link

twig+the client side get the result is very slow #75

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,
I use Google Web Toolkit (GWT) in client side and using twig to store
the data in server side,  the version of twig is twig-persist-2.0-
beta4.jar.
In the client side, I have a function to get a list object.  When the
list is empty or null, i got the result fast, however, if the list
contains the objects, we got the result is really slow in the client
side, it need 4-6 seconds to get the result. In addition, I do not
have much objects in the datastore  .

The function in client side:

rpcService.getRelatedEntities(entityKey, new AsyncCallback<List<MyObject>>() {

                       public void onSuccess(List results) {

                           handlnRpcResult(results);
                       }

                       public void onFailure(Throwable caught) {
                           Window.alert("Error");
                       }
                   });

The code in server side :
List<MyObject> results = new ArrayList<MyObject>();
MyObject object = this.datastore.load(MyObject.class, entityKey);
Iterator<EntityJoin>  itJoins =
this.datastore.find().type(EntityJoin.class).addFilter("firstEntity",
FilterOperator.EQUAL, object).now();
while (itJoins.hasNext()) {
EntityJoin j = itJoins.next();

 results.add(j.getSecondEntity());
}
return results;

And my class EntityJoin :
public class EntityJoin implements Serializable {
   private MyObject firstEntity;
   private MyObject secondEntity;

   //GETTER and SETTER
}

Is there something wrong with my code?I have lost a lot of hair over
this and need some 1 to advise me. Thank you in advance.

Original issue reported on code.google.com by qinail...@gmail.com on 4 Nov 2011 at 9:29

GoogleCodeExporter commented 9 years ago
things to try:

don't load the first instance.  Create a new dummy instance and associate it 
with the ObjectDatastore.  e.g:

first = new MyObject(id);
od.associate(first);

Make sure you only load the entities you need with setActivationDepth(0), 
collect together all the unactivated second instances and then 
activateAll(seconds).

Use AppStats so you know how many datastore RPC calls are being made and how 
long each is taking.

Original comment by jdpatterson on 4 Nov 2011 at 9:48