Tabnine Logo
DirectMappedCache
Code IndexAdd Tabnine to your IDE (free)

How to use
DirectMappedCache
in
cascading.util.cache

Best Java code snippets using cascading.util.cache.DirectMappedCache (Showing top 7 results out of 315)

origin: cwensel/cascading

@Override
public CascadingCache create( FlowProcess flowProcess )
 {
 return new DirectMappedCache();
 }
origin: cwensel/cascading

@Override
public boolean containsKey( Object key )
 {
 if( key == null )
  throw new IllegalArgumentException( "null keys are not permitted" );
 return get( key ) != null;
 }
origin: cwensel/cascading

@Override
public Value get( Object key )
 {
 int index = index( key );
 Entry<Key, Value> existing = elements[ index ];
 if( existing == null || !key.equals( existing.getKey() ) )
  return null;
 return existing.getValue();
 }
origin: cwensel/cascading

int index = index( key );
Entry<Key, Value> existing = elements[ index ];
if( putCalls % getCapacity() == 0 )
 long totalMem = runtime.totalMemory() / 1024 / 1024;
 LOG.info( "mem on flush (mb), free: " + freeMem + ", total: " + totalMem + ", max: " + maxMem );
 LOG.info( "capacity={}, puts={}, collisions={}, fill factor={}%", getCapacity(), putCalls, collisions,
  ( (double) getCapacity() / actualSize ) * 100 );
 float percent = (float) totalMem / (float) maxMem;
 if( percent < 0.80F )
origin: cwensel/cascading

@Override
public void putAll( Map<? extends Key, ? extends Value> m )
 {
 for( Entry<? extends Key, ? extends Value> entry : m.entrySet() )
  put( entry.getKey(), entry.getValue() );
 }
origin: cwensel/cascading

private CascadingCache<Object, Object> getDirectMappedCache( int capacity, CacheEvictionCallback cacheEvictionCallback )
 {
 CascadingCache<Object, Object> map = new DirectMappedCache<Object, Object>();
 map.setCacheEvictionCallback( cacheEvictionCallback );
 map.setCapacity( capacity );
 map.initialize();
 return map;
 }
origin: cwensel/cascading

@Override
public Value remove( Object key )
 {
 if( key == null )
  throw new IllegalArgumentException( "key cannot be null" );
 int index = index( key );
 Entry<Key, Value> existing = elements[ index ];
 if( existing == null || !existing.getKey().equals( key ) )
  return null;
 elements[ index ] = null;
 actualSize--;
 evictionCallBack.evict( existing );
 return existing.getValue();
 }
cascading.util.cacheDirectMappedCache

Javadoc

DirectMappedCache is an implementation of the cascading.util.cache.CascadingCache interface following the semantics of http://en.wikipedia.org/wiki/CPU_cache#Direct-mapped_cache. The Cache is backed by an array that stays constant in size.

Unlike other implementation of a Map a hash collision will lead to the entry being overwritten. The CacheEvictionCallback is called with the entry that will be overwritten.

Use this cache if the keys are arriving in a random if not uniformly distributed order in order to reduce the number of hash and equality comparisons.

If duplicate keys are clustered near each other in the incoming tuple stream, consider the cascading.util.cache.LRUHashMapCache cache instead.

DirectMappedCache does not permit null keys nor null values

Most used methods

  • <init>
  • get
  • getCapacity
  • index
  • put

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • putExtra (Intent)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JPanel (javax.swing)
  • JTable (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now