aa
com.cliffc.aa.tvar.UQNodes Class Reference
Inheritance diagram for com.cliffc.aa.tvar.UQNodes:
[legend]
Collaboration diagram for com.cliffc.aa.tvar.UQNodes:
[legend]

Public Member Functions

UQNodes add (Node tn)
 
UQNodes addAll (UQNodes uq)
 
void clear ()
 Removes all of the mappings from this map. More...
 
void clear (boolean large)
 
NonBlockingHashMapLong< TypeV > clone ()
 Creates a shallow copy of this hashtable. More...
 
boolean contains (Object val)
 Legacy method testing if some key maps into the specified value in this table. More...
 
boolean containsKey (long key)
 Tests if the key in the table. More...
 
boolean containsKey (Object key)
 Auto-boxing version of containsKey(long). More...
 
boolean containsValue (Object val)
 Returns true if this Map maps one or more keys to the specified value. More...
 
Enumeration< TypeV > elements ()
 Returns an enumeration of the values in this table. More...
 
Set< Map.Entry< Long, TypeV > > entrySet ()
 Returns a Set view of the mappings contained in this map. More...
 
boolean equals (Object o)
 
final TypeV get (long key)
 Returns the value to which the specified key is mapped, or. More...
 
TypeV get (Object key)
 Auto-boxing version of get(long). More...
 
int hashCode ()
 
Enumeration< Long > keys ()
 Returns an enumeration of the auto-boxed keys in this table. More...
 
Set< Long > keySet ()
 Returns a Set view of the keys contained in this map; with care the keys may be iterated over without auto-boxing. More...
 
long[] keySetLong ()
 Keys as a long array. More...
 
final void print ()
 Verbose printout of table internals, useful for debugging. More...
 
TypeV put (long key, TypeV val)
 Maps the specified key to the specified value in the table. More...
 
TypeV put (Long key, TypeV val)
 Auto-boxing version of put. More...
 
TypeV putIfAbsent (long key, TypeV val)
 Atomically, do a put if-and-only-if the key is not mapped. More...
 
TypeV putIfAbsent (Long key, TypeV val)
 Auto-boxing version of putIfAbsent. More...
 
TypeV remove (long key)
 Removes the key (and its corresponding value) from this map. More...
 
boolean remove (long key, Object val)
 Atomically do a remove(long) if-and-only-if the key is mapped to a value which is equals to the given value. More...
 
TypeV remove (Object key)
 Auto-boxing version of remove(long). More...
 
boolean remove (Object key, Object Val)
 Auto-boxing version of remove(long,Object). More...
 
UQNodes rename (HashMap< Node, Node > map)
 
boolean replace (long key, TypeV oldValue, TypeV newValue)
 Atomically do a put(key,newValue) if-and-only-if the key is mapped a value which is equals to oldValue. More...
 
boolean replace (Long key, TypeV oldValue, TypeV newValue)
 Auto-boxing version of replace. More...
 
TypeV replace (long key, TypeV val)
 Atomically do a put(key,val) if-and-only-if the key is mapped to some value already. More...
 
TypeV replace (Long key, TypeV Val)
 Auto-boxing version of replace. More...
 
long reprobes ()
 Get and clear the current count of reprobes. More...
 
int size ()
 Returns the number of key-value mappings in this map. More...
 
Collection< TypeV > values ()
 Returns a Collection view of the values contained in this map. More...
 

Static Public Member Functions

static UQNodes make (Node tn)
 

Private Member Functions

final boolean CAS (final long offset, final Object old, final Object nnn)
 
void help_copy ()
 
void initialize (final int initial_sz)
 
void print2 ()
 
TypeV putIfMatch (long key, Object newVal, Object oldVal)
 
void readObject (java.io.ObjectInputStream s) throws IOException, ClassNotFoundException
 
void setHash ()
 
void writeObject (java.io.ObjectOutputStream s) throws IOException
 

Static Private Member Functions

static final int hash (long h)
 
static UQNodes intern ()
 
static void print2_impl (final int i, final long K, final Object V)
 
static void print_impl (final int i, final long K, final Object V)
 
static long rawIndex (final long[] ary, final int idx)
 
static long rawIndex (final Object[] ary, final int idx)
 
static int reprobe_limit (int len)
 

Private Attributes

transient CHM _chm
 
int _hash
 
transient long _last_resize_milli
 
final boolean _opt_for_space
 
transient ConcurrentAutoTable _reprobes
 
transient Object _val_1
 

Static Private Attributes

static final long _chm_offset
 
static final int _Lbase
 
static final int _Lscale
 
static final int _Obase
 
static final int _Oscale
 
static final long _val_1_offset
 
static UQNodes KEY = new UQNodes()
 
static final Object MATCH_ANY
 
static final int MIN_SIZE
 
static final int MIN_SIZE_LOG
 
static final long NO_KEY
 
static final Object NO_MATCH_OLD
 
static final int REPROBE_LIMIT
 
static final long serialVersionUID
 
static final Prime TOMBPRIME
 
static final Object TOMBSTONE
 
static final NonBlockingHashMap< UQNodes, UQNodesUQSETS = new NonBlockingHashMap<>()
 

Detailed Description

Definition at line 8 of file UQNodes.java.

Member Function Documentation

◆ add()

UQNodes com.cliffc.aa.tvar.UQNodes.add ( Node  tn)

Definition at line 36 of file UQNodes.java.

36  {
37  assert KEY.isEmpty();
38  assert !tn.is_dead();
39  if( get(tn._uid)!=null ) return this; // Already in there
40  // Fold them together
41  for( Node n : values() ) if( !n.is_dead() ) KEY.put(n._uid,n);
42  KEY.put(tn._uid,tn);
43  return intern();
44  }

References com.cliffc.aa.node.Node._uid, com.cliffc.aa.tvar.UQNodes.intern(), com.cliffc.aa.node.Node.is_dead(), com.cliffc.aa.tvar.UQNodes.KEY, com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put(), and com.cliffc.aa.util.NonBlockingHashMapLong< Node >.values().

Referenced by com.cliffc.aa.tvar.TV2._push_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addAll()

UQNodes com.cliffc.aa.tvar.UQNodes.addAll ( UQNodes  uq)

Definition at line 47 of file UQNodes.java.

47  {
48  assert KEY.isEmpty();
49  if( uq==null ) return this;
50 
51  // Get smaller in uq0
52  UQNodes uq0 = this;
53  UQNodes uq1 = uq;
54  if( uq1.size() < uq0.size() ) { uq0=uq; uq1=this; }
55  // See if all of smaller is in larger
56  boolean progress=false;
57  for( Node n : uq0.values() )
58  if( !n.is_dead() && uq1.get(n._uid)!=n )
59  { progress = true; break; }
60  if( !progress ) return uq1;
61 
62  // Fold them together
63  for( Node n : uq0.values() ) if( !n.is_dead() ) KEY.put(n._uid,n);
64  for( Node n : uq1.values() ) if( !n.is_dead() ) KEY.put(n._uid,n);
65 
66  return intern();
67  }

References com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.get(), com.cliffc.aa.tvar.UQNodes.intern(), com.cliffc.aa.tvar.UQNodes.KEY, com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put(), com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.size(), and com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.values().

Referenced by com.cliffc.aa.tvar.TV2.merge_deps(), and com.cliffc.aa.tvar.TV2.merge_ns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CAS()

final boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.CAS ( final long  offset,
final Object  old,
final Object  nnn 
)
privateinherited

Definition at line 119 of file NonBlockingHashMapLong.java.

119  {
120  return UNSAFE.compareAndSwapObject(this, offset, old, nnn );
121  }

◆ clear() [1/2]

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.clear
inherited

Removes all of the mappings from this map.

Definition at line 332 of file NonBlockingHashMapLong.java.

332  { // Smack a new empty table down
333  CHM newchm = new CHM(this,new ConcurrentAutoTable(),MIN_SIZE_LOG);
334  while( !CAS(_chm_offset,_chm,newchm) ) { /*Spin until the clear works*/}
336  }

◆ clear() [2/2]

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.clear ( boolean  large)
inherited

Definition at line 338 of file NonBlockingHashMapLong.java.

338  { // Smack a new empty table down
339  _chm.clear();
341  }

◆ clone()

Creates a shallow copy of this hashtable.

All the structure of the hashtable itself is copied, but the keys and values are not cloned. This is a relatively expensive operation.

Returns
a clone of the hashtable.

Definition at line 1290 of file NonBlockingHashMapLong.java.

1290  {
1291  try {
1292  // Must clone, to get the class right; NBHML might have been
1293  // extended so it would be wrong to just make a new NBHML.
1294  NonBlockingHashMapLong<TypeV> t = (NonBlockingHashMapLong<TypeV>) super.clone();
1295  // But I don't have an atomic clone operation - the underlying _kvs
1296  // structure is undergoing rapid change. If I just clone the _kvs
1297  // field, the CHM in _kvs[0] won't be in sync.
1298  //
1299  // Wipe out the cloned array (it was shallow anyways).
1300  t.clear();
1301  // Now copy sanely
1302  for( long K : keySetLong() )
1303  t.put(K,get(K));
1304  return t;
1305  } catch (CloneNotSupportedException e) {
1306  // this shouldn't happen, since we are Cloneable
1307  throw new InternalError();
1308  }
1309  }

◆ contains()

◆ containsKey() [1/2]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.containsKey ( long  key)
inherited

Tests if the key in the table.

Returns
true if the key is in the table

Definition at line 258 of file NonBlockingHashMapLong.java.

258 { return get(key) != null; }

◆ containsKey() [2/2]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.containsKey ( Object  key)
inherited

Auto-boxing version of containsKey(long).

Definition at line 386 of file NonBlockingHashMapLong.java.

386 { return (key instanceof Long) && containsKey(((Long) key).longValue()); }

◆ containsValue()

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.containsValue ( Object  val)
inherited

Returns true if this Map maps one or more keys to the specified value.

Note: This method requires a full internal traversal of the hash table and is much slower than containsKey.

Parameters
valvalue whose presence in this map is to be tested
Returns
true if this Map maps one or more keys to the specified value
Exceptions
NullPointerExceptionif the specified value is null

Definition at line 349 of file NonBlockingHashMapLong.java.

349  {
350  if( val == null ) return false;
351  if( val == _val_1 ) return true; // Key 0
352  for( TypeV V : values() )
353  if( V == val || V.equals(val) )
354  return true;
355  return false;
356  }

◆ elements()

Enumeration<TypeV> com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.elements
inherited

Returns an enumeration of the values in this table.

Returns
an enumeration of the values in this table
See also
values()

Definition at line 1102 of file NonBlockingHashMapLong.java.

1102 { return new SnapshotV(); }

◆ entrySet()

Set<Map.Entry<Long,TypeV> > com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.entrySet
inherited

Returns a Set view of the mappings contained in this map.

The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

The view's iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.

Warning: the iterator associated with this Set requires the creation of java.util.Map.Entry objects with each iteration. The org.jctools.maps.NonBlockingHashMap does not normally create or using java.util.Map.Entry objects so they will be created soley to support this iteration. Iterating using Map#keySet or Map#values will be more efficient. In addition, this version requires auto-boxing the keys.

Definition at line 1235 of file NonBlockingHashMapLong.java.

1235  {
1236  return new AbstractSet<Map.Entry<Long,TypeV>>() {
1237  public void clear ( ) { NonBlockingHashMapLong.this.clear( ); }
1238  public int size ( ) { return NonBlockingHashMapLong.this.size ( ); }
1239  public boolean remove( final Object o ) {
1240  if (!(o instanceof Map.Entry)) return false;
1241  final Map.Entry<?,?> e = (Map.Entry<?,?>)o;
1242  return NonBlockingHashMapLong.this.remove(e.getKey(), e.getValue());
1243  }
1244  public boolean contains(final Object o) {
1245  if (!(o instanceof Map.Entry)) return false;
1246  final Map.Entry<?,?> e = (Map.Entry<?,?>)o;
1247  TypeV v = get(e.getKey());
1248  return v != null && v.equals(e.getValue());
1249  }
1250  public Iterator<Map.Entry<Long,TypeV>> iterator() { return new SnapshotE(); }
1251  };
1252  }

◆ equals()

boolean com.cliffc.aa.tvar.UQNodes.equals ( Object  o)

Definition at line 89 of file UQNodes.java.

89  {
90  if( !(o instanceof UQNodes) ) return false;
91  UQNodes uq = (UQNodes)o;
92  assert _hash!=0 && uq._hash!=0;
93  if( _hash!=uq._hash ) return false;
94  if( size() != uq.size() ) return false;
95  for( Node n : values() )
96  if( n!=uq.get(n._uid) )
97  return false;
98  return true;
99  }

References com.cliffc.aa.tvar.UQNodes._hash, com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.get(), com.cliffc.aa.util.NonBlockingHashMapLong< Node >.size(), com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.size(), and com.cliffc.aa.util.NonBlockingHashMapLong< Node >.values().

Here is the call graph for this function:

◆ get() [1/2]

final TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.get ( long  key)
inherited

Returns the value to which the specified key is mapped, or.

null

if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key

k

to a value

v

such that

key==k

, then this method returns

v

; otherwise it returns

null

. (There can be at most one such mapping.)

Exceptions
NullPointerExceptionif the specified key is null

Definition at line 368 of file NonBlockingHashMapLong.java.

368  {
369  if( key == NO_KEY ) {
370  final Object V = _val_1;
371  return V == TOMBSTONE ? null : (TypeV)V;
372  }
373  final Object V = _chm.get_impl(key);
374  assert !(V instanceof Prime); // Never return a Prime
375  assert V != TOMBSTONE;
376  return (TypeV)V;
377  }

◆ get() [2/2]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.get ( Object  key)
inherited

Auto-boxing version of get(long).

Definition at line 380 of file NonBlockingHashMapLong.java.

380 { return (key instanceof Long) ? get (((Long)key).longValue()) : null; }

◆ hash()

static final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.hash ( long  h)
staticprivateinherited

Definition at line 416 of file NonBlockingHashMapLong.java.

416  {
417  h ^= (h>>>20) ^ (h>>>12);
418  h ^= (h>>> 7) ^ (h>>> 4);
419  h += h<<7; // smear low bits up high, for hashcodes that only differ by 1
420  return (int)h;
421  }

◆ hashCode()

int com.cliffc.aa.tvar.UQNodes.hashCode ( )

Definition at line 88 of file UQNodes.java.

88 { assert _hash!=0; return _hash; }

References com.cliffc.aa.tvar.UQNodes._hash.

◆ help_copy()

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.help_copy
privateinherited

Definition at line 403 of file NonBlockingHashMapLong.java.

403  {
404  // Read the top-level CHM only once. We'll try to help this copy along,
405  // even if it gets promoted out from under us (i.e., the copy completes
406  // and another KVS becomes the top-level copy).
407  CHM topchm = _chm;
408  if( topchm._newchm == null ) return; // No copy in-progress
409  topchm.help_copy_impl(false);
410  }

◆ initialize()

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.initialize ( final int  initial_sz)
privateinherited

Definition at line 242 of file NonBlockingHashMapLong.java.

242  {
243  if( initial_sz < 0 ) throw new IllegalArgumentException("initial_sz argument must be >= 0");
244  int i; // Convert to next largest power-of-2
245  for( i=MIN_SIZE_LOG; (1<<i) < initial_sz; i++ ) {/*empty*/}
246  _chm = new CHM(this,new ConcurrentAutoTable(),i);
247  _val_1 = TOMBSTONE; // Always as-if deleted
248  _last_resize_milli = System.currentTimeMillis();
249  }

◆ intern()

static UQNodes com.cliffc.aa.tvar.UQNodes.intern ( )
staticprivate

Definition at line 14 of file UQNodes.java.

14  {
15  KEY.setHash();
16  UQNodes uqset = UQSETS.get(KEY);
17  if( uqset==null ) {
18  UQSETS.put(uqset=KEY,KEY);
19  KEY=new UQNodes();
20  } else {
21  KEY.clear();
22  KEY._hash=0;
23  }
24  return uqset;
25  }

References com.cliffc.aa.tvar.UQNodes._hash, com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.clear(), com.cliffc.aa.tvar.UQNodes.KEY, com.cliffc.aa.tvar.UQNodes.setHash(), and com.cliffc.aa.tvar.UQNodes.UQSETS.

Referenced by com.cliffc.aa.tvar.UQNodes.add(), com.cliffc.aa.tvar.UQNodes.addAll(), com.cliffc.aa.tvar.UQNodes.make(), and com.cliffc.aa.tvar.UQNodes.rename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keys()

Returns an enumeration of the auto-boxed keys in this table.

Warning: this version will auto-box all returned keys.

Returns
an enumeration of the auto-boxed keys in this table
See also
keySet()

Definition at line 1152 of file NonBlockingHashMapLong.java.

1152 { return new IteratorLong(); }

◆ keySet()

Set<Long> com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.keySet
inherited

Returns a Set view of the keys contained in this map; with care the keys may be iterated over without auto-boxing.

The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

The view's iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.

Definition at line 1168 of file NonBlockingHashMapLong.java.

1168  {
1169  return new AbstractSet<Long> () {
1170  public void clear ( ) { NonBlockingHashMapLong.this.clear ( ); }
1171  public int size ( ) { return NonBlockingHashMapLong.this.size ( ); }
1172  public boolean contains( Object k ) { return NonBlockingHashMapLong.this.containsKey(k); }
1173  public boolean remove ( Object k ) { return NonBlockingHashMapLong.this.remove (k) != null; }
1174  public IteratorLong iterator() { return new IteratorLong(); }
1175  };
1176  }

◆ keySetLong()

long [] com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.keySetLong
inherited

Keys as a long array.

Array may be zero-padded if keys are concurrently deleted.

Definition at line 1180 of file NonBlockingHashMapLong.java.

1180  {
1181  long[] dom = new long[size()];
1182  IteratorLong i=(IteratorLong)keySet().iterator();
1183  int j=0;
1184  while( j < dom.length && i.hasNext() )
1185  dom[j++] = i.nextLong();
1186  return dom;
1187  }

◆ make()

static UQNodes com.cliffc.aa.tvar.UQNodes.make ( Node  tn)
static

Definition at line 28 of file UQNodes.java.

28  {
29  assert !tn.is_dead();
30  assert KEY.isEmpty();
31  KEY.put(tn._uid,tn);
32  return intern();
33  }

References com.cliffc.aa.node.Node._uid, com.cliffc.aa.tvar.UQNodes.intern(), com.cliffc.aa.node.Node.is_dead(), com.cliffc.aa.tvar.UQNodes.KEY, and com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put().

Referenced by com.cliffc.aa.tvar.TV2._push_update(), com.cliffc.aa.tvar.TV2.make(), com.cliffc.aa.tvar.TV2.make_base(), com.cliffc.aa.tvar.TV2.make_err(), and com.cliffc.aa.tvar.TV2.make_leaf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

final void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.print
inherited

Verbose printout of table internals, useful for debugging.


Definition at line 171 of file NonBlockingHashMapLong.java.

171  {
172  System.out.println("=========");
173  print_impl(-99,NO_KEY,_val_1);
174  _chm.print();
175  System.out.println("=========");
176  }

◆ print2()

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.print2
privateinherited

Definition at line 184 of file NonBlockingHashMapLong.java.

184  {
185  System.out.println("=========");
187  _chm.print();
188  System.out.println("=========");
189  }

◆ print2_impl()

static void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.print2_impl ( final int  i,
final long  K,
final Object  V 
)
staticprivateinherited

Definition at line 190 of file NonBlockingHashMapLong.java.

190  {
191  if( V != null && Prime.unbox(V) != TOMBSTONE )
192  print_impl(i,K,V);
193  }

◆ print_impl()

static void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.print_impl ( final int  i,
final long  K,
final Object  V 
)
staticprivateinherited

Definition at line 177 of file NonBlockingHashMapLong.java.

177  {
178  String p = (V instanceof Prime) ? "prime_" : "";
179  Object V2 = Prime.unbox(V);
180  String VS = (V2 == TOMBSTONE) ? "tombstone" : V2.toString();
181  System.out.println("["+i+"]=("+K+","+p+VS+")");
182  }

◆ put() [1/2]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put ( long  key,
TypeV  val 
)
inherited

Maps the specified key to the specified value in the table.

The value cannot be null.

The value can be retrieved by calling get with a key that is equal to the original key.

Parameters
keykey with which the specified value is to be associated
valvalue to be associated with the specified key
Returns
the previous value associated with key, or null if there was no mapping for key
Exceptions
NullPointerExceptionif the specified value is null

Definition at line 278 of file NonBlockingHashMapLong.java.

278 { return putIfMatch( key, val,NO_MATCH_OLD);}

◆ put() [2/2]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put ( Long  key,
TypeV  val 
)
inherited

Auto-boxing version of put.

Definition at line 392 of file NonBlockingHashMapLong.java.

392 { return put(key.longValue(),val); }

◆ putIfAbsent() [1/2]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.putIfAbsent ( long  key,
TypeV  val 
)
inherited

Atomically, do a put if-and-only-if the key is not mapped.

Useful to ensure that only a single mapping for the key exists, even if many threads are trying to create the mapping in parallel.

Returns
the previous value associated with the specified key, or null if there was no mapping for the key
Exceptions
NullPointerExceptionif the specified is value is null

Definition at line 286 of file NonBlockingHashMapLong.java.

286 { return putIfMatch( key, val,TOMBSTONE );}

◆ putIfAbsent() [2/2]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.putIfAbsent ( Long  key,
TypeV  val 
)
inherited

Auto-boxing version of putIfAbsent.

Definition at line 388 of file NonBlockingHashMapLong.java.

388 { return putIfAbsent( key.longValue(), val ); }

◆ putIfMatch()

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.putIfMatch ( long  key,
Object  newVal,
Object  oldVal 
)
privateinherited

Definition at line 312 of file NonBlockingHashMapLong.java.

312  {
313  if (oldVal == null || newVal == null) throw new NullPointerException();
314  if( key == NO_KEY ) {
315  Object curVal = _val_1;
316  if( oldVal == NO_MATCH_OLD || // Do we care about expected-Value at all?
317  curVal == oldVal || // No instant match already?
318  (oldVal == MATCH_ANY && curVal != TOMBSTONE) ||
319  oldVal.equals(curVal) ) { // Expensive equals check
320  if( !CAS(_val_1_offset,curVal,newVal) ) // One shot CAS update attempt
321  curVal = _val_1; // Failed; get failing witness
322  }
323  return curVal == TOMBSTONE ? null : (TypeV)curVal; // Return the last value present
324  }
325  final Object res = _chm.putIfMatch( key, newVal, oldVal );
326  assert !(res instanceof Prime);
327  assert res != null;
328  return res == TOMBSTONE ? null : (TypeV)res;
329  }

◆ rawIndex() [1/2]

static long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.rawIndex ( final long[]  ary,
final int  idx 
)
staticprivateinherited

Definition at line 108 of file NonBlockingHashMapLong.java.

108  {
109  assert idx >= 0 && idx < ary.length;
110  // Note the long-math requirement, to handle arrays of more than 2^31 bytes
111  // - or 2^28 - or about 268M - 8-byte pointer elements.
112  return _Lbase + ((long)idx * _Lscale);
113  }

◆ rawIndex() [2/2]

static long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.rawIndex ( final Object[]  ary,
final int  idx 
)
staticprivateinherited

Definition at line 100 of file NonBlockingHashMapLong.java.

100  {
101  assert idx >= 0 && idx < ary.length;
102  // Note the long-math requirement, to handle arrays of more than 2^31 bytes
103  // - or 2^28 - or about 268M - 8-byte pointer elements.
104  return _Obase + ((long)idx * _Oscale);
105  }

◆ readObject()

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.readObject ( java.io.ObjectInputStream  s) throws IOException, ClassNotFoundException
privateinherited

Definition at line 1270 of file NonBlockingHashMapLong.java.

1270  {
1271  s.defaultReadObject(); // Read nothing
1273  for (;;) {
1274  final long K = s.readLong();
1275  final TypeV V = (TypeV) s.readObject();
1276  if( K == NO_KEY && V == null ) break;
1277  put(K,V); // Insert with an offical put
1278  }
1279  }

◆ remove() [1/4]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.remove ( long  key)
inherited

Removes the key (and its corresponding value) from this map.

This method does nothing if the key is not in the map.

Returns
the previous value associated with key, or null if there was no mapping for key

Definition at line 292 of file NonBlockingHashMapLong.java.

292 { return putIfMatch( key,TOMBSTONE,NO_MATCH_OLD);}

◆ remove() [2/4]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.remove ( long  key,
Object  val 
)
inherited

Atomically do a remove(long) if-and-only-if the key is mapped to a value which is equals to the given value.

Exceptions
NullPointerExceptionif the specified value is null

Definition at line 297 of file NonBlockingHashMapLong.java.

297 { return putIfMatch( key,TOMBSTONE,val ) == val ;}

◆ remove() [3/4]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.remove ( Object  key)
inherited

Auto-boxing version of remove(long).

Definition at line 382 of file NonBlockingHashMapLong.java.

382 { return (key instanceof Long) ? remove (((Long)key).longValue()) : null; }

◆ remove() [4/4]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.remove ( Object  key,
Object  Val 
)
inherited

Auto-boxing version of remove(long,Object).

Definition at line 384 of file NonBlockingHashMapLong.java.

384 { return (key instanceof Long) && remove(((Long) key).longValue(), Val); }

◆ rename()

UQNodes com.cliffc.aa.tvar.UQNodes.rename ( HashMap< Node, Node map)

Definition at line 70 of file UQNodes.java.

70  {
71  assert KEY.isEmpty();
72  for( Node n : values() )
73  if( !n.is_dead() ) {
74  Node c = map.get(n);
75  if( c==null ) c = n;
76  KEY.put(c._uid,c);
77  }
78  return intern();
79  }

References com.cliffc.aa.node.Node._uid, com.cliffc.aa.tvar.UQNodes.intern(), com.cliffc.aa.tvar.UQNodes.KEY, com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.put(), and com.cliffc.aa.util.NonBlockingHashMapLong< Node >.values().

Referenced by com.cliffc.aa.tvar.TV2._rename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace() [1/4]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.replace ( long  key,
TypeV  oldValue,
TypeV  newValue 
)
inherited

Atomically do a put(key,newValue) if-and-only-if the key is mapped a value which is equals to oldValue.

Exceptions
NullPointerExceptionif the specified value is null

Definition at line 307 of file NonBlockingHashMapLong.java.

307  {
308  return putIfMatch( key, newValue, oldValue ) == oldValue;
309  }

◆ replace() [2/4]

boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.replace ( Long  key,
TypeV  oldValue,
TypeV  newValue 
)
inherited

Auto-boxing version of replace.

Definition at line 394 of file NonBlockingHashMapLong.java.

394  {
395  return replace(key.longValue(), oldValue, newValue);
396  }

◆ replace() [3/4]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.replace ( long  key,
TypeV  val 
)
inherited

Atomically do a put(key,val) if-and-only-if the key is mapped to some value already.

Exceptions
NullPointerExceptionif the specified value is null

Definition at line 302 of file NonBlockingHashMapLong.java.

302 { return putIfMatch( key, val,MATCH_ANY );}

◆ replace() [4/4]

TypeV com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.replace ( Long  key,
TypeV  Val 
)
inherited

Auto-boxing version of replace.

Definition at line 390 of file NonBlockingHashMapLong.java.

390 { return replace(key.longValue(), Val); }

◆ reprobe_limit()

static int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.reprobe_limit ( int  len)
staticprivateinherited

Definition at line 210 of file NonBlockingHashMapLong.java.

210  {
211  return REPROBE_LIMIT + (len>>4);
212  }

◆ reprobes()

long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.reprobes
inherited

Get and clear the current count of reprobes.

Reprobes happen on key collisions, and a high reprobe rate may indicate a poor hash function or weaknesses in the table resizing function.

Returns
the count of reprobes since the last call to reprobes or since the table was created.

Definition at line 202 of file NonBlockingHashMapLong.java.

202 { long r = _reprobes.get(); _reprobes = new ConcurrentAutoTable(); return r; }

◆ setHash()

void com.cliffc.aa.tvar.UQNodes.setHash ( )
private

Definition at line 81 of file UQNodes.java.

81  {
82  long hash=0;
83  for( Node n : values() )
84  hash = hash^System.identityHashCode(n);
85  if( hash==0 ) hash=1;
86  _hash = (int)hash;
87  }

References com.cliffc.aa.tvar.UQNodes._hash, com.cliffc.aa.util.NonBlockingHashMapLong< Node >.hash(), and com.cliffc.aa.util.NonBlockingHashMapLong< Node >.values().

Referenced by com.cliffc.aa.tvar.UQNodes.intern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.size
inherited

Returns the number of key-value mappings in this map.

Returns
the number of key-value mappings in this map

Definition at line 255 of file NonBlockingHashMapLong.java.

255 { return (_val_1==TOMBSTONE?0:1) + _chm.size(); }

◆ values()

Collection<TypeV> com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.values
inherited

Returns a Collection view of the values contained in this map.

The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

The view's iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.

Definition at line 1118 of file NonBlockingHashMapLong.java.

1118  {
1119  return new AbstractCollection<TypeV>() {
1120  public void clear ( ) { NonBlockingHashMapLong.this.clear ( ); }
1121  public int size ( ) { return NonBlockingHashMapLong.this.size ( ); }
1122  public boolean contains( Object v ) { return NonBlockingHashMapLong.this.containsValue(v); }
1123  public Iterator<TypeV> iterator() { return new SnapshotV(); }
1124  };
1125  }

◆ writeObject()

void com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.writeObject ( java.io.ObjectOutputStream  s) throws IOException
privateinherited

Definition at line 1256 of file NonBlockingHashMapLong.java.

1256  {
1257  s.defaultWriteObject(); // Write nothing
1258  for( long K : keySet() ) {
1259  final Object V = get(K); // Do an official 'get'
1260  s.writeLong (K); // Write the <long,TypeV> pair
1261  s.writeObject(V);
1262  }
1263  s.writeLong(NO_KEY); // Sentinel to indicate end-of-data
1264  s.writeObject(null);
1265  }

Member Data Documentation

◆ _chm

transient CHM com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._chm
privateinherited

Definition at line 131 of file NonBlockingHashMapLong.java.

◆ _chm_offset

final long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._chm_offset
staticprivateinherited

Definition at line 116 of file NonBlockingHashMapLong.java.

◆ _hash

◆ _last_resize_milli

transient long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._last_resize_milli
privateinherited

Definition at line 137 of file NonBlockingHashMapLong.java.

◆ _Lbase

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._Lbase
staticprivateinherited

Definition at line 106 of file NonBlockingHashMapLong.java.

◆ _Lscale

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._Lscale
staticprivateinherited

Definition at line 107 of file NonBlockingHashMapLong.java.

◆ _Obase

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._Obase
staticprivateinherited

Definition at line 98 of file NonBlockingHashMapLong.java.

◆ _opt_for_space

final boolean com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._opt_for_space
privateinherited

Definition at line 140 of file NonBlockingHashMapLong.java.

◆ _Oscale

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._Oscale
staticprivateinherited

Definition at line 99 of file NonBlockingHashMapLong.java.

◆ _reprobes

transient ConcurrentAutoTable com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._reprobes
privateinherited

Definition at line 196 of file NonBlockingHashMapLong.java.

◆ _val_1

transient Object com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._val_1
privateinherited

Definition at line 134 of file NonBlockingHashMapLong.java.

◆ _val_1_offset

final long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >._val_1_offset
staticprivateinherited

Definition at line 117 of file NonBlockingHashMapLong.java.

◆ KEY

◆ MATCH_ANY

final Object com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.MATCH_ANY
staticprivateinherited

Definition at line 154 of file NonBlockingHashMapLong.java.

◆ MIN_SIZE

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.MIN_SIZE
staticprivateinherited

Definition at line 146 of file NonBlockingHashMapLong.java.

◆ MIN_SIZE_LOG

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.MIN_SIZE_LOG
staticprivateinherited

Definition at line 145 of file NonBlockingHashMapLong.java.

◆ NO_KEY

final long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.NO_KEY
staticprivateinherited

Definition at line 167 of file NonBlockingHashMapLong.java.

◆ NO_MATCH_OLD

final Object com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.NO_MATCH_OLD
staticprivateinherited

Definition at line 151 of file NonBlockingHashMapLong.java.

◆ REPROBE_LIMIT

final int com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.REPROBE_LIMIT
staticprivateinherited

Definition at line 95 of file NonBlockingHashMapLong.java.

◆ serialVersionUID

final long com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.serialVersionUID
staticprivateinherited

Definition at line 93 of file NonBlockingHashMapLong.java.

◆ TOMBPRIME

final Prime com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.TOMBPRIME
staticprivateinherited

Definition at line 162 of file NonBlockingHashMapLong.java.

◆ TOMBSTONE

final Object com.cliffc.aa.util.NonBlockingHashMapLong< TypeV >.TOMBSTONE
staticprivateinherited

Definition at line 157 of file NonBlockingHashMapLong.java.

◆ UQSETS

final NonBlockingHashMap<UQNodes,UQNodes> com.cliffc.aa.tvar.UQNodes.UQSETS = new NonBlockingHashMap<>()
staticprivate

Definition at line 9 of file UQNodes.java.

Referenced by com.cliffc.aa.tvar.UQNodes.intern().


The documentation for this class was generated from the following file:
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_chm
transient CHM _chm
Definition: NonBlockingHashMapLong.java:131
com.cliffc.aa.tvar.UQNodes.KEY
static UQNodes KEY
Definition: UQNodes.java:10
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::REPROBE_LIMIT
static final int REPROBE_LIMIT
Definition: NonBlockingHashMapLong.java:95
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::NonBlockingHashMapLong
NonBlockingHashMapLong()
Create a new NonBlockingHashMapLong with default minimum size (currently set to 8 K/V pairs or roughl...
Definition: NonBlockingHashMapLong.java:219
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::keySetLong
long[] keySetLong()
Keys as a long array.
Definition: NonBlockingHashMapLong.java:1180
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_reprobes
transient ConcurrentAutoTable _reprobes
Definition: NonBlockingHashMapLong.java:196
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::MIN_SIZE_LOG
static final int MIN_SIZE_LOG
Definition: NonBlockingHashMapLong.java:145
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_Lscale
static final int _Lscale
Definition: NonBlockingHashMapLong.java:107
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::initialize
void initialize(final int initial_sz)
Definition: NonBlockingHashMapLong.java:242
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::clear
void clear()
Removes all of the mappings from this map.
Definition: NonBlockingHashMapLong.java:332
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::size
int size()
Returns the number of key-value mappings in this map.
Definition: NonBlockingHashMapLong.java:255
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::MATCH_ANY
static final Object MATCH_ANY
Definition: NonBlockingHashMapLong.java:154
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_chm_offset
static final long _chm_offset
Definition: NonBlockingHashMapLong.java:116
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::print_impl
static void print_impl(final int i, final long K, final Object V)
Definition: NonBlockingHashMapLong.java:177
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::keySet
Set< Long > keySet()
Returns a Set view of the keys contained in this map; with care the keys may be iterated over without...
Definition: NonBlockingHashMapLong.java:1168
com.cliffc.aa.util.NonBlockingHashMapLong.get
final TypeV get(long key)
Returns the value to which the specified key is mapped, or.
Definition: NonBlockingHashMapLong.java:368
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::NO_KEY
static final long NO_KEY
Definition: NonBlockingHashMapLong.java:167
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::putIfAbsent
TypeV putIfAbsent(long key, TypeV val)
Atomically, do a put if-and-only-if the key is not mapped.
Definition: NonBlockingHashMapLong.java:286
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::replace
TypeV replace(long key, TypeV val)
Atomically do a put(key,val) if-and-only-if the key is mapped to some value already.
Definition: NonBlockingHashMapLong.java:302
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::contains
boolean contains(Object val)
Legacy method testing if some key maps into the specified value in this table.
Definition: NonBlockingHashMapLong.java:268
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::hash
static final int hash(long h)
Definition: NonBlockingHashMapLong.java:416
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::putIfMatch
TypeV putIfMatch(long key, Object newVal, Object oldVal)
Definition: NonBlockingHashMapLong.java:312
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_Oscale
static final int _Oscale
Definition: NonBlockingHashMapLong.java:99
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::MIN_SIZE
static final int MIN_SIZE
Definition: NonBlockingHashMapLong.java:146
com.cliffc.aa.tvar.UQNodes.intern
static UQNodes intern()
Definition: UQNodes.java:14
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::containsKey
boolean containsKey(long key)
Tests if the key in the table.
Definition: NonBlockingHashMapLong.java:258
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_last_resize_milli
transient long _last_resize_milli
Definition: NonBlockingHashMapLong.java:137
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_val_1
transient Object _val_1
Definition: NonBlockingHashMapLong.java:134
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::TOMBSTONE
static final Object TOMBSTONE
Definition: NonBlockingHashMapLong.java:157
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::print2_impl
static void print2_impl(final int i, final long K, final Object V)
Definition: NonBlockingHashMapLong.java:190
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_Lbase
static final int _Lbase
Definition: NonBlockingHashMapLong.java:106
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::containsValue
boolean containsValue(Object val)
Returns true if this Map maps one or more keys to the specified value.
Definition: NonBlockingHashMapLong.java:349
com.cliffc.aa.tvar.UQNodes.setHash
void setHash()
Definition: UQNodes.java:81
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::NO_MATCH_OLD
static final Object NO_MATCH_OLD
Definition: NonBlockingHashMapLong.java:151
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_Obase
static final int _Obase
Definition: NonBlockingHashMapLong.java:98
com.cliffc.aa.util.NonBlockingHashMapLong.put
TypeV put(long key, TypeV val)
Maps the specified key to the specified value in the table.
Definition: NonBlockingHashMapLong.java:278
com.cliffc.aa.tvar.UQNodes._hash
int _hash
Definition: UQNodes.java:11
com.cliffc.aa.util.ConcurrentAutoTable.get
long get()
Current value of the counter.
Definition: ConcurrentAutoTable.java:50
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::values
Collection< TypeV > values()
Returns a Collection view of the values contained in this map.
Definition: NonBlockingHashMapLong.java:1118
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::CAS
final boolean CAS(final long offset, final Object old, final Object nnn)
Definition: NonBlockingHashMapLong.java:119
com.cliffc.aa.util.NonBlockingHashMapLong< Node >::_val_1_offset
static final long _val_1_offset
Definition: NonBlockingHashMapLong.java:117
com.cliffc.aa.tvar.UQNodes.UQSETS
static final NonBlockingHashMap< UQNodes, UQNodes > UQSETS
Definition: UQNodes.java:9