List of usage examples for org.apache.commons.collections.buffer PriorityBuffer PriorityBuffer
public PriorityBuffer(int capacity)
From source file:org.apache.accumulo.core.iterators.system.HeapIterator.java
protected void createHeap(int maxSize) { if (heap != null) throw new IllegalStateException("heap already exist"); heap = new PriorityBuffer(maxSize == 0 ? 1 : maxSize); }
From source file:org.apache.accumulo.server.tabletserver.log.MultiReader.java
public synchronized boolean seek(WritableComparable key) throws IOException { PriorityBuffer reheap = new PriorityBuffer(heap.size()); boolean result = false; for (Object obj : heap) { Index index = (Index) obj;// ww w . j a va 2 s . co m try { WritableComparable found = index.reader.getClosest(key, index.value, true); if (found != null && found.equals(key)) { result = true; } } catch (EOFException ex) { // thrown if key is beyond all data in the map } index.cached = false; reheap.add(index); } heap = reheap; return result; }
From source file:org.apache.accumulo.tserver.log.RecoveryLogReader.java
@VisibleForTesting synchronized boolean seek(WritableComparable<?> key) throws IOException { PriorityBuffer reheap = new PriorityBuffer(heap.size()); boolean result = false; for (Object obj : heap) { Index index = (Index) obj;// w w w . j a v a2 s. c o m try { WritableComparable<?> found = index.reader.getClosest(key, index.value, true); if (found != null && found.equals(key)) { result = true; } } catch (EOFException ex) { // thrown if key is beyond all data in the map } index.cached = false; reheap.add(index); } heap = reheap; return result; }
From source file:org.lockss.crawler.CrawlQueue.java
/** Create a CrawlQueue that sorts {@link CrawlUrlData} objects (viewed * as {@link CrawlUrl}) by the specified comparator. * @param comparator the comparator that determines the order of URLs in * the queue. If null, the crawl will be breadth first, with the URLs at * each level fetched in the order they were discovered (at the previous * level)./*from www . j av a 2 s .c o m*/ */ public CrawlQueue(Comparator<CrawlUrl> comparator) { if (comparator == null) { sorted = new UnboundedFifoBuffer(); } else { sorted = new PriorityBuffer(comparator); } map = new HashMap<String, CrawlUrlData>(); }