congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TreeMap.headMap
Code IndexAdd Tabnine to your IDE (free)

How to use
headMap
method
in
java.util.TreeMap

Best Java code snippets using java.util.TreeMap.headMap (Showing top 20 results out of 909)

origin: commons-collections/commons-collections

/**
 * Return a view of the portion of this map whose keys are strictly
 * less than the specified key.
 *
 * @param key Key higher than any in the returned map
 * @return a head map
 */
public SortedMap headMap(Object key) {
  if (fast) {
    return (map.headMap(key));
  } else {
    synchronized (map) {
      return (map.headMap(key));
    }
  }
}
origin: wildfly/wildfly

/**
 * Return a view of the portion of this map whose keys are strictly
 * less than the specified key.
 *
 * @param key Key higher than any in the returned map
 * @return a head map
 */
public SortedMap headMap(Object key) {
  if (fast) {
    return (map.headMap(key));
  } else {
    synchronized (map) {
      return (map.headMap(key));
    }
  }
}
origin: jenkinsci/jenkins

/**
 * Splits the range set at the given timestamp (if it hasn't been split yet)
 */
private void splitAt(long t) {
  if (data.containsKey(t)) return; // already split at this timestamp
  SortedMap<Long, int[]> head = data.headMap(t);
  int v = head.isEmpty() ? 0 : data.get(head.lastKey())[0];
  data.put(t, new int[]{v});
}
origin: alibaba/jstorm

public Object getPreviousState(long txid) {
  SortedMap<Long, Object> prevMap = _curr.headMap(txid);
  if(prevMap.isEmpty()) return null;
  else return prevMap.get(prevMap.lastKey());
}

origin: apache/storm

public Object getPreviousState(long txid) {
  final SortedMap<Long, Object> prevMap = _curr.headMap(txid);
  Object state;
  if (prevMap.isEmpty()) {
    state = null;
  } else {
    state = prevMap.get(prevMap.lastKey());
  }
  LOG.debug("Getting previous [state = {}], [txid = {}]", state, txid);
  LOG.trace("[{}]", this);
  return state;
}
origin: alibaba/jstorm

public void cleanupBefore(BigInteger txid) {
  Set<BigInteger> toDelete = new HashSet<>();
  toDelete.addAll(_curr.headMap(txid).keySet());
  for (BigInteger tx : toDelete) {
    _curr.remove(tx);
    _state.delete(txPath(tx));
  }
}
origin: goldmansachs/gs-collections

public MutableSortedMap<K, V> headMap(K toKey)
{
  return SortedMapAdapter.adapt(this.treeMap.headMap(toKey));
}
origin: eclipse/eclipse-collections

@Override
public MutableSortedMap<K, V> headMap(K toKey)
{
  return SortedMapAdapter.adapt(this.treeMap.headMap(toKey));
}
origin: eclipse/eclipse-collections

@Override
public MutableSortedMap<K, V> headMap(K toKey)
{
  return SortedMapAdapter.adapt(this.treeMap.headMap(toKey));
}
origin: apache/storm

private TreeMap<Long, Integer> getStoredCurrAttempts(long currTransaction, int maxBatches) {
  TreeMap<Long, Integer> ret = new TreeMap<Long, Integer>();
  for (TransactionalState state : _states) {
    Map<Object, Number> attempts = (Map) state.getData(CURRENT_ATTEMPTS);
    if (attempts == null) {
      attempts = new HashMap();
    }
    for (Entry<Object, Number> e : attempts.entrySet()) {
      // this is because json doesn't allow numbers as keys...
      // TODO: replace json with a better form of encoding
      Number txidObj;
      if (e.getKey() instanceof String) {
        txidObj = Long.parseLong((String) e.getKey());
      } else {
        txidObj = (Number) e.getKey();
      }
      long txid = ((Number) txidObj).longValue();
      int attemptId = ((Number) e.getValue()).intValue();
      Integer curr = ret.get(txid);
      if (curr == null || attemptId > curr) {
        ret.put(txid, attemptId);
      }
    }
  }
  ret.headMap(currTransaction).clear();
  ret.tailMap(currTransaction + maxBatches - 1).clear();
  return ret;
}
origin: alibaba/mdrill

public void cleanupBefore(BigInteger txid) {
  SortedMap<BigInteger, Object> toDelete = _curr.headMap(txid);
  for(BigInteger tx: new HashSet<BigInteger>(toDelete.keySet())) {
    _curr.remove(tx);
    _state.delete(txPath(tx));
  }
}

origin: apache/storm

public void cleanupBefore(long txid) {
  SortedMap<Long, Object> toDelete = _curr.headMap(txid);
  for (long tx : new HashSet<Long>(toDelete.keySet())) {
    _curr.remove(tx);
    try {
      _state.delete(txPath(tx));
    } catch (RuntimeException e) {
      // Ignore NoNodeExists exceptions because when sync() it may populate _curr with stale data since
      // zookeeper reads are eventually consistent.
      if (!Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
        throw e;
      }
    }
  }
}
origin: apache/usergrid

/**
 * Get all shards <= this one in descending order
 */
public Iterator<ShardEntryGroup> getShards( final Long maxShard ) {
  final Long firstKey = shards.floorKey( maxShard );
  return Collections.unmodifiableCollection( shards.headMap( firstKey, true ).descendingMap().values()).iterator();
}
origin: apache/storm

public Object getState(long txid, StateInitializer init) {
  if (!_curr.containsKey(txid)) {
    SortedMap<Long, Object> prevMap = _curr.headMap(txid);
    SortedMap<Long, Object> afterMap = _curr.tailMap(txid);
    Long prev = null;
    if (!prevMap.isEmpty()) {
      prev = prevMap.lastKey();
    }
    Object data;
    if (afterMap.isEmpty()) {
      Object prevData;
      if (prev != null) {
        prevData = _curr.get(prev);
      } else {
        prevData = null;
      }
      data = init.init(txid, prevData);
    } else {
      data = null;
    }
    _curr.put(txid, data);
    _state.setData(txPath(txid), data);
  }
  Object state = _curr.get(txid);
  LOG.debug("Getting or initializing state. [txid = {}] => [state = {}]", txid, state);
  LOG.trace("[{}]", this);
  return state;
}
origin: alibaba/jstorm

public void cleanupBefore(long txid) {
  SortedMap<Long, Object> toDelete = _curr.headMap(txid);
  for(long tx: new HashSet<>(toDelete.keySet())) {
    _curr.remove(tx);
    try {
      _state.delete(txPath(tx));
    } catch(RuntimeException e) {
      // Ignore NoNodeExists exceptions because when sync() it may populate _curr with stale data since
      // zookeeper reads are eventually consistent.
      if(!Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
        throw e;
      }
    }
  }
}

origin: alibaba/jstorm

public Object getState(long txid, StateInitializer init) {
  if(!_curr.containsKey(txid)) {
    SortedMap<Long, Object> prevMap = _curr.headMap(txid);
    SortedMap<Long, Object> afterMap = _curr.tailMap(txid);            
    
    Long prev = null;
    if(!prevMap.isEmpty()) prev = prevMap.lastKey();            
    
    Object data;
    if(afterMap.isEmpty()) {
      Object prevData;
      if(prev!=null) {
        prevData = _curr.get(prev);
      } else {
        prevData = null;
      }
      data = init.init(txid, prevData);
    } else {
      data = null;
    }
    _curr.put(txid, data);
    _state.setData(txPath(txid), data);
  }
  return _curr.get(txid);
}

origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public int named(String name) {
  return instrumentedMethod.getStackSize()
      + exitType.getStackSize().getSize()
      + StackSize.of(namedTypes.headMap(name).values());
}
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public int named(String name) {
  return instrumentedMethod.getStackSize()
      + exitType.getStackSize().getSize()
      + StackSize.of(namedTypes.headMap(name).values());
}
origin: apache/storm

@Override
public void execute(BatchInfo info, Tuple input) {
  // there won't be a BatchInfo for the success stream
  TransactionAttempt attempt = (TransactionAttempt) input.getValue(0);
  if (input.getSourceStreamId().equals(MasterBatchCoordinator.COMMIT_STREAM_ID)) {
    if (attempt.equals(_activeBatches.get(attempt.getTransactionId()))) {
      ((ICommitterTridentSpout.Emitter) _emitter).commit(attempt);
      _activeBatches.remove(attempt.getTransactionId());
    } else {
      throw new FailedException("Received commit for different transaction attempt");
    }
  } else if (input.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {
    // valid to delete before what's been committed since 
    // those batches will never be accessed again
    _activeBatches.headMap(attempt.getTransactionId()).clear();
    _emitter.success(attempt);
  } else {
    _collector.setBatch(info.batchId);
    _emitter.emitBatch(attempt, input.getValue(1), _collector);
    _activeBatches.put(attempt.getTransactionId(), attempt);
  }
}
origin: alibaba/jstorm

@Override
public void execute(BatchInfo info, Tuple input) {
  // there won't be a BatchInfo for the success stream
  TransactionAttempt attempt = (TransactionAttempt) input.getValue(0);
  if (input.getSourceStreamId().equals(MasterBatchCoordinator.COMMIT_STREAM_ID)) {
    if (attempt.equals(_activeBatches.get(attempt.getTransactionId()))) {
      ((ICommitterTridentSpout.Emitter) _emitter).commit(attempt);
      _activeBatches.remove(attempt.getTransactionId());
    } else {
      throw new FailedException("Received commit for different transaction attempt");
    }
  } else if (input.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {
    // valid to delete before what's been committed since
    // those batches will never be accessed again
    _activeBatches.headMap(attempt.getTransactionId()).clear();
    _emitter.success(attempt);
  } else {
    _collector.setBatch(info.batchId);
    _emitter.emitBatch(attempt, input.getValue(1), _collector);
    _activeBatches.put(attempt.getTransactionId(), attempt);
  }
}
java.utilTreeMapheadMap

Popular methods of TreeMap

  • <init>
    Constructs a new tree map containing the same mappings and using the same ordering as the specified
  • put
    Associates the specified value with the specified key in this map. If the map previously contained a
  • get
    Returns the value to which the specified key is mapped, or null if this map contains no mapping for
  • entrySet
    Returns a Set view of the mappings contained in this map. The set's iterator returns the entries in
  • values
    Returns a Collection view of the values contained in this map. The collection's iterator returns the
  • size
    Returns the number of key-value mappings in this map.
  • keySet
    Returns a Set view of the keys contained in this map. The set's iterator returns the keys in ascendi
  • remove
    Removes the mapping for this key from this TreeMap if present.
  • containsKey
    Returns true if this map contains a mapping for the specified key.
  • isEmpty
  • clear
    Removes all of the mappings from this map. The map will be empty after this call returns.
  • firstKey
  • clear,
  • firstKey,
  • putAll,
  • lastKey,
  • firstEntry,
  • tailMap,
  • lastEntry,
  • floorEntry,
  • subMap

Popular in Java

  • Start an intent from android
  • runOnUiThread (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getApplicationContext (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now