
water.util.IcedHashMap Maven / Gradle / Ivy
package water.util;
import water.AutoBuffer;
import water.Freezable;
import water.H2O;
import water.Iced;
import water.nbhm.NonBlockingHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
/** Iced / Freezable NonBlockingHashMap. Delegates to a NonBlockingHashMap for
* all its operations. Inspired by water.parser.Categorical.
*/
public class IcedHashMap extends IcedHashMapBase implements ConcurrentMap {
transient NonBlockingHashMap _map;
public IcedHashMap() { init(); }
@Override protected Map map() { return _map; }
@Override protected Map init() { return _map = new NonBlockingHashMap<>(); }
public V putIfAbsent(K key, V value) { return _map.putIfAbsent(key, value); }
public boolean remove(Object key, Object value) { return _map.remove(key, value); }
public boolean replace(K key, V oldValue, V newValue) { return _map.replace(key, oldValue, newValue); }
public V replace(K key, V value) { return _map.replace(key, value); }
public K getk(K key) { return _map.getk(key); }
// Map-writing optimized for NBHM
@Override protected void writeMap(AutoBuffer ab, int mode) {
// For faster K/V store walking get the NBHM raw backing array,
// and walk it directly.
Object[] kvs = _map.raw_array();
// Start the walk at slot 2, because slots 0,1 hold meta-data
// In the raw backing array, Keys and Values alternate in slots
// Ignore tombstones and Primes and null's
switch( mode ) {
case 1: //
for( int i=2; i
for( int i=2; i
for( int i=2; i
for( int i=2; i
for( int i=2;i
for( int i=2;i {}
public static class IcedHashMapStringObject extends IcedHashMap {}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy