public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NO_ENTRY_VALUE no_entry_value = in.readLong(); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { //noinspection unchecked K key = ( K ) in.readObject(); long val = in.readLong(); put(key, val); } }
@Override public void rollCycle() { executionData.add(currentExecutionData); allocationData.add(currentAllocationData); spikeData.forEachEntry(decayLargestExecutionTime); currentExecutionData.forEachEntry(updateExecutionTimeTotalAndSpikeData); currentAllocationData.forEachEntry(updateAllocatedMemoryTotal); while (executionData.size() > RETAINED_CYCLES) { executionData.get(0).forEachEntry(removeExpiredExecutionTimeValueFromTotal); executionData.remove(0); } while (allocationData.size() > RETAINED_CYCLES) { allocationData.get(0).forEachEntry(removeExpiredAllocatedMemoryValueFromTotal); allocationData.remove(0); } currentExecutionData = new TObjectLongHashMap<>(); currentAllocationData = new TObjectLongHashMap<>(); }
/** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObjectLongProcedure<K>() { private boolean first = true; public boolean execute( K key, long value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObjectLongHashMap
@SuppressWarnings({"unchecked"}) public boolean remove( Object o ) { return removeElement( (E) o ); }
public boolean execute(K key, long value) { put(key, value); return true; } };
/** {@inheritDoc} */ public long[] values() { long[] vals = new long[size()]; long[] v = _values; Object[] keys = _set; for ( int i = v.length, j = 0; i-- > 0; ) { if ( keys[i] != FREE && keys[i] != REMOVED ) { vals[j++] = v[i]; } } return vals; }
public void addAll(TscStreamReductor other) { timestamps.addAll(other.timestamps); other.groups.forEachEntry((group, ts) -> { if (groups.get(group) < ts) groups.put(group, ts); return true; }); } }
/** {@inheritDoc} */ public long get( Object key ) { int index = index( key ); return index < 0 ? no_entry_value : _values[index]; }
/** {@inheritDoc} */ public boolean containsKey( Object key ) { return contains( key ); }
public void add(TimeSeriesCollection tsc) { final long tsMillis = tsc.getTimestamp().getMillis(); timestamps.add(tsMillis); final Set<GroupName> updateGroups = tsc.getGroups(group -> !groups.containsKey(group) || tsMillis > groups.get(group)); updateGroups.forEach(group -> groups.put(group, tsMillis)); }
/** * Executes <tt>procedure</tt> for each key in the map. * * @param procedure a <code>TObjectProcedure</code> value * @return false if the loop over the keys terminated because * the procedure returned false for some key. */ public boolean forEachKey( TObjectProcedure<? super K> procedure ) { return forEach( procedure ); }
/** {@inheritDoc} */ @SuppressWarnings({"RedundantCast"}) public boolean increment( K key ) { //noinspection RedundantCast return adjustValue( key, (long)1 ); }
/** {@inheritDoc} */ public long put( K key, long value ) { int index = insertionIndex( key ); return doPut( key, value, index ); }
/** {@inheritDoc} */ public void putAll( Map<? extends K, ? extends Long> map ) { Set<? extends Map.Entry<? extends K,? extends Long>> set = map.entrySet(); for ( Map.Entry<? extends K,? extends Long> entry : set ) { put( entry.getKey(), entry.getValue() ); } }
/** {@inheritDoc} */ public Object[] keys() { //noinspection unchecked K[] keys = ( K[] ) new Object[size()]; Object[] k = _set; for ( int i = k.length, j = 0; i-- > 0; ) { if ( k[i] != FREE && k[i] != REMOVED ) { //noinspection unchecked keys[j++] = ( K ) k[i]; } } return keys; }