My replies take a long time to get posted here since I'm new. 

My application is written in Java and instance class of my app is F4. There 
are a total of 922,758 entities of that Kind in the Datastore.

Here's the function:

public static Map <String , Object> getEntitiesUsingQueryCursor( String kind , 
int limit , int chunkSize , String currentCursor, String account, String user, 
Boolean status, String dept ) throws Exception
        {

            String nextCursor = null;

            Entity entity = null;

            List <Entity> listOfEntity = new ArrayList <Entity>();

            Map <String , Object> result = new HashMap <String , Object>();


            DatastoreService datastore = 
DatastoreServiceFactory.getDatastoreService();
            com.google.appengine.api.datastore.Query q = new 
com.google.appengine.api.datastore.Query( kind );

List <Filter> listOfFilter = new ArrayList <Filter>();
Filter filter1 = new FilterPredicate( "accountID" , FilterOperator.EQUAL ,  
account);
Filter filter2 = new FilterPredicate( "assigneeID" , FilterOperator.EQUAL ,  
user);
Filter filter3 = new FilterPredicate( "departmentID" , FilterOperator.EQUAL ,  
dept);
Filter filter4 = new FilterPredicate( "open" , FilterOperator.EQUAL ,  status); 
//Boolean
listOfFilter.add( filter1 );
listOfFilter.add( filter2 );
listOfFilter.add( filter3 );
listOfFilter.add( filter4 );
Filter filterParams1 = filterParams = CompositeFilterOperator.and( listOfFilter 
);
q.setFilter( filter );

            PreparedQuery pq = datastore.prepare( q );
            FetchOptions fetchOptions = 
FetchOptions.Builder.withLimit(limit).prefetchSize( chunkSize ).chunkSize( 
chunkSize );// limit & chunksize - 500

            if ( !StringUtil.isBlank( currentCursor ) )
                fetchOptions.startCursor( Cursor.fromWebSafeString( 
currentCursor ) );

            QueryResultIterable <Entity> results = pq.asQueryResultIterable( 
fetchOptions );
            QueryResultIterator <Entity> iterator = results.iterator();

            while ( iterator.hasNext() )
                {
                    entity = iterator.next();
                    listOfEntity.add( entity );
                }

            if(listOfEntity.size() == limit)
                nextCursor = iterator.getCursor().toWebSafeString();

            result.put( "cursor" , nextCursor );
            result.put( "entity" , listOfEntity );

            return result;
}


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/1023920d-8691-4b2d-90ab-833413090524%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to