java.util.concurrent.ConcurrentSkipListMap.lowerEntry()方法的使用及代码示例

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

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

ConcurrentSkipListMap.lowerEntry介绍

[英]Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key. The returned entry does not support the Entry.setValue method.
[中]返回与严格小于给定键的最大键关联的键值映射,如果没有这样的键,则返回null。返回的条目支持该条目。设置值方法。

代码示例

代码示例来源:origin: qunarcorp/qmq

DispatchLogSegment lowerSegment(long offset) {
    Map.Entry<Long, DelaySegment<Boolean>> lowEntry = segments.lowerEntry(offset);
    if (lowEntry == null) {
      return null;
    }
    return (DispatchLogSegment) lowEntry.getValue();
  }
}

代码示例来源:origin: qunarcorp/qmq

public LogSegment locateSegment(final long offset) {
  if (isBaseOffset(offset)) {
    return segments.get(offset);
  }
  final Map.Entry<Long, LogSegment> entry = segments.lowerEntry(offset);
  if (entry == null) {
    return null;
  } else {
    return entry.getValue();
  }
}

代码示例来源:origin: palantir/atlasdb

@Override
public Map<Cell, Value> get(TableReference tableRef, Map<Cell, Long> timestampByCell) {
  ConcurrentSkipListMap<Key, byte[]> table = getTableMap(tableRef).entries;
  Map<Cell, Value> result = Maps.newHashMap();
  for (Map.Entry<Cell, Long> e : timestampByCell.entrySet()) {
    Cell cell = e.getKey();
    Entry<Key, byte[]> lastEntry = table.lowerEntry(new Key(cell, e.getValue()));
    if (lastEntry != null) {
      Key key = lastEntry.getKey();
      if (key.matchesCell(cell)) {
        long ts = lastEntry.getKey().ts;
        result.put(cell, Value.createWithCopyOfData(lastEntry.getValue(), ts));
      }
    }
  }
  return result;
}

代码示例来源:origin: co.paralleluniverse/galaxy

private Node getPreviousNode(String node) {
  assert ordered;
  synchronized (nodes) {
    final Map.Entry<String, Node> entry = nodes.lowerEntry(node);
    return (entry != null ? entry.getValue() : null);
  }
}

代码示例来源:origin: the8472/mldht

public List<KBucketEntry> get(Key target, int targetSize)
{
  ArrayList<KBucketEntry> closestSet = new ArrayList<>(2 * targetSize);
  
  Map.Entry<Key, CacheBucket> ceil = cache.ceilingEntry(target);
  Map.Entry<Key, CacheBucket> floor = cache.floorEntry(target);
  
  do
  {
    if(floor != null)
    {
      closestSet.addAll(floor.getValue().entries);
      floor = cache.lowerEntry(floor.getKey());
    }
      
    if(ceil != null)
    {
      closestSet.addAll(ceil.getValue().entries);
      ceil = cache.higherEntry(ceil.getKey());
    }
  } while (closestSet.size() / 2 < targetSize && (floor != null || ceil != null));
  
  return closestSet;
}

代码示例来源:origin: com.palantir.atlasdb/atlasdb-client

@Override
public Map<Cell, Value> get(TableReference tableRef, Map<Cell, Long> timestampByCell) {
  ConcurrentSkipListMap<Key, byte[]> table = getTableMap(tableRef).entries;
  Map<Cell, Value> result = Maps.newHashMap();
  for (Map.Entry<Cell, Long> e : timestampByCell.entrySet()) {
    Cell cell = e.getKey();
    Entry<Key, byte[]> lastEntry = table.lowerEntry(new Key(cell, e.getValue()));
    if (lastEntry != null) {
      Key key = lastEntry.getKey();
      if (key.matchesCell(cell)) {
        long ts = lastEntry.getKey().ts;
        result.put(cell, Value.createWithCopyOfData(lastEntry.getValue(), ts));
      }
    }
  }
  return result;
}

代码示例来源:origin: cinchapi/concourse

@Override
public java.util.Map.Entry<K, V> lowerEntry(K key) {
  long[] stamps = grabAllSegmentWriteLocks();
  try {
    sort();
    return sorted.lowerEntry(key);
  }
  finally {
    releaseSegmentLocks(stamps);
  }
}

代码示例来源:origin: indeedeng/lsmtree

@Override
  protected Entry<K, V> computeNext() {
    final Map.Entry<K, Object> entry;
    if (!initialized) {
      initialized = true;
      if (start == null) {
        entry = map.lastEntry();
      } else if (startInclusive) {
        entry = map.floorEntry(start);
      } else {
        entry = map.lowerEntry(start);
      }
    } else {
      entry = map.lowerEntry(key);
    }
    if (entry == null) {
      return endOfData();
    }
    key = entry.getKey();
    final Object value = entry.getValue();
    if (value == deleted) return Entry.createDeleted(key);
    return Entry.create(key, (V)value);
  }
};

代码示例来源:origin: org.hbase/asynchbase

: table, stop_key);
final Map.Entry<byte[], RegionInfo> entry =
 regions_cache.lowerEntry(search_key);
if (entry != null && entry.getValue() == region) {

代码示例来源:origin: the8472/mldht

entry = cache.lowerEntry(current.prefix);
if(entry == null)
  continue;

代码示例来源:origin: addthis/hydra

/**
 * Return true if the page was evicted from the cache
 *
 * @return true if the page was evicted from the cache
 */
protected boolean removePageFromCache(K targetKey) {
  assert (!targetKey.equals(negInf));
  Page<K, V> currentPage;
  Map.Entry<K, Page<K, V>> prevEntry, currentEntry;
  prevEntry = getCache().lowerEntry(targetKey);
  currentEntry = getCache().higherEntry(prevEntry.getKey());
  if (currentEntry != null) {
    currentPage = currentEntry.getValue();
    int compareKeys = compareKeys(targetKey, currentPage.getFirstKey());
    if (compareKeys < 0) {
      return false;
    } else if (compareKeys == 0 && currentPage.keys() == null &&
        currentPage.getState() == ExternalMode.DISK_MEMORY_IDENTICAL) {
      currentPage.setState(ExternalMode.MEMORY_EVICTED);
      getCache().remove(targetKey);
      cacheSize.getAndDecrement();
      return true;
    }
  }
  return false;
}

代码示例来源:origin: co.paralleluniverse/galaxy

private void nodeRemoved(String name) {
  try {
    boolean _doneInit;
    final Node node;
    Node previous = null, next = null;
    synchronized (nodes) {
      while (!doneInit)
        nodes.wait();
      if (ordered) {
        previous = value(nodes.lowerEntry(name));
        next = value(nodes.higherEntry(name));
      }
      node = nodes.remove(name);
      _doneInit = this.doneInit;
    }
    if (node.isComplete()) {
      for (Listener listener : listeners)
        listener.nodeChildDeleted(branchRoot, name);
    }
    if (ordered) {
      if (_doneInit && next != null && (previous == null || previous.isComplete()))
        next.predecessorsComplete();
    }
  } catch (InterruptedException e) {
    throw new RuntimeException();
  }
}

相关文章

ConcurrentSkipListMap类方法