addedRelations = new ConcurrentBufferAddedRelations(); concurrencyLevel = 1; //TODO: should we increase this? newTypeCache = new NonBlockingHashMap<String, Long>(); newVertexIndexEntries = new ConcurrentIndexCache();
/** * {@inheritDoc} * <p> * <strong>NOTE:</strong> This method deviates from the original * {@link Multimap} interface in that changes to the returned collection * WILL NOT update the underlying multimap and vice-versa. */ @Override public Set<V> get(K key) { Set<V> values = map.get(key); return values != null ? values : emptySet; }
/** * @return <tt>true</tt> if {@code o} is in the set. */ public boolean contains ( final Object o ) { return _map.containsKey(o); } /** Remove {@code o} from the set.
/** Removes all of the mappings from this map. */ @Override public void clear() { // Smack a new empty table down Object[] newkvs = new NonBlockingHashMap(MIN_SIZE)._kvs; while( !CAS_kvs(_kvs,newkvs) ) // Spin until the clear works ; }
/** * @return a collection of dirty CFIDs for this segment file. */ public synchronized Collection<UUID> getDirtyCFIDs() { if (cfClean.isEmpty() || cfDirty.isEmpty()) return cfDirty.keySet(); List<UUID> r = new ArrayList<>(cfDirty.size()); for (Map.Entry<UUID, AtomicInteger> dirty : cfDirty.entrySet()) { UUID cfId = dirty.getKey(); AtomicInteger dirtyPos = dirty.getValue(); AtomicInteger cleanPos = cfClean.get(cfId); if (cleanPos == null || cleanPos.intValue() < dirtyPos.intValue()) r.add(dirty.getKey()); } return r; }
public static NoSpamLogger getLogger(Logger logger, long minInterval, TimeUnit unit) { NoSpamLogger wrapped = wrappedLoggers.get(logger); if (wrapped == null) { wrapped = new NoSpamLogger(logger, minInterval, unit); NoSpamLogger temp = wrappedLoggers.putIfAbsent(logger, wrapped); if (temp != null) wrapped = temp; } return wrapped; }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Nothing to write for( Object K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeObject(K); // Write the <TypeK,TypeV> pair s.writeObject(V); } s.writeObject(null); // Sentinel to indicate end-of-data s.writeObject(null); }
/** Remove {@code o} from the set. * @return <tt>true</tt> if {@code o} was removed to the set, <tt>false</tt> * if {@code o} was not in the set. */ public boolean remove ( final Object o ) { return _map.remove(o) == V; } /**
@Override public void clear() { map.clear(); totalSize = 0; }
/** * Current count of elements in the set. Due to concurrent racing updates, * the size is only ever approximate. Updates due to the calling thread are * immediately visible to calling thread. * @return count of elements. */ public int size ( ) { return _map.size(); } /** Empty the set. */
/** * Removes all references of the given object from the dependency provider * * @param i the object to remove occurrences of * @return true if the object was found and removed, false otherwise */ public boolean remove(Object i) { if (i == null) { return false; } List<Map.Entry<Class<?>, Object>> entries = new ArrayList<>(); for (Map.Entry<Class<?>, Object> e : instances.entrySet()) { if (e.getValue() == i) { entries.add(e); } } for (Map.Entry<Class<?>, Object> e : entries) { instances.remove(e.getKey()); } return entries.size() > 0; }
@Override public Map<String, TokenHostConnectionPoolPartition<CL>> getPartitions() { Map<String, TokenHostConnectionPoolPartition<CL>> result = Maps.newHashMap(); for (Entry<BigInteger, TokenHostConnectionPoolPartition<CL>> entry : tokenToPartitionMap.entrySet()) { result.put(entry.getKey().toString(), entry.getValue()); } return result; }
@Override public Set<K> keySet() { return map.keySet(); }
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); // Read nothing initialize(MIN_SIZE); for(;;) { final TypeK K = (TypeK) s.readObject(); final TypeV V = (TypeV) s.readObject(); if( K == null ) break; put(K,V); // Insert with an offical put } }
/** * Register named dependency provider. * Named providers are useful for separating sets of dependencies that should only be used under * certain conditions * * @param name the name by which this provider can be retrieved and used later * @param provider the provider to register * @return false if the provider param is null or the provider was already registered, true otherwise */ public static boolean register(String name, DependencyProvider provider) { return provider != null && namedProviders.put(name, provider) == null; }
/** Add {@code o} to the set. * @return <tt>true</tt> if {@code o} was added to the set, <tt>false</tt> * if {@code o} was already in the set. */ public boolean add ( final E o ) { return _map.putIfAbsent(o,V) != V; }
/** * @return a collection of dirty CFIDs for this segment file. */ public synchronized Collection<UUID> getDirtyCFIDs() { if (cfClean.isEmpty() || cfDirty.isEmpty()) return cfDirty.keySet(); List<UUID> r = new ArrayList<>(cfDirty.size()); for (Map.Entry<UUID, IntegerInterval> dirty : cfDirty.entrySet()) { UUID cfId = dirty.getKey(); IntegerInterval dirtyInterval = dirty.getValue(); IntegerInterval.Set cleanSet = cfClean.get(cfId); if (cleanSet == null || !cleanSet.covers(dirtyInterval)) r.add(dirty.getKey()); } return r; }
public static NoSpamLogger getLogger(Logger logger, long minInterval, TimeUnit unit) { NoSpamLogger wrapped = wrappedLoggers.get(logger); if (wrapped == null) { wrapped = new NoSpamLogger(logger, minInterval, unit); NoSpamLogger temp = wrappedLoggers.putIfAbsent(logger, wrapped); if (temp != null) wrapped = temp; } return wrapped; }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Nothing to write for( Object K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeObject(K); // Write the <TypeK,TypeV> pair s.writeObject(V); } s.writeObject(null); // Sentinel to indicate end-of-data s.writeObject(null); }