void intoOrdered() { orderedChildren = new PriorityQueue<>(); orderedChildren.addAll( children.values() ); children.clear(); for ( Sample child : orderedChildren ) { child.intoOrdered(); } } }
/** * Saves this queue to a stream (that is, serializes it). * * For compatibility with previous version of this class, elements * are first copied to a java.util.PriorityQueue, which is then * serialized. */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { lock.lock(); try { // avoid zero capacity argument q = new PriorityQueue<E>(Math.max(size, 1), comparator); q.addAll(this); s.defaultWriteObject(); } finally { q = null; lock.unlock(); } }
public void setPriorities(final List<FlowFilePrioritizer> newPriorities) { writeLock.lock(); try { priorities.clear(); priorities.addAll(newPriorities); final PriorityQueue<FlowFileRecord> newQueue = new PriorityQueue<>(Math.max(20, activeQueue.size()), new QueuePrioritizer(newPriorities)); newQueue.addAll(activeQueue); activeQueue = newQueue; } finally { writeLock.unlock("setPriorities"); } }
public void putAll(final Collection<FlowFileRecord> flowFiles) { final int numFiles = flowFiles.size(); long bytes = 0L; for (final FlowFile flowFile : flowFiles) { bytes += flowFile.getSize(); } writeLock.lock(); try { if (swapMode || activeQueue.size() >= swapThreshold - numFiles) { swapQueue.addAll(flowFiles); incrementSwapQueueSize(numFiles, bytes, 0); swapMode = true; writeSwapFilesIfNecessary(); } else { incrementActiveQueueSize(numFiles, bytes); activeQueue.addAll(flowFiles); } logger.debug("{} put to {}", flowFiles, this); } finally { writeLock.unlock("putAll"); } }
pq.addAll(children); } while (currentNode.lowerBound < bestNode.lowerBound); System.err.printf("%n");
/** * Constructs a priority queue that contains the elements of a collection. * The constructed priority queue has the initial capacity of 110% of the * size of the collection. The queue uses natural ordering to order its * elements. * * @param c * the collection whose elements will be added to the priority * queue to be constructed. * @throws ClassCastException * if any of the elements in the collection are not comparable. * @throws NullPointerException * if any of the elements in the collection are null. */ public PriorityQueue(Collection<? extends E> c) { if (c instanceof PriorityQueue) { getFromPriorityQueue((PriorityQueue<? extends E>) c); } else if (c instanceof SortedSet) { getFromSortedSet((SortedSet<? extends E>) c); } else { initSize(c); addAll(c); } }
newPartialMatches.addAll(statesToRetain);
this.activeQueue.addAll(unselected); incrementActiveQueueSize(-flowFilesPulled, -bytesPulled);
activeQueue.addAll(swapContents.getFlowFiles());
theQ.addAll(changedIterators); changedIterators.clear();
activeQueue.addAll(swapContents.getFlowFiles()); // ensure that we don't lose the FlowFiles from our queue.
@Override public boolean addAll(Collection<? extends T> items) { return priorityQueue.addAll(items); }
@Override public boolean addAll(Collection<? extends T> c) { return this.queue.addAll(c); }
public synchronized void updateCurrentServingInstance() { synchronized (_currentServingInstance) { Map<String, InstanceTopicPartitionHolder> instanceMap = new HashMap<String, InstanceTopicPartitionHolder>(); Map<String, Set<TopicPartition>> instanceToTopicPartitionsMap = HelixUtils.getInstanceToTopicPartitionsMap(_helixZkManager); List<String> liveInstances = HelixUtils.liveInstances(_helixZkManager); for (String instanceName : liveInstances) { InstanceTopicPartitionHolder instance = new InstanceTopicPartitionHolder(instanceName); instanceMap.put(instanceName, instance); } for (String instanceName : instanceToTopicPartitionsMap.keySet()) { if (instanceMap.containsKey(instanceName)) { instanceMap.get(instanceName) .addTopicPartitions(instanceToTopicPartitionsMap.get(instanceName)); } } _currentServingInstance.clear(); _currentServingInstance.addAll(instanceMap.values()); } }
private Queue<Long> queuedTicketNumbers(Collection<String> ticketIds) { List<Long> tickets = new ArrayList<>(); for (String id : ticketIds) { tickets.add(Long.parseLong(id)); } Collections.sort(tickets); PriorityQueue<Long> longs = new PriorityQueue<>(tickets.size(), Collections.reverseOrder()); longs.addAll(tickets); return longs; }
@Override public boolean addAll(Collection paramCollection) { if (_directAccess) { return super.addAll(paramCollection); } return ProxyCollections.addAll(this, paramCollection); }
@Override public boolean addAll(Collection paramCollection) { if (_directAccess) { return super.addAll(paramCollection); } return ProxyCollections.addAll(this, paramCollection); }
@Override public void switchOff(double timeSeconds) { Set<SignalGroupStateChangeRequest> req = new HashSet<SignalGroupStateChangeRequest>(); for (Id<SignalGroup> sgId : this.signalGroups.keySet()){ req.add(new SignalGroupStateChangeRequestImpl(sgId, SignalGroupState.YELLOW, timeSeconds)); req.add(new SignalGroupStateChangeRequestImpl(sgId, SignalGroupState.OFF, timeSeconds + SWITCH_OFF_SEQUENCE_LENGTH)); } this.sortedRequests.addAll(req); }
private void processFinalizedAndPendingItems( ReadsDownsampler<SAMRecord> currentDownsampler ) { if ( currentDownsampler.hasFinalizedItems() ) { orderedDownsampledReadsCache.addAll(currentDownsampler.consumeFinalizedItems()); } updateEarliestPendingRead(currentDownsampler); }