java.util.TreeMap.pollFirstEntry()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中java.util.TreeMap.pollFirstEntry()方法的一些代码示例,展示了TreeMap.pollFirstEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.pollFirstEntry()方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:pollFirstEntry

TreeMap.pollFirstEntry介绍

暂无

代码示例

代码示例来源:origin: apache/rocketmq

public Map.Entry<K, V> pollFirstEntry() {
  lock.lock();
  try {
    return tree.pollFirstEntry();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: apache/hive

@Override
 public void close() throws IOException {
  // ColumnizedDeleteEventRegistry reads all the delete events into memory during initialization
  // and it closes the delete event readers after it. If an exception gets thrown during
  // initialization, we may have to close any readers that are still left open.
  while (!sortMerger.isEmpty()) {
   Entry<DeleteRecordKey, DeleteReaderValue> entry = sortMerger.pollFirstEntry();
   entry.getValue().close(); // close the reader for this entry
  }
 }
}

代码示例来源:origin: graphhopper/graphhopper

/**
 * @return removes the smallest entry (key and value) from this collection
 */
public int pollKey() {
  if (map.isEmpty())
    throw new IllegalStateException("Cannot poll collection is empty!");
  long key = map.pollFirstEntry().getKey();
  return bitUtil.getIntLow(key);
}

代码示例来源:origin: linkedin/parseq

/**
 * Check how much we missed scheduled wake up and if it is larger than _minStallNano
 * then consider it a stall and remember it.
 */
private void checkForStall(long currentTime) {
 long delta = currentTime - _lastMonitoringStep;
 if (delta < _shortestObservedDelta) {
  _shortestObservedDelta = delta;
 }
 long stall = Math.max(0, delta - _shortestObservedDelta);
 if (stall > _minStallNano) {
  _stalls.put(_lastMonitoringStep, stall);
  if (_stalls.size() > _stallsHistorySize) {
   _stalls.pollFirstEntry();
  }
 }
}

代码示例来源:origin: apache/drill

@Override
 public void close() throws IOException {
  // ColumnizedDeleteEventRegistry reads all the delete events into memory during initialization
  // and it closes the delete event readers after it. If an exception gets thrown during
  // initialization, we may have to close any readers that are still left open.
  while (!sortMerger.isEmpty()) {
   Entry<DeleteRecordKey, DeleteReaderValue> entry = sortMerger.pollFirstEntry();
   entry.getValue().close(); // close the reader for this entry
  }
 }
}

代码示例来源:origin: apache/rocketmq

public List<MessageExt> takeMessags(final int batchSize) {
  List<MessageExt> result = new ArrayList<MessageExt>(batchSize);
  final long now = System.currentTimeMillis();
  try {
    this.lockTreeMap.writeLock().lockInterruptibly();
    this.lastConsumeTimestamp = now;
    try {
      if (!this.msgTreeMap.isEmpty()) {
        for (int i = 0; i < batchSize; i++) {
          Map.Entry<Long, MessageExt> entry = this.msgTreeMap.pollFirstEntry();
          if (entry != null) {
            result.add(entry.getValue());
            consumingMsgOrderlyTreeMap.put(entry.getKey(), entry.getValue());
          } else {
            break;
          }
        }
      }
      if (result.isEmpty()) {
        consuming = false;
      }
    } finally {
      this.lockTreeMap.writeLock().unlock();
    }
  } catch (InterruptedException e) {
    log.error("take Messages exception", e);
  }
  return result;
}

代码示例来源:origin: wildfly/wildfly

private void tryCreatePendingStreams() {
  while (!pendingStreams.isEmpty() && canCreateStream()) {
    Map.Entry<Integer, PendingStream> entry = pendingStreams.pollFirstEntry();
    PendingStream pendingStream = entry.getValue();
    try {
      pendingStream.sendFrames();
    } catch (Throwable t) {
      pendingStream.close(t);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void close() {
  try {
    if (!closed) {
      closed = true;
      // Fail all buffered streams.
      Http2ChannelClosedException e = new Http2ChannelClosedException();
      while (!pendingStreams.isEmpty()) {
        PendingStream stream = pendingStreams.pollFirstEntry().getValue();
        stream.close(e);
      }
    }
  } finally {
    super.close();
  }
}

代码示例来源:origin: Alluxio/alluxio

timeToFile.pollFirstEntry().getValue());
mUfs.deleteFile(toDeleteFile);

代码示例来源:origin: apache/hive

Entry<DeleteRecordKey, DeleteReaderValue> entry = sortMerger.pollFirstEntry();
DeleteRecordKey deleteRecordKey = entry.getKey();
DeleteReaderValue deleteReaderValue = entry.getValue();

代码示例来源:origin: apache/drill

Entry<DeleteRecordKey, DeleteReaderValue> entry = sortMerger.pollFirstEntry();
DeleteRecordKey deleteRecordKey = entry.getKey();
DeleteReaderValue deleteReaderValue = entry.getValue();

代码示例来源:origin: apache/drill

Map.Entry<ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
if (entry != null) {
 primary = entry.getValue();

代码示例来源:origin: apache/hive

Map.Entry<ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
if (entry != null) {
 primary = entry.getValue();

代码示例来源:origin: apache/drill

Map.Entry<ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
if (entry == null) {
 columns = 0;

代码示例来源:origin: javahongxi/whatsmars

public Map.Entry<K, V> pollFirstEntry() {
  lock.lock();
  try {
    return tree.pollFirstEntry();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: didi/DDMQ

public Map.Entry<K, V> pollFirstEntry() {
  lock.lock();
  try {
    return tree.pollFirstEntry();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: yacy/yacy_grid_mcp

@Override
public synchronized Map.Entry<K,V> pollFirstEntry() {
  Map.Entry<K,V> entry = super.pollFirstEntry();
  boolean removed = removeFromKeys(entry.getKey());
  assert removed;
  return entry;
}
@Override

代码示例来源:origin: apache/hive

Map.Entry<ReaderKey, ReaderPair> entry = readers.pollFirstEntry();
if (entry == null) {
 columns = 0;

代码示例来源:origin: didi/DDMQ

public List<MessageExt> takeMessags(final int batchSize) {
  List<MessageExt> result = new ArrayList<MessageExt>(batchSize);
  final long now = System.currentTimeMillis();
  try {
    this.lockTreeMap.writeLock().lockInterruptibly();
    this.lastConsumeTimestamp = now;
    try {
      if (!this.msgTreeMap.isEmpty()) {
        for (int i = 0; i < batchSize; i++) {
          Map.Entry<Long, MessageExt> entry = this.msgTreeMap.pollFirstEntry();
          if (entry != null) {
            result.add(entry.getValue());
            consumingMsgOrderlyTreeMap.put(entry.getKey(), entry.getValue());
          } else {
            break;
          }
        }
      }
      if (result.isEmpty()) {
        consuming = false;
      }
    } finally {
      this.lockTreeMap.writeLock().unlock();
    }
  } catch (InterruptedException e) {
    log.error("take Messages exception", e);
  }
  return result;
}

代码示例来源:origin: quickfix-j/quickfixj

private void updateMessageIndex(long sequenceNum, long offset, int size) {
  // Remove the lowest indexed sequence number if this addition
  // would result the index growing to larger than maxCachedMsgs.
  if (messageIndex.size() >= maxCachedMsgs && messageIndex.get(sequenceNum) == null) {
    messageIndex.pollFirstEntry();
  }
  messageIndex.put(sequenceNum, new long[] { offset, size });
}

相关文章