@Override protected int evictionExtraSpace(Builder<K,V> builder){
  double factor=EVICTION_SPACE_PERCENT / 100D;
  userDataElements=builder.getExpectedMapSize();
  final int parallelityEvictionSpace;
  if (FEATURE_ExtraParEvictionSpace) {
    int evictionSpacePerWriter=builder.getConcurrencyLevel() * EVICTION_SPACE_PER_WRITER;
    parallelityEvictionSpace=Math.min(evictionSpacePerWriter,MAXIMUM_EVICTION_SPACE_FOR_WRITERS);
  }
 else {
    parallelityEvictionSpace=0;
  }
  long normalEvictionSpace=(long)(userDataElements * factor);
  long extraEvictionSpace=Math.max(normalEvictionSpace,parallelityEvictionSpace);
  long plannedSizeLong=userDataElements + extraEvictionSpace;
  blockStartAt=(int)Math.min(plannedSizeLong,Integer.MAX_VALUE);
  evictNormallyElements=(int)((double)userDataElements * FREE_PERCENTAGE / 100D);
  evictNormallyElements=Math.max(1,evictNormallyElements);
  evictUntilAtLeast=userDataElements - evictNormallyElements;
  if (LOG_INTERNAL_DATA) {
    logger.info("Cache eviction tuning [" + id() + "]. Size="+ userDataElements+ ", BLOCK="+ blockStartAt+ ", evictToPos="+ evictUntilAtLeast+ ", normal-evicting="+ evictNormallyElements);
  }
  return blockStartAt - userDataElements;
}

@ Override protected int evictionExtraSpace ( Builder < K , V > builder ) { double factor = EVICTION_SPACE_PERCENT / 100D ; userDataElements = builder . getExpectedMapSize ( ) ; final int parallelityEvictionSpace ; if ( FEATURE_ExtraParEvictionSpace ) { int evictionSpacePerWriter = builder . getConcurrencyLevel ( ) * EVICTION_SPACE_PER_WRITER ; parallelityEvictionSpace = Math . min ( evictionSpacePerWriter , MAXIMUM_EVICTION_SPACE_FOR_WRITERS ) ; } else { parallelityEvictionSpace = 0 ; } long normalEvictionSpace = ( long ) ( userDataElements * factor ) ; long extraEvictionSpace = Math . max ( normalEvictionSpace , parallelityEvictionSpace ) ; long plannedSizeLong = userDataElements + extraEvictionSpace ; blockStartAt = ( int ) Math . min ( plannedSizeLong , Integer . MAX_VALUE ) ; evictNormallyElements = ( int ) ( ( double ) userDataElements * FREE_PERCENTAGE / 100D ) ; evictNormallyElements = Math . max ( 1 , evictNormallyElements ) ; evictUntilAtLeast = userDataElements - evictNormallyElements ; if ( LOG_INTERNAL_DATA ) { logger . info ( "Cache eviction tuning [" + id ( ) + "]. Size=" + userDataElements + ", BLOCK=" + blockStartAt + ", evictToPos=" + evictUntilAtLeast + ", normal-evicting=" + evictNormallyElements ) ; } return blockStartAt - userDataElements ; }
calculates the amount of extra space that we need as eviction extra space in the storage map . the amount returned is the number of extra elements to allocate in the map . a storagebackend can use that . < p > internally this method calculates some more numbers : 0 / / empty private int evictuntilatleast ; / / position below userdataelements private int userdataelements ; / / expected elements , as given by user private int blockstartat ; / / block mark private int evictnormallyelements ; / / set during construction
