本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.removeLast()
方法的一些代码示例,展示了MinMaxPriorityQueue.removeLast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.removeLast()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:removeLast
[英]Removes and returns the greatest element of this queue.
[中]删除并返回此队列中最大的元素。
代码示例来源:origin: apache/hive
public int removeBiggest() {
return indexes.removeLast();
}
代码示例来源:origin: apache/phoenix
/**
* Used when the cache is growing past its max size to clone in a single pass.
* Removes least recently used tables to get size of cache below its max size by
* the overage amount.
*/
public PMetaDataCache cloneMinusOverage(long overage) {
assert(overage > 0);
int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1);
MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create();
PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory);
long toRemoveBytes = 0;
// Add to new cache, but track references to remove when done
// to bring cache at least overage amount below it's max size.
for (PTableRef tableRef : this.tables.values()) {
newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef));
toRemove.add(tableRef);
toRemoveBytes += tableRef.getEstimatedSize();
while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) {
PTableRef removedRef = toRemove.removeLast();
toRemoveBytes -= removedRef.getEstimatedSize();
}
}
for (PTableRef toRemoveRef : toRemove) {
newCache.remove(toRemoveRef.getTable().getKey());
}
return newCache;
}
代码示例来源:origin: co.cask.hbase/hbase
/**
* Add a region from the head or tail to the List of regions to return.
*/
void addRegionPlan(final MinMaxPriorityQueue<RegionPlan> regionsToMove,
final boolean fetchFromTail, final ServerName sn, List<RegionPlan> regionsToReturn) {
RegionPlan rp = null;
if (!fetchFromTail) rp = regionsToMove.remove();
else rp = regionsToMove.removeLast();
rp.setDestination(sn);
regionsToReturn.add(rp);
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
private long replaceRow(Block[] row)
{
checkState(candidateRows.size() == maxRowCountPerPartition);
Block[] previousRow = candidateRows.removeLast();
long sizeDelta = addRow(row);
return sizeDelta - sizeOfRow(previousRow);
}
代码示例来源:origin: alibaba/wasp
/**
* Add a entityGroup from the head or tail to the List of entityGroups to return.
*/
private void addEntityGroupPlan(
final MinMaxPriorityQueue<EntityGroupPlan> entityGroupsToMove,
final boolean fetchFromTail, final ServerName sn,
List<EntityGroupPlan> entityGroupsToReturn) {
EntityGroupPlan rp = null;
if (!fetchFromTail)
rp = entityGroupsToMove.remove();
else
rp = entityGroupsToMove.removeLast();
rp.setDestination(sn);
entityGroupsToReturn.add(rp);
}
}
代码示例来源:origin: com.cloudhopper/ch-mq
queue.removeLast();
代码示例来源:origin: caskdata/cdap
/**
* Balance the assignment by spreading it across all handlers evenly.
*
* @param handlerQueue The priority queue for tracking number of resources assigned to a given handler.
* @param assigner The assigner for changing the assignment.
* @param maxDiff The maximum differences between the handlers that has the most resources assigned vs the one with
* the least resources assigned.
*/
private <T> void balance(MinMaxPriorityQueue<HandlerSize<T>> handlerQueue,
ResourceAssigner<T> assigner, int maxDiff) {
HandlerSize<T> minHandler = handlerQueue.peekFirst();
HandlerSize<T> maxHandler = handlerQueue.peekLast();
// Move assignment from the handler that has the most assigned partition replica to the least one, until the
// differences is within the desired range.
Multimap<T, PartitionReplica> assignments = assigner.get();
while (maxHandler.getSize() - minHandler.getSize() > maxDiff) {
PartitionReplica partitionReplica = assignments.get(maxHandler.getHandler()).iterator().next();
// Remove min and max from the queue, and perform the reassignment.
handlerQueue.removeFirst();
handlerQueue.removeLast();
assigner.set(minHandler.getHandler(), partitionReplica);
// After assignment, the corresponding size should get updated, hence put it back to the queue for next iteration.
handlerQueue.add(minHandler);
handlerQueue.add(maxHandler);
minHandler = handlerQueue.peekFirst();
maxHandler = handlerQueue.peekLast();
}
}
代码示例来源:origin: co.cask.cdap/cdap-common
/**
* Balance the assignment by spreading it across all handlers evenly.
*
* @param handlerQueue The priority queue for tracking number of resources assigned to a given handler.
* @param assigner The assigner for changing the assignment.
* @param maxDiff The maximum differences between the handlers that has the most resources assigned vs the one with
* the least resources assigned.
*/
private <T> void balance(MinMaxPriorityQueue<HandlerSize<T>> handlerQueue,
ResourceAssigner<T> assigner, int maxDiff) {
HandlerSize<T> minHandler = handlerQueue.peekFirst();
HandlerSize<T> maxHandler = handlerQueue.peekLast();
// Move assignment from the handler that has the most assigned partition replica to the least one, until the
// differences is within the desired range.
Multimap<T, PartitionReplica> assignments = assigner.get();
while (maxHandler.getSize() - minHandler.getSize() > maxDiff) {
PartitionReplica partitionReplica = assignments.get(maxHandler.getHandler()).iterator().next();
// Remove min and max from the queue, and perform the reassignment.
handlerQueue.removeFirst();
handlerQueue.removeLast();
assigner.set(minHandler.getHandler(), partitionReplica);
// After assignment, the corresponding size should get updated, hence put it back to the queue for next iteration.
handlerQueue.add(minHandler);
handlerQueue.add(maxHandler);
minHandler = handlerQueue.peekFirst();
maxHandler = handlerQueue.peekLast();
}
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
/**
* Used when the cache is growing past its max size to clone in a single pass.
* Removes least recently used tables to get size of cache below its max size by
* the overage amount.
*/
public PMetaDataCache cloneMinusOverage(long overage) {
assert(overage > 0);
int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1);
MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create();
PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory);
long toRemoveBytes = 0;
// Add to new cache, but track references to remove when done
// to bring cache at least overage amount below it's max size.
for (PTableRef tableRef : this.tables.values()) {
newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef));
toRemove.add(tableRef);
toRemoveBytes += tableRef.getEstimatedSize();
while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) {
PTableRef removedRef = toRemove.removeLast();
toRemoveBytes -= removedRef.getEstimatedSize();
}
}
for (PTableRef toRemoveRef : toRemove) {
newCache.remove(toRemoveRef.getTable().getKey());
}
return newCache;
}
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
/**
* Used when the cache is growing past its max size to clone in a single pass.
* Removes least recently used tables to get size of cache below its max size by
* the overage amount.
*/
public PMetaDataCache cloneMinusOverage(long overage) {
assert(overage > 0);
int nToRemove = Math.max(MIN_REMOVAL_SIZE, (int)Math.ceil((currentByteSize-maxByteSize) / ((double)currentByteSize / size())) + 1);
MinMaxPriorityQueue<PTableRef> toRemove = BUILDER.expectedSize(nToRemove).create();
PMetaDataCache newCache = new PMetaDataCache(this.size(), this.maxByteSize, this.timeKeeper, this.tableRefFactory);
long toRemoveBytes = 0;
// Add to new cache, but track references to remove when done
// to bring cache at least overage amount below it's max size.
for (PTableRef tableRef : this.tables.values()) {
newCache.put(tableRef.getTable().getKey(), tableRefFactory.makePTableRef(tableRef));
toRemove.add(tableRef);
toRemoveBytes += tableRef.getEstimatedSize();
while (toRemoveBytes - toRemove.peekLast().getEstimatedSize() >= overage) {
PTableRef removedRef = toRemove.removeLast();
toRemoveBytes -= removedRef.getEstimatedSize();
}
}
for (PTableRef toRemoveRef : toRemove) {
newCache.remove(toRemoveRef.getTable().getKey());
}
return newCache;
}
内容来源于网络,如有侵权,请联系作者删除!