Package com.oracle.coherence.ai.index
Class BinaryQuantIndex<K,V,T>
java.lang.Object
com.tangosol.io.AbstractEvolvable
com.oracle.coherence.ai.index.BinaryQuantIndex<K,V,T>
- Type Parameters:
K- the type of the cache keyV- the type of the cache valueT- the type of the vector
- All Implemented Interfaces:
VectorIndexExtractor<V,,T> CanonicallyNamed,Evolvable,ExternalizableLite,EvolvablePortableObject,PortableObject,IndexAwareExtractor<V,,Vector<T>> Remote.Function<V,,Vector<T>> Remote.ToDoubleFunction<V>,Remote.ToIntFunction<V>,Remote.ToLongFunction<V>,ValueExtractor<V,,Vector<T>> Serializable,Function<V,,Vector<T>> ToDoubleFunction<V>,ToIntFunction<V>,ToLongFunction<V>
public class BinaryQuantIndex<K,V,T>
extends AbstractEvolvable
implements VectorIndexExtractor<V,T>, ExternalizableLite, EvolvablePortableObject
An
VectorIndexExtractor to create a VectorIndex using binary quantization of vectors.
Binary quantization converts any vector of floating point numbers into a vector of bit values.- Since:
- 24.09
- Author:
- Aleks Seovic 2024.07.24, Jonathan Knight 2024.07.26
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe POF implementation version. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for serialization.BinaryQuantIndex(ValueExtractor<V, Vector<T>> extractor) Create aBinaryQuantIndex. -
Method Summary
Modifier and TypeMethodDescriptioncreateIndex(boolean b, Comparator comparator, Map<ValueExtractor<V, Vector<T>>, MapIndex> map, BackingMapContext backingMapContext) Create an index and associate it with the corresponding extractor.destroyIndex(Map<ValueExtractor<V, Vector<T>>, MapIndex> map) Destroy an existing index and remove it from the given map of indexes.booleanThis instance is considered equal to parameterowhen both have same non-nullValueExtractor.getCanonicalName().Extract the value from the passed object.intDetermine the serialization version supported by the implementing class.inthashCode()Return the hashCode for this extractor.oversamplingFactor(int nOversamplingFactor) Set the oversampling factor.voidRestore the contents of a user type instance by reading its state using the specified PofReader object.voidRestore the contents of this object by loading the object's state from the passed DataInput object.toString()voidwriteExternal(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.Methods inherited from class com.tangosol.io.AbstractEvolvable
getDataVersion, getFutureData, setDataVersion, setFutureDataMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.tangosol.io.Evolvable
getDataVersion, getFutureData, setDataVersion, setFutureDataMethods inherited from interface com.tangosol.util.extractor.IndexAwareExtractor
getExtractorMethods inherited from interface com.tangosol.util.function.Remote.Function
andThen, composeMethods inherited from interface com.tangosol.util.ValueExtractor
andThen, apply, applyAsDouble, applyAsInt, applyAsLong, compose, fromKey, getCanonicalName, getTarget
-
Field Details
-
POF_IMPL_VERSION
public static final int POF_IMPL_VERSIONThe POF implementation version.- See Also:
-
-
Constructor Details
-
BinaryQuantIndex
public BinaryQuantIndex()Default constructor for serialization. -
BinaryQuantIndex
Create aBinaryQuantIndex.- Parameters:
extractor- theValueExtractorto use to extract theVector
-
-
Method Details
-
oversamplingFactor
Set the oversampling factor.- Parameters:
nOversamplingFactor- the oversampling factor- Returns:
- this
BinaryQuantIndexfor fluent API calls
-
extract
Description copied from interface:ValueExtractorExtract the value from the passed object. The returned value may be null. For intrinsic types, the returned value is expected to be a standard wrapper type in the same manner that reflection works; for example, int would be returned as a java.lang.Integer.- Specified by:
extractin interfaceValueExtractor<K,V> - Parameters:
v- the object to extract the value from- Returns:
- the extracted value; null is an acceptable value
-
createIndex
public MapIndex<K,V, createIndexVector<T>> (boolean b, Comparator comparator, Map<ValueExtractor<V, Vector<T>>, MapIndex> map, BackingMapContext backingMapContext) Description copied from interface:IndexAwareExtractorCreate an index and associate it with the corresponding extractor. Important note: it is a responsibility of this method's implementations to place the necessary <ValueExtractor, MapIndex> entry into the given map of indexes.- Specified by:
createIndexin interfaceIndexAwareExtractor<K,V> - Parameters:
b- true iff the contents of the indexed information should be ordered; false otherwisecomparator- the Comparator object which imposes an ordering of entries in the index contents; or null if the entries' values natural ordering should be usedmap- Map<ValueExtractor, MapIndex> to be updated with the created indexbackingMapContext- Thecontextthe index is associate with.- Returns:
- the created index; null if the index has not been created
-
destroyIndex
Description copied from interface:IndexAwareExtractorDestroy an existing index and remove it from the given map of indexes.- Specified by:
destroyIndexin interfaceIndexAwareExtractor<K,V> - Parameters:
map- map<ValueExtractor, MapIndex> to be updated by removing the index being destroyed- Returns:
- the destroyed index; null if the index does not exist
-
equals
Description copied from interface:ValueExtractorThis instance is considered equal to parameterowhen both have same non-nullValueExtractor.getCanonicalName().Note: Fall back to implementation specific equals/hashCode when both canonical names are
null. -
hashCode
public int hashCode()Description copied from interface:ValueExtractorReturn the hashCode for this extractor.Note two extractors with the same non-null
canonical nameare expected to also have the same hashCode.Note: Fall back to implementation specific equals/hashCode when canonical name is
null. -
toString
-
getImplVersion
public int getImplVersion()Description copied from class:AbstractEvolvableDetermine the serialization version supported by the implementing class.- Specified by:
getImplVersionin interfaceEvolvable- Specified by:
getImplVersionin classAbstractEvolvable- Returns:
- the serialization version supported by this object
-
readExternal
Description copied from interface:PortableObjectRestore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternalin interfacePortableObject- 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:PortableObjectSave the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternalin interfacePortableObject- Parameters:
out- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
readExternal
Description copied from interface:ExternalizableLiteRestore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternalin interfaceExternalizableLite- Parameters:
in- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException- if an I/O exception occurs
-
writeExternal
Description copied from interface:ExternalizableLiteSave the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternalin interfaceExternalizableLite- Parameters:
out- the DataOutput stream to write the state of this object to- Throws:
IOException- if an I/O exception occurs
-