## org.apache.lucene.util
Class FieldCacheSanityChecker

    java.lang.Object
      org.apache.lucene.util.FieldCacheSanityChecker

    public final class FieldCacheSanityChecker

extends java.lang.Object

Provides methods for sanity checking that entries in the FieldCache are not wasteful or inconsistent.

Lucene 2.9 Introduced numerous enhancements into how the FieldCache is used by the low levels of Lucene searching (for Sorting and ValueSourceQueries) to improve both the speed for Sorting, as well as reopening of IndexReaders. But these changes have shifted the usage of FieldCache from "top level" IndexReaders (frequently a MultiReader or DirectoryReader) down to the leaf level SegmentReaders. As a result, existing applications that directly access the FieldCache may find RAM usage increase significantly when upgrading to 2.9 or Later. This class provides an API for these applications (or their Unit tests) to check at run time if the FieldCache contains "insane" usages of the FieldCache.

EXPERIMENTAL API: This API is considered extremely advanced and experimental. It may be removed or altered w/o warning in future releases of Lucene.

See Also:
  `FieldCache`, `FieldCacheSanityChecker.Insanity`, `FieldCacheSanityChecker.InsanityType`

Nested Class Summary
`static class` `FieldCacheSanityChecker.Insanity` Simple container for a collection of related CacheEntry objects that in conjunction with each other represent some "insane" usage of the FieldCache.
`static class` `FieldCacheSanityChecker.InsanityType` An Enumeration of the different types of "insane" behavior that may be detected in a FieldCache.

Constructor Summary
`FieldCacheSanityChecker()`

Method Summary
`FieldCacheSanityChecker.Insanity[]` `check(FieldCache.CacheEntry[] cacheEntries)` Tests a CacheEntry[] for indication of "insane" cache usage.
`static FieldCacheSanityChecker.Insanity[]` `checkSanity(FieldCache.CacheEntry[] cacheEntries)` Quick and dirty convenience method that instantiates an instance with "good defaults" and uses it to test the CacheEntry[]
`static FieldCacheSanityChecker.Insanity[]` `checkSanity(FieldCache cache)` Quick and dirty convenience method
`void` `setRamUsageEstimator(RamUsageEstimator r)` If set, will be used to estimate size for all CacheEntry objects dealt with.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FieldCacheSanityChecker

    public FieldCacheSanityChecker()

Method Detail

### setRamUsageEstimator

    public void setRamUsageEstimator(RamUsageEstimator r)

  If set, will be used to estimate size for all CacheEntry objects dealt with.

### checkSanity

    public static FieldCacheSanityChecker.Insanity[] checkSanity(FieldCache cache)

  Quick and dirty convenience method

  See Also:
    `check(org.apache.lucene.search.FieldCache.CacheEntry[])`

### checkSanity

    public static FieldCacheSanityChecker.Insanity[] checkSanity(FieldCache.CacheEntry[] cacheEntries)

  Quick and dirty convenience method that instantiates an instance with "good defaults" and uses it to test the CacheEntry[]

  See Also:
    `check(org.apache.lucene.search.FieldCache.CacheEntry[])`

### check

    public FieldCacheSanityChecker.Insanity[] check(FieldCache.CacheEntry[] cacheEntries)

  Tests a CacheEntry[] for indication of "insane" cache usage.

  NOTE:FieldCache CreationPlaceholder objects are ignored. (:TODO: is this a bad idea? are we masking a real problem?)

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.