test_class.file: oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/ReaderCacheTest.java
test_class.identifier: ReaderCacheTest
test_case.body: @Test
      public void empty() {
          final AtomicInteger counter = new AtomicInteger();
          Function<Integer, String> loader = new Function<Integer, String>() {
              @Override @NotNull
              public String apply(@Nullable Integer input) {
                  counter.incrementAndGet();
                  return valueOf(input);
              }
          };
          StringCache c = new StringCache(0);
          for (int repeat = 0; repeat < 10; repeat++) {
              for (int i = 0; i < 1000; i++) {
                  assertEquals(valueOf(i), c.get(i, i, i, loader));
              }
          }
          // the LIRS cache should be almost empty (low hit rate there)
          assertTrue(valueOf(counter), counter.get() > 1000);
          // but the fast cache should improve the total hit rate
          assertTrue(valueOf(counter), counter.get() < 5000);
      }
test_case.class_method_signature: ReaderCacheTest.empty()
test_case.full_signature: @Test public void empty()
test_case.identifier: empty
test_case.invocations: incrementAndGet valueOf assertEquals valueOf get assertTrue valueOf get assertTrue valueOf get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void empty()
focal_class.declarator: weigher
focal_class.modifier: @NotNull
      private final
focal_class.original_string: @NotNull
      private final Weigher<CacheKey, T> weigher;
focal_class.type: Weigher<CacheKey, T>
focal_class.var_name: weigher
focal_class.declarator: name
focal_class.modifier: @NotNull
      private final
focal_class.original_string: @NotNull
      private final String name;
focal_class.type: String
focal_class.var_name: name
focal_class.declarator: fastCache
focal_class.modifier: @Nullable
      private final
focal_class.original_string: @Nullable
      private final FastCache<T> fastCache;
focal_class.type: FastCache<T>
focal_class.var_name: fastCache
focal_class.declarator: cache
focal_class.modifier: @NotNull
      private final
focal_class.original_string: @NotNull
      private final CacheLIRS<CacheKey, T> cache;
focal_class.type: CacheLIRS<CacheKey, T>
focal_class.var_name: cache
focal_class.file: oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/ReaderCache.java
focal_class.identifier: ReaderCache
focal_class.class_method_signature: ReaderCache.ReaderCache(long maxWeight, int averageWeight,
              @NotNull String name, @NotNull Weigher<CacheKey, T> weigher)
focal_class.full_signature: protected  ReaderCache(long maxWeight, int averageWeight,
              @NotNull String name, @NotNull Weigher<CacheKey, T> weigher)
focal_class.identifier: ReaderCache
focal_class.modifiers: protected
focal_class.parameters: (long maxWeight, int averageWeight,
              @NotNull String name, @NotNull Weigher<CacheKey, T> weigher)
focal_class.signature:  ReaderCache(long maxWeight, int averageWeight,
              @NotNull String name, @NotNull Weigher<CacheKey, T> weigher)
focal_class.class_method_signature: ReaderCache.getStats()
focal_class.full_signature: @NotNull public CacheStats getStats()
focal_class.identifier: getStats
focal_class.modifiers: @NotNull public
focal_class.parameters: ()
focal_class.return: CacheStats
focal_class.signature: CacheStats getStats()
focal_class.class_method_signature: ReaderCache.getEntryHash(long lsb, long msb, int offset)
focal_class.full_signature: private static int getEntryHash(long lsb, long msb, int offset)
focal_class.identifier: getEntryHash
focal_class.modifiers: private static
focal_class.parameters: (long lsb, long msb, int offset)
focal_class.return: int
focal_class.signature: int getEntryHash(long lsb, long msb, int offset)
focal_class.class_method_signature: ReaderCache.get(long msb, long lsb, int offset, Function<Integer, T> loader)
focal_class.full_signature: @NotNull public T get(long msb, long lsb, int offset, Function<Integer, T> loader)
focal_class.identifier: get
focal_class.modifiers: @NotNull public
focal_class.parameters: (long msb, long lsb, int offset, Function<Integer, T> loader)
focal_class.return: T
focal_class.signature: T get(long msb, long lsb, int offset, Function<Integer, T> loader)
focal_class.class_method_signature: ReaderCache.clear()
focal_class.full_signature: public void clear()
focal_class.identifier: clear
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: ReaderCache.isSmall(T value)
focal_class.full_signature: protected abstract boolean isSmall(T value)
focal_class.identifier: isSmall
focal_class.modifiers: protected abstract
focal_class.parameters: (T value)
focal_class.return: boolean
focal_class.signature: boolean isSmall(T value)
focal_method.body: @NotNull
      public T get(long msb, long lsb, int offset, Function<Integer, T> loader) {
          int hash = getEntryHash(msb, lsb, offset);
          if (fastCache == null) {
              // disabled cache
              T value = loader.apply(offset);
              assert value != null;
              return value;
          }
  
          T value = fastCache.get(hash, msb, lsb, offset);
          if (value != null) {
              return value;
          }
          CacheKey key = new CacheKey(hash, msb, lsb, offset);
          value = cache.getIfPresent(key);
          if (value == null) {
              value = loader.apply(offset);
              assert value != null;
              cache.put(key, value);
          }
          if (isSmall(value)) {
              fastCache.put(hash, new FastCacheEntry<>(hash, msb, lsb, offset, value));
          }
          return value;
      }
focal_method.class_method_signature: ReaderCache.get(long msb, long lsb, int offset, Function<Integer, T> loader)
focal_method.full_signature: @NotNull public T get(long msb, long lsb, int offset, Function<Integer, T> loader)
focal_method.identifier: get
focal_method.invocations: getEntryHash apply get getIfPresent apply put isSmall put
focal_method.modifiers: @NotNull public
focal_method.parameters: (long msb, long lsb, int offset, Function<Integer, T> loader)
focal_method.return: T
focal_method.signature: T get(long msb, long lsb, int offset, Function<Integer, T> loader)