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

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

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

ConcurrentSkipListMap.get介绍

[英]Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that key compares equal to k according to the map's ordering, then this method returns v; otherwise it returns null. (There can be at most one such mapping.)
[中]返回指定键映射到的值,如果此映射不包含该键的映射,则返回null。
更正式地说,如果此映射包含从键k到值v的映射,使得键根据映射的顺序比较等于k,则此方法返回v;否则返回null。(最多可以有一个这样的映射。)

代码示例

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

RegionStateNode getRegionStateNodeFromName(byte[] regionName) {
 return regionsMap.get(regionName);
}

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

/**
 * @param nodeOrder Node order.
 * @return Node instance.
 */
@Nullable public ZookeeperClusterNode node(long nodeOrder) {
  assert nodeOrder > 0 : nodeOrder;
  return rtState.top.nodesByOrder.get(nodeOrder);
}

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

public boolean isRegionInTransition(final RegionInfo regionInfo) {
 final RegionStateNode node = regionInTransition.get(regionInfo);
 return node != null ? node.isInTransition() : false;
}

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

SegmentBuffer getDispatchData(long segmentBaseOffset, long dispatchLogOffset) {
  DispatchLogSegment segment = (DispatchLogSegment) segments.get(segmentBaseOffset);
  if (null == segment) {
    return null;
  }
  return segment.selectSegmentBuffer(dispatchLogOffset);
}

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

public V get(Object key) {
  if (key == null) throw new NullPointerException();
  K k = (K)key;
  return (!inBounds(k)) ? null : m.get(k);
}

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

public RegionFailedOpen getFailedOpen(final RegionInfo regionInfo) {
 return regionFailedOpen.get(regionInfo.getRegionName());
}

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

long getMaxOffset(long segmentOffset) {
  DispatchLogSegment segment = (DispatchLogSegment) segments.get(segmentOffset);
  if (null == segment) {
    return 0;
  }
  return segment.getWrotePosition();
}

代码示例来源:origin: lealone/Lealone

@Override
public V get(K key) {
  Object v = buffer.get(key);
  if (v == null)
    v = map.get(key);
  return (V) v;
}

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

private V load(K key) {
  V val = map.get(key);
  if (val == null) {
    val = cacheLoader.load(key);
    if (val == null) {
      throw new NullPointerException("Null value for key " + key);
    }
    ensureCapacity();
    map.put(key, val);
    ++size;
  }
  return val;
}

代码示例来源: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: apache/hive

private TagState getTagState(String tag) {
 TagState state = tagInfo.get(tag);
 if (state == null) {
  state = new TagState(tag);
  TagState old = tagInfo.putIfAbsent(tag, state);
  state = (old == null) ? state : old;
 }
 return state;
}

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

@Override
public Entry getEntry(Object key) {
 if (map.containsKey(key)) {
  return new EntryImpl(toDeserializable(key), (CachedDeserializable) map.get(key));
 } else {
  return null;
 }
}

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

private DelaySegment<T> allocNewSegment(long offset) {
  long baseOffset = resolveSegment(offset, segmentScale);
  if (segments.containsKey(baseOffset)) {
    return segments.get(baseOffset);
  }
  return allocSegment(baseOffset);
}

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

boolean appendData(long startOffset, long baseOffset, ByteBuffer body) {
  DispatchLogSegment segment = (DispatchLogSegment) segments.get(baseOffset);
  if (null == segment) {
    segment = (DispatchLogSegment) allocSegment(baseOffset);
    segment.fillPreBlank(startOffset);
  }
  return segment.appendData(startOffset, body);
}

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

public RegionState getRegionTransitionState(RegionInfo hri) {
 RegionStateNode node = regionInTransition.get(hri);
 if (node == null) {
  return null;
 }
 node.lock();
 try {
  return node.isInTransition() ? node.toRegionState() : null;
 } finally {
  node.unlock();
 }
}

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

public RegionFailedOpen addToFailedOpen(final RegionStateNode regionNode) {
 final byte[] key = regionNode.getRegionInfo().getRegionName();
 RegionFailedOpen node = regionFailedOpen.get(key);
 if (node == null) {
  RegionFailedOpen newNode = new RegionFailedOpen(regionNode);
  RegionFailedOpen oldNode = regionFailedOpen.putIfAbsent(key, newNode);
  node = oldNode != null ? oldNode : newNode;
 }
 return node;
}

代码示例来源:origin: apache/incubator-druid

@Override
public void dropSegment(DataSegment segment, LoadPeonCallback callback)
{
 synchronized (lock) {
  if (stopped) {
   log.warn(
     "Server[%s] cannot drop segment[%s] because load queue peon is stopped.",
     serverId,
     segment.getId()
   );
   callback.execute();
   return;
  }
  SegmentHolder holder = segmentsToDrop.get(segment);
  if (holder == null) {
   log.debug("Server[%s] to drop segment[%s] queued.", serverId, segment.getId());
   segmentsToDrop.put(segment, new DropSegmentHolder(segment, callback));
   processingExecutor.execute(this::doSegmentManagement);
  } else {
   holder.addCallback(callback);
  }
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
public void loadSegment(DataSegment segment, LoadPeonCallback callback)
{
 synchronized (lock) {
  if (stopped) {
   log.warn(
     "Server[%s] cannot load segment[%s] because load queue peon is stopped.",
     serverId,
     segment.getId()
   );
   callback.execute();
   return;
  }
  SegmentHolder holder = segmentsToLoad.get(segment);
  if (holder == null) {
   log.debug("Server[%s] to load segment[%s] queued.", serverId, segment.getId());
   segmentsToLoad.put(segment, new LoadSegmentHolder(segment, callback));
   processingExecutor.execute(this::doSegmentManagement);
  } else {
   holder.addCallback(callback);
  }
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
public void loadSegment(final DataSegment segment, final LoadPeonCallback callback)
{
 synchronized (lock) {
  if ((currentlyProcessing != null) &&
    currentlyProcessing.getSegmentId().equals(segment.getId())) {
   if (callback != null) {
    currentlyProcessing.addCallback(callback);
   }
   return;
  }
 }
 synchronized (lock) {
  final SegmentHolder existingHolder = segmentsToLoad.get(segment);
  if (existingHolder != null) {
   if ((callback != null)) {
    existingHolder.addCallback(callback);
   }
   return;
  }
 }
 log.debug("Asking server peon[%s] to load segment[%s]", basePath, segment.getId());
 queuedSize.addAndGet(segment.getSize());
 segmentsToLoad.put(segment, new SegmentHolder(segment, LOAD, Collections.singletonList(callback)));
}

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

@Test
public void testReplace1() throws Exception {
 for (Map.Entry<Long, Long> e: csm.entrySet()) {
  Long newValue = ThreadLocalRandom.current().nextLong();
  assertEquals(csm.replace(e.getKey(), e.getValue() + 1, newValue),
    m.replace(e.getKey(), e.getValue() + 1, newValue));
  assertEquals(csm.replace(e.getKey(), e.getValue(), newValue),
    m.replace(e.getKey(), e.getValue(), newValue));
  assertEquals(newValue, m.get(e.getKey()));
  assertEquals(csm.get(e.getKey()), m.get(e.getKey()));
 }
 assertEquals(null, m.replace(MAX_RAND + 100L, ThreadLocalRandom.current().nextLong()));
}

相关文章

ConcurrentSkipListMap类方法