Package org.timedex.dao.interfaces

Examples of org.timedex.dao.interfaces.PageLinkDAO


    }
  }
 
  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();
View Full Code Here


  public static void main(String[] args) {
    clearBadRows();
  }
 
  public static void clearBadRows() {
    PageLinkDAO pageLinkDAO = new PageLinkDAOImpl();
    PageDAO pageDAO = new PageDAOImpl();
   
    int count = -1;
   
    try {
      sessionStrategy.beginTransaction();
      count = pageLinkDAO.count();
      sessionStrategy.commitTransaction();
    } finally {
      sessionStrategy.rollbackIfActive();
    }
   
    int start = 0;
    long erased = 0;
   
    while (start < count) {
      List<PageLink> chunk = null;
      try {
        sessionStrategy.beginTransaction();
       
        chunk = pageLinkDAO.findDistinctSources(start, CHUNK_SIZE);
       
        sessionStrategy.commitTransaction();
      } finally {
        sessionStrategy.rollbackIfActive();
      }
     
      for (PageLink pl : chunk) {
        try {
          sessionStrategy.beginTransaction();
         
          Page found = pageDAO.findById(pl.getSourcePageId());
         
          if (found == null) {
            pageLinkDAO.delete(pl);
            erased++;
          } else {
            Page found2 = pageDAO.findByTitleAndNamespace(pl.getDestinationTitle(), pl.getDestinationNamespace());
         
            if (found2 == null) {
              pageLinkDAO.delete(pl);
              erased++;
            }
          }
         
          sessionStrategy.commitTransaction();
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();
View Full Code Here

 
  public static void main(String[] args) {
    System.out.println("Running naive page rank");
   
    EventDAO eventDAO = new EventDAOImpl();
    PageLinkDAO pageLinkDAO = new PageLinkDAOImpl();
    PageDAO pageDAO = new PageDAOImpl();
   
    int pages = 0;
    try {
      sessionStrategy.beginTransaction();
      pages = pageDAO.count();
      sessionStrategy.commitTransaction();
    } finally {
      sessionStrategy.rollbackIfActive();
    }
   
    int start = 0;
   
    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();

          int linksIn = pageLinkDAO.findLinkCountInByPage(p);

          List<Event> events = eventDAO.findByPage(p);
          for (Event e : events) {
            e.setRank(linksIn);
            eventDAO.update(e);
View Full Code Here

TOP

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

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.