Kisu San wrote:
Below is my method, I am using DerbyPersistenceManager. Is there anyway, we can by pass using persistence manager? What are the trade offs of not using persistence manager?

the persistence manager is an integral part of jackrabbit, you cannot just bypass it.

public ArrayList getBulletinList(String bulletinType, String model) throws
RepositoryException {
                
                log.info("Entering .....");
                long startTime = System.currentTimeMillis();
                //String query = "//" + PRIMARY_NODE + "/child::*";
                //String query = "//element(*, bulletin)";
                //String query = "//element(*, " + NODE_TYPE + " )";
                String query ="/jcr:root/BULLETIN//element(*, " + NODE_TYPE
+")[jcr:deref(@btnmodel='" + model +"') and" +
                                                                                               
         " jcr:deref(@btnbulletin_type='"+ bulletinType +"')] order by
jcr:score() descending";

please note that your query will not work as expected because it is invalid and jackrabbit should actually reject it. see: https://issues.apache.org/jira/browse/JCR-1211

                ArrayList list = new ArrayList();
                
                long getResultsStartTime = System.currentTimeMillis();
                
                QueryResult results = getQueryResults(query);
                
                long getResultsEndTime = System.currentTimeMillis();
                log.info("getting nodes from Resultset took " + 
(getResultsEndTime -
getResultsStartTime) + " ms");
                
                NodeIterator it =  results.getNodes();
                

                log.debug("Size is  " + it.getSize());
                BulletinDTO dto = null;
                //while (it.hasNext()) {
                long loopStartTime = System.currentTimeMillis();
                for (int i= 0; i < it.getSize(); i++){
                        
                        Node n = (Node) it.next();
                        
                        //log.debug("Node name is  " + n.getName());
                        
                        dto = new BulletinDTO();
                        dto.setName(n.getName());
                        dto.setUuid(n.getUUID());
                        dto.setBulletinId(n.getProperty(ID).getLong());
                
dto.setBulletinTypeRef(n.getProperty(REF_BULLETIN_TYPE).getNode().getUUID());
                        
dto.setModelRef(n.getProperty(REF_MODEL).getNode().getUUID());
                        dto.setContent(n.getProperty(REF_TOPIC).getStream());
                        list.add(dto);
                        
                }
                long loopEndTime = System.currentTimeMillis();
                log.info("To loop through and populate 1000 dtos it took" + 
(loopEndTime -
loopStartTime) + " ms");
                
                long finishTime = System.currentTimeMillis();
                log.debug("Finished in " + (finishTime - startTime) + "ms");
                log.info("Finished");
                return list;

                }

metrics from log are 13-43-2007 11:43:16:726 - INFO -
com.entity.data.daoimpl.GenericDAOImpl.getQueryResults() :Finished in 500 ms
13-43-2007 11:43:16:726 - INFO -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :getting nodes
from Resultset took 500 ms
13-43-2007 11:43:16:742 - DEBUG -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :Size is  10000
13-43-2007 11:43:32:226 - INFO -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :To loop through
and populate 1000 dtos it took15484 ms
13-43-2007 11:43:32:226 - DEBUG -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :Finished in
16000ms

please note that the size of the query result is 10'000 (!) and not one thousand. the timing quite clearly shows that the majority of the time is spend iterating over the result and retrieving the nodes.

I made another call with in same session, their logs are

13-43-2007 11:43:32:414 - INFO -
com.entity.data.daoimpl.GenericDAOImpl.getQueryResults() :Finished in 188 ms
13-43-2007 11:43:32:414 - INFO -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :getting nodes
from Resultset took 188 ms
13-43-2007 11:43:32:430 - DEBUG -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :Size is  10000
13-43-2007 11:43:33:305 - INFO -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :To loop through
and populate 1000 dtos it took875 ms
13-43-2007 11:43:33:305 - DEBUG -
com.entity.data.daoimpl.BulletinDAOImpl.getBulletinList() :Finished in
1079ms

note that the over all time to execute your code dropped significantly because of the caches in jackrabbit. most nodes are now already cached and the time to loop over the nodes dropped to 875 ms.

regards
 marcel

Reply via email to