// Path: src/main/java/eu/socialsensor/focused/crawler/models/RankedWebPage.java
// public class RankedWebPage implements Comparable<RankedWebPage> {
// 
// 	private WebPage webPage;
// 	private double score = 0;
// 	
// 	public RankedWebPage(WebPage webPage, double score) {
// 		this.webPage = webPage;
// 		this.score = score;
// 	}
// 
// 	public WebPage getWebPage() {
// 		return webPage;
// 	}
// 	
// 	public double getScore() {
// 		return score;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return webPage.getUrl() + " : " + score;
// 	}
// 	
// 	public int compareTo(RankedWebPage other) {
// 		if(this.score > other.score) {
// 			return -1;
// 		}
// 		return 1;
// 	}
// 
// 	public static void main(String[] args) {
// 		PriorityQueue<RankedWebPage> _queue = new PriorityQueue<RankedWebPage>();
// 		
// 		RankedWebPage rwp1 = new RankedWebPage(new WebPage("A", "1"), 0.1);
// 		RankedWebPage rwp2 = new RankedWebPage(new WebPage("B", "1"), 0.2);
// 		RankedWebPage rwp3 = new RankedWebPage(new WebPage("C", "1"), 0.4);
// 		RankedWebPage rwp4 = new RankedWebPage(new WebPage("D", "1"), 0.1);
// 		
// 		_queue.offer(rwp1);
// 		_queue.offer(rwp2);
// 		_queue.offer(rwp3);
// 		_queue.offer(rwp4);
// 		
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());	
// 	}
// }


import static backtype.storm.utils.Utils.tuple;
import java.util.Date;
import java.util.Map;
import java.util.PriorityQueue;
import org.apache.log4j.Logger;
import eu.socialsensor.focused.crawler.models.RankedWebPage;
import eu.socialsensor.framework.common.domain.WebPage;
import eu.socialsensor.framework.common.factories.ItemFactory;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.utils.Utils;
package eu.socialsensor.focused.crawler.bolts.webpages;





public class RankerBolt extends BaseRichBolt {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	private static long avgTimeDiff = 10 * 60 * 1000; // 10 minutes 
	
	private OutputCollector _collector;
// Path: src/main/java/eu/socialsensor/focused/crawler/models/RankedWebPage.java
// public class RankedWebPage implements Comparable<RankedWebPage> {
// 
// 	private WebPage webPage;
// 	private double score = 0;
// 	
// 	public RankedWebPage(WebPage webPage, double score) {
// 		this.webPage = webPage;
// 		this.score = score;
// 	}
// 
// 	public WebPage getWebPage() {
// 		return webPage;
// 	}
// 	
// 	public double getScore() {
// 		return score;
// 	}
// 	
// 	@Override
// 	public String toString() {
// 		return webPage.getUrl() + " : " + score;
// 	}
// 	
// 	public int compareTo(RankedWebPage other) {
// 		if(this.score > other.score) {
// 			return -1;
// 		}
// 		return 1;
// 	}
// 
// 	public static void main(String[] args) {
// 		PriorityQueue<RankedWebPage> _queue = new PriorityQueue<RankedWebPage>();
// 		
// 		RankedWebPage rwp1 = new RankedWebPage(new WebPage("A", "1"), 0.1);
// 		RankedWebPage rwp2 = new RankedWebPage(new WebPage("B", "1"), 0.2);
// 		RankedWebPage rwp3 = new RankedWebPage(new WebPage("C", "1"), 0.4);
// 		RankedWebPage rwp4 = new RankedWebPage(new WebPage("D", "1"), 0.1);
// 		
// 		_queue.offer(rwp1);
// 		_queue.offer(rwp2);
// 		_queue.offer(rwp3);
// 		_queue.offer(rwp4);
// 		
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());
// 		System.out.println(_queue.poll());	
// 	}
// }


// Path: src/main/java/eu/socialsensor/focused/crawler/bolts/webpages/RankerBolt.java
import static backtype.storm.utils.Utils.tuple;
import java.util.Date;
import java.util.Map;
import java.util.PriorityQueue;
import org.apache.log4j.Logger;
import eu.socialsensor.focused.crawler.models.RankedWebPage;
import eu.socialsensor.framework.common.domain.WebPage;
import eu.socialsensor.framework.common.factories.ItemFactory;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.utils.Utils;

package eu.socialsensor.focused.crawler.bolts.webpages;





public class RankerBolt extends BaseRichBolt {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	private static long avgTimeDiff = 10 * 60 * 1000; // 10 minutes 
	
	private OutputCollector _collector;
	private PriorityQueue<RankedWebPage> _queue;