@Override public String put(String key, String value) { if (key == null || value == null) { LOG.error(new Exception("Nulls are not allowed")); return null; } if (key.isEmpty()) { // Windows: passing an environment variable with empty name causes "CreateProcess error=87, The parameter is incorrect" LOG.warn("Skipping environment variable with empty name, value: " + value); return null; } return super.put(key, value); }
/** * Pruning duplicates reduces memory pressure from hprof bloat added in Marshmallow. */ void deduplicateGcRoots(Snapshot snapshot) { // THashMap has a smaller memory footprint than HashMap. final THashMap<String, RootObj> uniqueRootMap = new THashMap<>(); final Collection<RootObj> gcRoots = snapshot.getGCRoots(); for (RootObj root : gcRoots) { String key = generateRootKey(root); if (!uniqueRootMap.containsKey(key)) { uniqueRootMap.put(key, root); } } // Repopulate snapshot with unique GC roots. gcRoots.clear(); uniqueRootMap.forEach(new TObjectProcedure<String>() { @Override public boolean execute(String key) { return gcRoots.add(uniqueRootMap.get(key)); } }); }
/** * Caches some information about this graph that is specific to * a given type of inferencer (e.g., a junction tree). * @param inferencer Class of inferencer that can use this * information * @param info The information to cache. * @see #getInferenceCache */ public void setInferenceCache (Class inferencer, Object info) { inferenceCaches.put (inferencer, info); }
/** * Caches some information about this graph that is specific to * a given type of inferencer (e.g., a junction tree). * @param inferencer Class of inferencer that can use this * information * @param info The information to cache. * @see #getInferenceCache */ public void setInferenceCache (Class inferencer, Object info) { inferenceCaches.put (inferencer, info); }
/** * Caches some information about this graph that is specific to * a given type of inferencer (e.g., a junction tree). * @param inferencer Class of inferencer that can use this * information * @param info The information to cache. * @see #getInferenceCache */ public void setInferenceCache (Class inferencer, Object info) { inferenceCaches.put (inferencer, info); }
/** Adds <tt>key</tt> as a key with an empty list as a value. */ public void add (Object key) { backing.put (key, new ArrayList ()); }
/** * Resets the value at the specified key to {@code null} * @param key * @return The old value at the specified key */ public V reset(K key) { V oldValue = this.get(key); super.put(key, null); return oldValue; } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int size = stream.readInt(); setUp(size); while (size-- > 0) { Object key = stream.readObject(); Object val = stream.readObject(); put(key, val); } } } // THashMap
/** * copies the key/value mappings in <tt>map</tt> into this map. * * @param map a <code>Map</code> value */ public void putAll(Map map) { ensureCapacity(map.size()); // could optimize this for cases when map instanceof THashMap for (Iterator i = map.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry)i.next(); put(e.getKey(),e.getValue()); } }
public Object create() { THashMap map = new THashMap(); for (int i = 0; i < 1000; i++) { Integer x = new Integer(i); map.put(x,x); } return map; } }
private Object varFromName (String name, boolean preTwiddle) { if (nbrRegex.matcher(name).matches ()) { return new Double (Double.parseDouble (name)); } else if (name2var.contains (name)) { return name2var.get (name); } else { Variable var = (preTwiddle) ? new Variable (2) : new Variable (Variable.CONTINUOUS); var.setLabel (name); name2var.put (name, var); return var; } }
private Object varFromName (String name, boolean preTwiddle) { if (nbrRegex.matcher(name).matches ()) { return new Double (Double.parseDouble (name)); } else if (name2var.contains (name)) { return name2var.get (name); } else { Variable var = (preTwiddle) ? new Variable (2) : new Variable (Variable.CONTINUOUS); var.setLabel (name); name2var.put (name, var); return var; } }
private Object varFromName (String name, boolean preTwiddle) { if (nbrRegex.matcher(name).matches ()) { return new Double (Double.parseDouble (name)); } else if (name2var.contains (name)) { return name2var.get (name); } else { Variable var = (preTwiddle) ? new Variable (2) : new Variable (Variable.CONTINUOUS); var.setLabel (name); name2var.put (name, var); return var; } }
public K put(int one, V two, K val) { THashMap<V,K> firstVal = map.get(one); if(firstVal==null) { firstVal = new THashMap<V,K>(); map.put(one, firstVal); } return firstVal.put(two, val); }
public TIntObjectHashMap lookupProjectionCache (VarSet varSet) { List sizes = new ArrayList (varSet.size ()); for (int vi = 0; vi < varSet.size (); vi++) { sizes.add (varSet.get(vi).getNumOutcomes ()); } TIntObjectHashMap result = (TIntObjectHashMap) allProjectionCaches.get (sizes); if (result == null) { result = new TIntObjectHashMap (); allProjectionCaches.put (sizes, result); } return result; } }
public TIntObjectHashMap lookupProjectionCache (VarSet varSet) { List sizes = new ArrayList (varSet.size ()); for (int vi = 0; vi < varSet.size (); vi++) { sizes.add (varSet.get(vi).getNumOutcomes ()); } TIntObjectHashMap result = (TIntObjectHashMap) allProjectionCaches.get (sizes); if (result == null) { result = new TIntObjectHashMap (); allProjectionCaches.put (sizes, result); } return result; } }
/** Insert a term into this document, occurs at given block id */ public void insert(String t, int blockId) { insert(t); TIntHashSet blockids = null; if ((blockids = term_blocks.get(t)) == null) { term_blocks.put(t, blockids = new TIntHashSet(/*TODO */)); } blockids.add(blockId); blockCount++; }
/** Insert a term into this document, occurs at given block id, and in the given fields */ public void insert(String t, int[] fieldIds, int blockId) { super.insert(t, fieldIds); TIntHashSet blockids = null; if ((blockids = term_blocks.get(t)) == null) { term_blocks.put(t, blockids = new TIntHashSet(/*TODO */)); } blockids.add(blockId); blockCount++; }
/** Insert a term into this document tf times, occurs at given block id, and in the given fields */ public void insert(int tf, String t, int[] fieldIds, int blockId) { super.insert(tf, t, fieldIds); TIntHashSet blockids = null; if ((blockids = term_blocks.get(t)) == null) { term_blocks.put(t, blockids = new TIntHashSet(/*TODO */)); } blockids.add(blockId); blockCount++; }
/** Insert a term into this document, occurs at given block id, and in the given field */ public void insert(String t, int fieldId, int blockId) { super.insert(t, fieldId); TIntHashSet blockids = null; if ((blockids = term_blocks.get(t)) == null) { term_blocks.put(t, blockids = new TIntHashSet(/*TODO */)); } blockids.add(blockId); blockCount++; }