Package org.timedex.dao.interfaces

Examples of org.timedex.dao.interfaces.EventDAO


    File indexDir = new File(props.getProperty("lucene.index.dir", DEFAULT_LUCENE_INDEX_DIR));
   
    IndexWriter writer = new IndexWriter(indexDir,
        new StandardAnalyzer(), true);

    EventDAO eventDAO = new EventDAOImpl();

    System.out.println("Counting events...");
    long t1 = System.currentTimeMillis();

    long events = 0;
    try {
      sessionStrategy.beginTransaction();
      events = eventDAO.count();
      sessionStrategy.commitTransaction();
    } finally {
      sessionStrategy.rollbackIfActive();
    }

    long t2 = System.currentTimeMillis();
    System.out.println("...done (" + events + " events). Took " + (t2 - t1) + "ms");

    System.out.println("\nIndexing to directory '" + indexDir.getAbsolutePath() + "'...");
    t1 = System.currentTimeMillis();
   
    DateFormat dateFormat = DateFormat.getDateInstance();
   
    int start = 0;
    while (start < events) {
      System.out.println("Working on chunk starting at " + start + " out of " + events);

      List<Event> chunk = Collections.emptyList();
      try {
        sessionStrategy.beginTransaction();
        chunk = eventDAO.findAll(start, CHUNK_SIZE);
        sessionStrategy.commitTransaction();
      } finally {
        sessionStrategy.rollbackIfActive();
      }
View Full Code Here


  private static final SessionStrategy sessionStrategy = HibernateSessionStrategy.getInstance();
 
  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);
          }

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

      System.out.println("index being used: " + LUCENE_INDEX);
      e.printStackTrace();
      throw new RuntimeException(e);
    }
   
    EventDAO eventDAO = super.getEventDAO();
   
    Iterator it = hits.iterator();
    try {
      while(it.hasNext() && events.size() < maxResults) {
        Document d = ((Hit)it.next()).getDocument();
        long eventId = Long.parseLong(d.getField("event_id").stringValue());
        Event found = eventDAO.findById(eventId);
        events.add(found);
      }
      return events;
    }catch(IOException e) {
      System.out.println("index being used: " + LUCENE_INDEX);
View Full Code Here

TOP

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

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.