## Package org.apache.lucene.util

Some utility classes.

See:
Description

Interface Summary
Attribute: Base interface for attributes.
AttributeReflector: This interface is used to reflect contents of `AttributeSource` or `AttributeImpl`.
Bits: Interface for Bitset-like structures.
BytesRefIterator: A simple iterator interface for `BytesRef` iteration.
RollingBuffer.Resettable
TwoPhaseCommit: An interface for implementations that support 2-phase commit.

Class Summary
_TestUtil: General utility methods for Lucene unit tests.
ArrayUtil: Methods for manipulating arrays.
AttributeImpl: Base class for Attributes that can be added to a `AttributeSource`.
AttributeSource: An AttributeSource contains a list of different `AttributeImpl`s, and methods to add and get them.
AttributeSource.AttributeFactory: An AttributeFactory creates instances of `AttributeImpl`s.
AttributeSource.State: This class holds the state of an AttributeSource.
Bits.MatchAllBits: Bits impl of the specified length with all bits set.
Bits.MatchNoBits: Bits impl of the specified length with no bits set.
BitUtil: A variety of high efficiency bit twiddling routines.
BitVector: Optimized implementation of a vector of bits.
ByteBlockPool: Class that Posting and PostingVector use to write byte streams into shared fixed-size byte[] arrays.
ByteBlockPool.Allocator: Abstract class for allocating and freeing byte blocks.
ByteBlockPool.DirectAllocator: A simple `ByteBlockPool.Allocator` that never recycles.
ByteBlockPool.DirectTrackingAllocator: A simple `ByteBlockPool.Allocator` that never recycles, but tracks how much total RAM is in use.
BytesRef: Represents byte[], as a slice (offset + length) into an existing byte[].
BytesRefHash: `BytesRefHash` is a special purpose hash-map like data-structure optimized for `BytesRef` instances.
BytesRefHash.BytesStartArray: Manages allocation of the per-term addresses.
BytesRefHash.DirectBytesStartArray: A simple `BytesRefHash.BytesStartArray` that tracks memory allocation using a private `AtomicLong` instance.
BytesRefHash.TrackingDirectBytesStartArray: A simple `BytesRefHash.BytesStartArray` that tracks all memory allocation using a shared `AtomicLong` instance.
CharacterUtils: `CharacterUtils` provides a unified interface to Character-related operations to implement backwards compatible character operations based on a `Version` instance.
CharacterUtils.CharacterBuffer: A simple IO buffer to use with `CharacterUtils.fill(CharacterBuffer, Reader)`.
CharsRef: Represents char[], as a slice (offset + length) into an existing char[].
CloseableThreadLocal<T>: Java's builtin ThreadLocal has a serious flaw: it can take an arbitrarily long amount of time to dereference the things you had stored in it, even once the ThreadLocal instance itself is no longer referenced.
CodecUtil: Utility class for reading and writing versioned headers.
CollectionUtil: Methods for manipulating (sorting) collections.
CommandLineUtil: Class containing some useful methods used by command line tools
Constants: Some useful constants.
Counter: Simple counter class
DocIdBitSet: Simple DocIdSet and DocIdSetIterator backed by a BitSet
DoubleBarrelLRUCache<K extends DoubleBarrelLRUCache.CloneableKey,V>: Simple concurrent LRU cache, using a "double barrel" approach where two ConcurrentHashMaps record entries.
DoubleBarrelLRUCache.CloneableKey: Object providing clone(); the key class must subclass this.
DummyConcurrentLock: A dummy lock as a replacement for `ReentrantLock` to disable locking
English
FieldCacheSanityChecker: Provides methods for sanity checking that entries in the FieldCache are not wasteful or inconsistent.
FieldCacheSanityChecker.Insanity: Simple container for a collection of related CacheEntry objects that in conjunction with each other represent some "insane" usage of the FieldCache.
FieldCacheSanityChecker.InsanityType: An Enumeration of the different types of "insane" behavior that may be detected in a FieldCache.
FixedBitSet: BitSet of fixed length (numBits), backed by accessible (`FixedBitSet.getBits()`) long[], accessed with an int index, implementing Bits and DocIdSet.
IndexableBinaryStringTools: Provides support for converting byte sequences to Strings and back again.
IntsRef: Represents int[], as a slice (offset + length) into an existing int[].
IOUtils: This class emulates the new Java 7 "Try-With-Resources" statement.
LineFileDocs: Minimal port of contrib/benchmark's LneDocSource + DocMaker, so tests can enum docs from a line file created by contrib/benchmark's WriteLineDoc task
LuceneJUnitDividingSelector: Divides filesets into equal groups
LuceneJUnitResultFormatter: Just like BriefJUnitResultFormatter "brief" bundled with ant, except all formatted text is buffered until the test suite is finished.
LuceneTestCase: Base class for all Lucene unit tests, Junit3 or Junit4 variant.
LuceneTestCaseRunner: optionally filters the tests to be run by TEST_METHOD
MapBackedSet<E>: A Set implementation that wraps an actual Map based implementation.
MapOfSets<K,V>: Helper class for keeping Lists of Objects associated with keys.
NamedThreadFactory: A default `ThreadFactory` implementation that accepts the name prefix of the created threads as a constructor argument.
NumericUtils: This is a helper class to generate prefix-encoded representations for numerical values and supplies converters to represent float/double values as sortable integers/longs.
NumericUtils.IntRangeBuilder: Expert: Callback for `NumericUtils.splitIntRange(org.apache.lucene.util.NumericUtils.IntRangeBuilder, int, int, int)`.
NumericUtils.LongRangeBuilder: Expert: Callback for `NumericUtils.splitLongRange(org.apache.lucene.util.NumericUtils.LongRangeBuilder, int, long, long)`.
OpenBitSet: An "open" BitSet implementation that allows direct access to the array of words storing the bits.
OpenBitSetDISI: OpenBitSet with added methods to bulk-update the bits from a `DocIdSetIterator`.
OpenBitSetIterator: An iterator to iterate over set bits in an OpenBitSet.
PagedBytes: Represents a logical byte[] as a series of pages.
PagedBytes.Reader: Provides methods to read BytesRefs from a frozen PagedBytes.
Parameter: Deprecated. Use Java 5 enum, will be removed in a later Lucene 3.x release.
PriorityQueue<T>: A PriorityQueue maintains a partial ordering of its elements such that the least element can always be found in constant time.
RamUsageEstimator: Estimates the size (memory representation) of Java objects.
ReaderUtil: Common util methods for dealing with `IndexReader`s.
ReaderUtil.Gather: Recursively visits all sub-readers of a reader.
RecyclingByteBlockAllocator: A `ByteBlockPool.Allocator` implementation that recycles unused byte blocks in a buffer and reuses them in subsequent calls to `RecyclingByteBlockAllocator.getByteBlock()`.
Rethrow: Sneaky: rethrowing checked exceptions as unchecked ones.
RollingBuffer<T extends RollingBuffer.Resettable>: Acts like forever growing T[], but internally uses a circular buffer to reuse instances of T.
RollingCharBuffer: Acts like a forever growing char[] as you read characters into it from the provided reader, but internally it uses a circular buffer to only hold the characters that haven't been freed yet.
ScorerDocQueue: A ScorerDocQueue maintains a partial ordering of its Scorers such that the least Scorer can always be found in constant time.
SetOnce<T>: A convenient class which offers a semi-immutable object wrapper implementation which allows one to set the value of an object exactly once, and retrieve it many times.
SimpleStringInterner: Simple lockless and memory barrier free String intern cache that is guaranteed to return the same String instance as String.intern() does.
SmallFloat: Floating point numbers smaller than 32 bits.
SmartRandom: A random that tracks if its been initialized properly, and throws an exception if it hasn't.
SortedVIntList: Stores and iterate on sorted integers in compressed form in RAM.
SorterTemplate: This class was inspired by CGLIB, but provides a better QuickSort algorithm without additional InsertionSort at the end.
StoreClassNameRule
StringHelper: Methods for manipulating strings.
StringInterner: Subclasses of StringInterner are required to return the same single String object for all equal strings.
SystemPropertiesInvariantRule
SystemPropertiesRestoreRule: Restore system properties from before the nested `Statement`.
ThrottledIndexOutput: Intentionally slow IndexOutput for testing.
ToStringUtils: Helper methods to ease implementing `Object.toString()`.
TwoPhaseCommitTool: A utility for executing 2-phase commit on several objects.
TwoPhaseCommitTool.TwoPhaseCommitWrapper: A wrapper of a `TwoPhaseCommit`, which delegates all calls to the wrapped object, passing the specified commitData.
UncaughtExceptionsRule: Subscribes to `Thread.setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)` and causes test/ suite failures if uncaught exceptions are detected.
UncaughtExceptionsRule.UncaughtExceptionEntry
UnicodeUtil: Class to encode java's UTF16 char[] into UTF8 byte[] without always allocating a new byte[] as String.getBytes("UTF-8") does.
UnicodeUtil.UTF16Result: Holds decoded UTF16 code units.
UnicodeUtil.UTF8Result: Holds decoded UTF8 code units.
UnsafeByteArrayInputStream: This class, much like `ByteArrayInputStream` uses a given buffer as a source of an InputStream.
UnsafeByteArrayOutputStream: This class is used as a wrapper to a byte array, extending `OutputStream`.
Vint8: Variable-length encoding of 32-bit integers, into 8-bit bytes.
Vint8.Position: Because Java lacks call-by-reference, this class boxes the decoding position, which is initially set by the caller, and returned after decoding, incremented by the number of bytes processed.
VirtualMethod<C>: A utility for keeping backwards compatibility on previously abstract methods (or similar replacements).
WeakIdentityMap<K,V>: Implements a combination of `WeakHashMap` and `IdentityHashMap`.

Enum Summary
RamUsageEstimator.JvmFeature: JVM diagnostic features.
Version: Use by certain classes to match version compatibility across releases of Lucene.

Exception Summary
BytesRefHash.MaxBytesLengthExceededException: Thrown if a `BytesRef` exceeds the `BytesRefHash` limit of `ByteBlockPool.BYTE_BLOCK_SIZE`-2.
SetOnce.AlreadySetException: Thrown when `SetOnce.set(Object)` is called more than once.
ThreadInterruptedException: Thrown by lucene on detecting that Thread.interrupt() had been called.
TwoPhaseCommitTool.CommitFailException: Thrown by `TwoPhaseCommitTool.execute(TwoPhaseCommit...)` when an object fails to commit().
TwoPhaseCommitTool.PrepareCommitFailException: Thrown by `TwoPhaseCommitTool.execute(TwoPhaseCommit...)` when an object fails to prepareCommit().

Annotation Types Summary
LuceneTestCase.Nightly: Annotation for tests that should only be run during nightly builds.

## Package org.apache.lucene.util Description

Some utility classes.