# Package org.apache.lucene.util

package org.apache.lucene.util
Some utility classes.

Related Packages
Package
Description
org.apache.lucene.util.automaton
Finite-state automaton for regular expressions.
org.apache.lucene.util.bkd
Block KD-tree, implementing the generic spatial data structure described in this paper.
org.apache.lucene.util.compress
Compression utilities.
org.apache.lucene.util.fst
Finite state transducers
org.apache.lucene.util.graph
Utility classes for working with token streams as graphs.
org.apache.lucene.util.hnsw
Navigable Small-World graph, nominally Hierarchical but currently only has a single layer.
org.apache.lucene.util.mutable
Comparable object wrappers
org.apache.lucene.util.packed
Packed integer arrays and streams.
org.apache.lucene.util.quantization
Provides quantization methods for scaling vector values to smaller data types and possibly fewer dimensions
Class
Description
Accountable
An object whose RAM usage can be computed.
Accountables
Helper methods for constructing nested resource descriptions and debugging RAM usage.
ArrayUtil
Methods for manipulating arrays.
ArrayUtil.ByteArrayComparator
Comparator for a fixed number of bytes.
Attribute
Base interface for attributes.
AttributeFactory
An AttributeFactory creates instances of `AttributeImpl`s.
AttributeFactory.StaticImplementationAttributeFactory<A extends AttributeImpl>
Expert: AttributeFactory returning an instance of the given `clazz` for the attributes it implements.
AttributeImpl
Base class for Attributes that can be added to a `AttributeSource`.
AttributeReflector
This interface is used to reflect contents of `AttributeSource` or `AttributeImpl`.
AttributeSource
An AttributeSource contains a list of different `AttributeImpl`s, and methods to add and get them.
AttributeSource.State
This class holds the state of an AttributeSource.
BitDocIdSet
Implementation of the `DocIdSet` interface on top of a `BitSet`.
Bits
Interface for Bitset-like structures.
Bits.MatchAllBits
Bits impl of the specified length with all bits set.
Bits.MatchNoBits
Bits impl of the specified length with no bits set.
BitSet
Base implementation for a bit set.
BitSetIterator
A `DocIdSetIterator` which iterates over set bits in a bit set.
BitUtil
A variety of high efficiency bit twiddling routines and encoders for primitives.
ByteBlockPool
This class enables the allocation of fixed-size buffers and their management as part of a buffer array.
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[].
BytesRefArray
A simple append only random-access `BytesRef` array that stores full copies of the appended bytes in a `ByteBlockPool`.
BytesRefArray.IndexedBytesRefIterator
An extension of `BytesRefIterator` that allows retrieving the index of the current element
BytesRefArray.SortState
Used to iterate the elements of an array in a given order.
BytesRefBlockPool
Represents a logical list of ByteRef backed by a `ByteBlockPool`.
BytesRefBuilder
A builder for `BytesRef` instances.
BytesRefComparator
Specialized `BytesRef` comparator that `StringSorter` has optimizations for.
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 `Counter` instance.
BytesRefHash.MaxBytesLengthExceededException
Thrown if a `BytesRef` exceeds the `BytesRefHash` limit of `ByteBlockPool.BYTE_BLOCK_SIZE`-2.
BytesRefIterator
A simple iterator interface for `BytesRef` iteration.
CharsRef
Represents char[], as a slice (offset + length) into an existing char[].
CharsRefBuilder
A builder for `CharsRef` instances.
ClassLoaderUtils
Helper class used by ServiceLoader to investigate parent/child relationships of `ClassLoader`s.
ClasspathResourceLoader
Simple `ResourceLoader` that uses `ClassLoader.getResourceAsStream(String)` and `Class.forName(String,boolean,ClassLoader)` to open resources and classes, respectively.
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.
CollectionUtil
Methods for manipulating (sorting) and creating collections.
CommandLineUtil
Class containing some useful methods used by command line tools
Constants
Some useful constants.
Counter
Simple counter class
DocBaseBitSetIterator
A `DocIdSetIterator` like `BitSetIterator` but has a doc base in onder to avoid storing previous 0s.
DocIdSetBuilder
A builder of `DocIdSet`s.
DocIdSetBuilder.BulkAdder
Utility class to efficiently add many docs in one go.
FileDeleter
This class provides ability to track the reference counts of a set of index files and delete them when their counts decreased to 0.
FileDeleter.MsgType
Types of messages this file deleter will broadcast REF: messages about reference FILE: messages about file
FileDeleter.RefCount
Tracks the reference count for a single index file:
FilterIterator<T,InnerT extends T>
An `Iterator` implementation that filters elements with a boolean predicate.
FixedBitSet
BitSet of fixed length (numBits), backed by accessible (`FixedBitSet.getBits()`) long[], accessed with an int index, implementing `Bits` and `DocIdSet`.
FrequencyTrackingRingBuffer
A ring buffer that tracks the frequency of the integers that it contains.
GroupVIntUtil
This class contains utility methods and constants for group varint
GroupVIntUtil.IntReader
Provides an abstraction for read int values, so that decoding logic can be reused in different DataInput.
IgnoreRandomChains
Annotation to not test a class or constructor with `TestRandomChains` integration test.
InfoStream
Debugging API for Lucene classes such as `IndexWriter` and `SegmentInfos`.
InPlaceMergeSorter
`Sorter` implementation based on the merge-sort algorithm that merges in place (no extra memory will be allocated).
IntBlockPool
A pool for int blocks similar to `ByteBlockPool`
IntBlockPool.Allocator
Abstract class for allocating and freeing int blocks.
IntBlockPool.DirectAllocator
A simple `IntBlockPool.Allocator` that never recycles.
IntroSelector
Adaptive selection algorithm based on the introspective quick select algorithm.
IntroSorter
`Sorter` implementation based on a variant of the quicksort algorithm called introsort: when the recursion level exceeds the log of the length of the array to sort, it falls back to heapsort.
IntsRef
Represents int[], as a slice (offset + length) into an existing int[].
IntsRefBuilder
A builder for `IntsRef` instances.
IOBooleanSupplier
Boolean supplier that is allowed to throw an IOException.
IOConsumer<T>
An IO operation with a single input that may throw an IOException.
IOFunction<T,R>
A Function that may throw an IOException
IORunnable
A Runnable that may throw an IOException
IOSupplier<T>
This is a result supplier that is allowed to throw an IOException.
IOUtils
Utilities for dealing with `Closeable`s.
JavaLoggingInfoStream
InfoStream implementation that logs every message using Java Utils Logging (JUL) with the supplied log level.
LongBitSet
BitSet of fixed length (numBits), backed by accessible (`LongBitSet.getBits()`) long[], accessed with a long index.
LongHeap
A min heap that stores longs; a primitive priority queue that like all priority queues maintains a partial ordering of its elements such that the least element can always be found in constant time.
LongsRef
Represents long[], as a slice (offset + length) into an existing long[].
LongValues
Abstraction over an array of longs.
LSBRadixSorter
A LSB Radix sorter for unsigned int values.
MapOfSets<K,V>
Helper class for keeping Lists of Objects associated with keys.
MathUtil
Math static utility methods.
MergedIterator<T extends Comparable<T>>
Provides a merged sorted view from several sorted iterators.
ModuleResourceLoader
Simple `ResourceLoader` that uses `Module.getResourceAsStream(String)` and `Class.forName(Module,String)` to open resources and classes, respectively.
MSBRadixSorter
Radix sorter for variable-length strings.
NamedSPILoader<S extends NamedSPILoader.NamedSPI>
Helper class for loading named SPIs from classpath (e.g.
NamedSPILoader.NamedSPI
Interface to support `NamedSPILoader.lookup(String)` by name.
NamedThreadFactory
A default `ThreadFactory` implementation that accepts the name prefix of the created threads as a constructor argument.
NotDocIdSet
This `DocIdSet` encodes the negation of another `DocIdSet`.
NumericUtils
Helper APIs to encode numeric values as sortable bytes and vice-versa.
OfflineSorter
On-disk sorting of byte arrays.
OfflineSorter.BufferSize
A bit more descriptive unit for constructors.
OfflineSorter.ByteSequencesReader
Utility class to read length-prefixed byte[] entries from an input.
OfflineSorter.ByteSequencesWriter
Utility class to emit length-prefixed byte[] entries to an output stream for sorting.
PagedBytes
Represents a logical byte[] as a series of pages.
PagedBytes.Reader
Provides methods to read BytesRefs from a frozen PagedBytes.
PrintStreamInfoStream
InfoStream implementation over a `PrintStream` such as `System.out`.
PriorityQueue<T>
A priority queue maintains a partial ordering of its elements such that the least element can always be found in constant time.
QueryBuilder
Creates queries from the `Analyzer` chain.
QueryBuilder.TermAndBoost
Wraps a term and boost
RadixSelector
Radix selector.
RamUsageEstimator
Estimates the size (memory representation) of Java objects.
RecyclingByteBlockAllocator
A `ByteBlockPool.Allocator` implementation that recycles unused byte blocks in a buffer and reuses them in subsequent calls to `RecyclingByteBlockAllocator.getByteBlock()`.
RecyclingIntBlockAllocator
A `IntBlockPool.Allocator` implementation that recycles unused int blocks in a buffer and reuses them in subsequent calls to `RecyclingIntBlockAllocator.getIntBlock()`.
RefCount<T>
Manages reference counting for a given object.
ResourceLoader
Abstraction for loading resources (streams, files, and classes).
ResourceLoaderAware
Interface for a component that needs to be initialized by an implementation of `ResourceLoader`.
RoaringDocIdSet
`DocIdSet` implementation inspired from http://roaringbitmap.org/
RoaringDocIdSet.Builder
A builder of `RoaringDocIdSet`s.
RollingBuffer<T extends RollingBuffer.Resettable>
Acts like forever growing T[], but internally uses a circular buffer to reuse instances of T.
RollingBuffer.Resettable
Implement to reset an instance
SameThreadExecutorService
An `ExecutorService` that executes tasks immediately in the calling thread during submit.
Selector
An implementation of a selection algorithm, ie.
SentinelIntSet
A native int hash-based set where one value is reserved to mean "EMPTY" internally.
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.
SetOnce.AlreadySetException
Thrown when `SetOnce.set(Object)` is called more than once.
SloppyMath
Math functions that trade off accuracy for speed.
SmallFloat
Floating point numbers smaller than 32 bits.
Sorter
Base class for sorting algorithms implementations.
SparseFixedBitSet
A bit set that only stores longs that have at least one bit which is set.
StableMSBRadixSorter
Stable radix sorter for variable-length strings.
StableMSBRadixSorter.MergeSorter
A MergeSorter taking advantage of temporary storage.
StringHelper
Methods for manipulating strings.
StringSorter
A `BytesRef` sorter tries to use a efficient radix sorter if `StringSorter.cmp` is a `BytesRefComparator`, otherwise fallback to `StringSorter.fallbackSorter(java.util.Comparator<org.apache.lucene.util.BytesRef>)`
SuppressForbidden
Annotation to suppress forbidden-apis errors inside a whole class, a method, or a field.
TermAndVector
Word2Vec unit composed by a term with the associated vector
ThreadInterruptedException
Thrown by lucene on detecting that Thread.interrupt() had been called.
TimSorter
`Sorter` implementation based on the TimSort algorithm.
ToStringUtils
Helper methods to ease implementing `Object.toString()`.
UnicodeUtil
Class to encode java's UTF16 char[] into UTF8 byte[] without always allocating a new byte[] as String.getBytes(StandardCharsets.UTF_8) does.
UnicodeUtil.UTF8CodePoint
Holds a codepoint along with the number of bytes required to represent it in UTF8
Unwrappable<T>
An object with this interface is a wrapper around another object (e.g., a filter with a delegate).
VectorUtil
Utilities for computations with numeric arrays, especially algebraic operations like vector dot products.
Version
Use by certain classes to match version compatibility across releases of Lucene.
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`.