Package org.timedex.dao.interfaces

Examples of org.timedex.dao.interfaces.PageMetaDAO


      }
    }
  }
 
  public static void iterate(int iterations) {
    PageMetaDAO pageMetaDAO = new PageMetaDAOImpl();
    PageLinkDAO pageLinkDAO = new PageLinkDAOImpl();
    PageDAO pageDAO = new PageDAOImpl();
   
    for (int iteration = 0; iteration < iterations; iteration++) {
      System.out.print("Performing iteration " + (iteration + 1) + " ... ");
     
      int pages = 0;
      try {
        sessionStrategy.beginTransaction();
        pages = pageDAO.count();
        sessionStrategy.commitTransaction();
      } finally {
        sessionStrategy.rollbackIfActive();
      }
     
      int start = 0;
     
      double pre = ((1.0 - DAMPING) / (double)pages) + DAMPING;
     
      while (start < pages) {
       
        List<Page> chunk = Collections.emptyList();
        try {
          sessionStrategy.beginTransaction();
          chunk = pageDAO.findAll(start, CHUNK_SIZE);
          sessionStrategy.commitTransaction();
        } finally {
          sessionStrategy.rollbackIfActive();
        }

        for (Page p : chunk) {
          try {
            sessionStrategy.beginTransaction();

            double rank = pre;

            PageMeta meta = pageMetaDAO.findByPage(p);
            List<Page> linksIn = pageLinkDAO.findLinksInByPage(p);

            if (linksIn == null || linksIn.size() == 0)
              continue;

            for (Page linkIn : linksIn) {
              PageMeta linkInMeta = pageMetaDAO
                  .findByPage(linkIn);
              List<Page> linksOut = pageLinkDAO
                  .findLinksOutByPage(linkIn);

              if (linksOut != null && linksOut.size() != 0)
                rank += (linkInMeta.getRank())
                    / linksOut.size();
            }

            if (meta == null) {
              meta = new PageMeta(p, new Date(0), 0, rank);
              pageMetaDAO.create(meta);
            } else
              pageMetaDAO.updatePageRank(meta, rank);

            sessionStrategy.commitTransaction();
           
          } finally {
            sessionStrategy.rollbackIfActive();
View Full Code Here


   
    public void run() {
      System.out.println("\tThread starting with " + start + ", " + chunkSize);
      double pre = ((1.0 - DAMPING) / (double)pages) + DAMPING;
     
      PageMetaDAO pageMetaDAO = new PageMetaDAOImpl();
      PageLinkDAO pageLinkDAO = new PageLinkDAOImpl();
      PageDAO pageDAO = new PageDAOImpl();
     
      List<Page> chunk = Collections.emptyList();
      try {
        sessionStrategy.beginTransaction();
        chunk = pageDAO.findAll(start, chunkSize);
        sessionStrategy.commitTransaction();
      } finally {
        sessionStrategy.rollbackIfActive();
      }

      for (Page p : chunk) {
        try {
          sessionStrategy.beginTransaction();

          double rank = pre;

          PageMeta meta = pageMetaDAO.findByPage(p);
          List<Page> linksIn = pageLinkDAO.findLinksInByPage(p);

          if (linksIn == null || linksIn.size() == 0)
            continue;

          for (Page linkIn : linksIn) {
            PageMeta linkInMeta = pageMetaDAO
                .findByPage(linkIn);
            List<Page> linksOut = pageLinkDAO
                .findLinksOutByPage(linkIn);

            if (linksOut != null && linksOut.size() != 0)
              rank += (linkInMeta.getRank())
                  / linksOut.size();
          }

          if (meta == null) {
            meta = new PageMeta(p, new Date(0), 0, rank);
            pageMetaDAO.create(meta);
          } else
            pageMetaDAO.updatePageRank(meta, rank);

          sessionStrategy.commitTransaction();
         
        } finally {
          sessionStrategy.rollbackIfActive();
View Full Code Here

TOP

Related Classes of org.timedex.dao.interfaces.PageMetaDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.