Class BinaryQuantIndexConfig
- All Implemented Interfaces:
Evolvable
,PortableObject
BinaryQuantIndex
vector indexing.
Binary quantization is a memory-efficient vector indexing technique that reduces vector storage requirements by compressing high-dimensional vectors into binary representations. This approach significantly reduces memory footprint and can improve search performance, especially for large-scale vector datasets.
Binary Quantization Benefits:
- Memory Efficiency - Reduces memory usage by up to 32x compared to full-precision vectors
- Fast Similarity Search - Binary operations (XOR, popcount) are extremely fast on modern CPUs
- Cache Friendliness - Compressed vectors fit better in CPU cache, improving performance
- Scalability - Enables indexing of larger datasets that wouldn't fit in memory otherwise
Trade-offs:
- Accuracy - Some precision is lost due to quantization, though this is often acceptable
- Oversampling - Higher oversampling factors can recover accuracy at the cost of performance
Configuration Example:
BinaryQuantIndexConfig config = new BinaryQuantIndexConfig()
.setOversamplingFactor(5); // Higher accuracy, more computation
This configuration class supports POF serialization for persistence and distribution across Coherence cluster nodes, and provides fluent API for method chaining.
- Since:
- 25.09
- Author:
- Aleks Seovic 2025.06.28
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default oversampling factor value.static final int
The implementation version for this class.static final String
The type of the index this configuration is for. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BinaryQuantIndexConfig with default settings. -
Method Summary
Modifier and TypeMethodDescriptioncom.oracle.coherence.ai.index.BinaryQuantIndex
<?, ?, ?> apply
(com.oracle.coherence.ai.index.BinaryQuantIndex<?, ?, ?> target) Applies all readable properties from this config instance to the given target object.boolean
int
Determine the serialization version supported by the implementing class.int
Returns the oversampling factor used during binary quantization search.int
hashCode()
void
Restore the contents of a user type instance by reading its state using the specified PofReader object.setOversamplingFactor
(int nOversamplingFactor) Sets the oversampling factor used during binary quantization search.toString()
type()
Returns the type of the index this configuration is for.void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.Methods inherited from class com.oracle.coherence.rag.config.AbstractConfig
getDataVersion
Methods inherited from class com.tangosol.io.AbstractEvolvable
getFutureData, setDataVersion, setFutureData
-
Field Details
-
TYPE
-
IMPLEMENTATION_VERSION
public static final int IMPLEMENTATION_VERSIONThe implementation version for this class.This version is used by Coherence POF for class evolution support. Increment this value when making incompatible changes to the class structure.
- See Also:
-
DEFAULT_OVERSAMPLING_FACTOR
public static final int DEFAULT_OVERSAMPLING_FACTORThe default oversampling factor value.This default value of 3 provides a good balance between search accuracy and computational performance for most binary quantization use cases.
- See Also:
-
-
Constructor Details
-
BinaryQuantIndexConfig
public BinaryQuantIndexConfig()Constructs a new BinaryQuantIndexConfig with default settings.Initializes the configuration with:
- Index type: "BINARY"
- Oversampling factor: 3 (balanced accuracy/performance)
The default oversampling factor of 3 provides a good balance between search accuracy and computational performance for most use cases.
-
-
Method Details
-
type
Returns the type of the index this configuration is for.- Overrides:
type
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>> - Returns:
- the type of the index this configuration is for
-
getOversamplingFactor
public int getOversamplingFactor()Returns the oversampling factor used during binary quantization search.The oversampling factor determines how many additional candidates are considered during the binary quantization process to improve search accuracy. This parameter directly affects the accuracy vs. performance trade-off.
- Returns:
- the oversampling factor, defaults to 3
- See Also:
-
setOversamplingFactor
Sets the oversampling factor used during binary quantization search.The oversampling factor determines how many additional candidates are considered during the binary quantization process to improve search accuracy. This parameter directly affects the accuracy vs. performance trade-off.
Recommended Values:
- Low Latency Applications: 1-2 (prioritize speed over accuracy)
- General Purpose: 3-5 (balanced approach, recommended default)
- High Accuracy Requirements: 6-10 (prioritize accuracy over speed)
Performance Impact: Higher oversampling factors increase computational cost approximately linearly, as more candidates must be evaluated using full-precision similarity calculations.
- Parameters:
nOversamplingFactor
- the oversampling factor to set, must be positive- Returns:
- this
BinaryQuantIndexConfig
instance for method chaining - Throws:
IllegalArgumentException
- if nOversamplingFactor is less than 1- See Also:
-
apply
public com.oracle.coherence.ai.index.BinaryQuantIndex<?,?, apply?> (com.oracle.coherence.ai.index.BinaryQuantIndex<?, ?, ?> target) Description copied from class:AbstractConfig
Applies all readable properties from this config instance to the given target object.This supports both JavaBean-style and fluent-style setter methods on the target.
- Overrides:
apply
in classAbstractConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>> - Parameters:
target
- the object to apply configuration values to (e.g., a POJO or Builder)
-
equals
- Overrides:
equals
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>>
-
hashCode
public int hashCode()- Overrides:
hashCode
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>>
-
toString
- Overrides:
toString
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>>
-
getImplVersion
public int getImplVersion()Description copied from class:AbstractEvolvable
Determine the serialization version supported by the implementing class.- Specified by:
getImplVersion
in interfaceEvolvable
- Overrides:
getImplVersion
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>> - Returns:
- the serialization version supported by this object
-
readExternal
Description copied from interface:PortableObject
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Overrides:
readExternal
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>> - Parameters:
in
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
Description copied from interface:PortableObject
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Overrides:
writeExternal
in classIndexConfig<com.oracle.coherence.ai.index.BinaryQuantIndex<?,
?, ?>> - Parameters:
out
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-