Class BoundedArrayBackedOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>

java.lang.Object
com.illumon.util.datastructures.cache.BaseOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
com.illumon.util.datastructures.cache.BoundedArrayBackedOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
All Implemented Interfaces:
OffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>

@Deprecated public class BoundedArrayBackedOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE> extends BaseOffsetLookupCache<VALUE_TYPE,EXTRA_INPUT_TYPE>
Deprecated.

Caching data structure for caching int (offset) to Object mappings. For use when lookup is expensive but idempotent, and the range of offset indexes is relatively contiguous. This is only suitable for lookup functions that return fully-initialized, immutable objects (or null).

This implementation stores data in an array indexed by (offset % array size), and is well-optimized for sequential access patterns with limited look-behind.

Note: This performed adequately. It obviously can't compete with an unbounded cache of hard references for repeated full column accesses, however. Overall memory vs. performance trade-off conclusions are not yet obvious. For the workloads it's well suited for, it does very well. For the rest, it's pretty abyssmal.

  • Constructor Details

    • BoundedArrayBackedOffsetLookupCache

      public BoundedArrayBackedOffsetLookupCache(@NotNull Class<VALUE_TYPE> valueType, @NotNull OffsetLookup<VALUE_TYPE,EXTRA_INPUT_TYPE> lookupFunction)
      Deprecated.
      Construct a lookup cache for the supplied arguments, using OffsetLookupCache.createPlaceholder(Class) to create a "null" placeholder value.
      Parameters:
      valueType - The value type
      lookupFunction - The lookup function from index to value, must return a fully-initialized, immutable object or null
  • Method Details

    • get

      public VALUE_TYPE get(long index, EXTRA_INPUT_TYPE extra)
      Deprecated.
      Description copied from interface: OffsetLookupCache
      Lookup the value for index.
      Parameters:
      index - The offset (must be >= 0)
      Returns:
      The result of calling the lookup function for index, possibly from cache
    • clear

      public void clear()
      Deprecated.
      Description copied from interface: OffsetLookupCache
      Release all resources held by the cache.