/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Long</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Long put( K key, Long value ) { if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) ); return wrapValue( _map.put( key, unwrapValue( value ) ) ); }
if ( that.size() != this.size() ) { return false; long value = iter.value(); if ( value == no_entry_value ) { if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) { if ( value != that.get( key ) ) { return false;
@Override public boolean execute(String activityName, long latestAllocatedMemory) { runningAllocationTotals.adjustOrPutValue(activityName, latestAllocatedMemory, latestAllocatedMemory); return true; } }
/** * Retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ public Long get( Object key ) { long v = _map.get( key ); // There may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if ( v == _map.getNoEntryValue() ) { return null; } else { return wrapValue( v ); } }
/** * Creates a new <code>TObjectLongHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TObjectLongMap</tt> to be copied. */ public TObjectLongHashMap( TObjectLongMap<? extends K> map ) { this( map.size(), 0.5f, map.getNoEntryValue() ); if ( map instanceof TObjectLongHashMap ) { TObjectLongHashMap hashmap = ( TObjectLongHashMap ) map; this._loadFactor = hashmap._loadFactor; this.no_entry_value = hashmap.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( long ) 0 ) { Arrays.fill( _values, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } putAll( map ); }
if (recentlyRequestedWorkers.containsKey(graphId) && recentlyRequestedWorkers.get(graphId) >= System.currentTimeMillis() - WORKER_STARTUP_TIME){ LOG.info("workers still starting on graph {}, not starting more", graphId); return; i.setTags(tags); }); recentlyRequestedWorkers.put(graphId, System.currentTimeMillis()); LOG.info("Requesting {} workers", nWorkers);
public boolean forEachEntry( TObjectLongProcedure<? super K> procedure ) { synchronized( mutex ) { return m.forEachEntry( procedure ); } } public void transformValues( TLongFunction function ) {
public TObjectLongIterator<K> iterator() { return m.iterator(); // Must be manually synched by user! }
public Set<K> keySet() { if ( keySet == null ) keySet = Collections.unmodifiableSet( m.keySet() ); return keySet; } public Object[] keys() { return m.keys(); }
/** * Empties the map. */ public void clear() { this._map.clear(); }
/** * Indicates whether map has any entries. * * @return true if the map is empty */ public boolean isEmpty() { return this._map.size() == 0; }
public long put( K key, long value ) { synchronized( mutex ) { return m.put( key, value ); } } public long remove( Object key ) {
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey( Object key ) { return _map.containsKey( key ); }
@Override public boolean execute(String activityName, long expiredExecutionTime) { runningExecutionTotals.adjustValue(activityName, -expiredExecutionTime); return true; } }
public long get( Object key ) { synchronized( mutex ) { return m.get( key ); } }
private void apply_lookback_(ExpressionLookBack lookBack) { final TLongHashSet retainTs = lookBack.filter(new ForwardIterator<>(timestamps.stream().mapToObj(TSCollectionImpl::new).iterator())) .map(TimeSeriesCollection::getTimestamp) .mapToLong(DateTime::getMillis) .collect(TLongHashSet::new, TLongHashSet::add, TLongHashSet::addAll); timestamps.retainAll(retainTs); data.values().forEach(tsvChain -> tsvChain.retainAll(retainTs)); // Drop inactive groups. final long oldestTs = timestamps.backLong(); activeGroups.retainEntries((group, ts) -> ts >= oldestTs); data.keySet().retainAll(activeGroups.keySet()); }
public static long getGCTimeDiff(final List<GarbageCollectorMXBean> gcBeans, final TObjectLongMap lastValues) { long gcTime = 0; for (GarbageCollectorMXBean gcBean : gcBeans) { long prevVal = lastValues.get(gcBean); long currVal = gcBean.getCollectionTime(); gcTime += currVal - prevVal; lastValues.put(gcBean, currVal); } return gcTime; }
/** {@inheritDoc} */ public void putAll( TObjectLongMap<? extends K> map ){ map.forEachEntry( PUT_ALL_PROC ); }
public TObjectLongIterator<K> iterator() { return new TObjectLongIterator<K>() { TObjectLongIterator<K> iter = m.iterator(); public K key() { return iter.key(); } public long value() { return iter.value(); } public void advance() { iter.advance(); } public boolean hasNext() { return iter.hasNext(); } public long setValue( long val ) { throw new UnsupportedOperationException(); } public void remove() { throw new UnsupportedOperationException(); } }; }