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 int
The 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.boolean
This instance is considered equal to parametero
when both have same non-nullValueExtractor.getCanonicalName()
.Extract the value from the passed object.int
Determine the serialization version supported by the implementing class.int
hashCode()
Return the hashCode for this extractor.oversamplingFactor
(int nOversamplingFactor) Set the oversampling factor.void
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore the contents of this object by loading the object's state from the passed DataInput object.toString()
void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(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, setFutureData
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.tangosol.io.Evolvable
getDataVersion, getFutureData, setDataVersion, setFutureData
Methods inherited from interface com.tangosol.util.extractor.IndexAwareExtractor
getExtractor
Methods inherited from interface com.tangosol.util.function.Remote.Function
andThen, compose
Methods 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
- theValueExtractor
to use to extract theVector
-
-
Method Details
-
oversamplingFactor
Set the oversampling factor.- Parameters:
nOversamplingFactor
- the oversampling factor- Returns:
- this
BinaryQuantIndex
for fluent API calls
-
extract
Description copied from interface:ValueExtractor
Extract 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:
extract
in 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:IndexAwareExtractor
Create 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:
createIndex
in 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
- Thecontext
the index is associate with.- Returns:
- the created index; null if the index has not been created
-
destroyIndex
Description copied from interface:IndexAwareExtractor
Destroy an existing index and remove it from the given map of indexes.- Specified by:
destroyIndex
in 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:ValueExtractor
This instance is considered equal to parametero
when 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:ValueExtractor
Return the hashCode for this extractor.Note two extractors with the same non-null
canonical name
are 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:AbstractEvolvable
Determine the serialization version supported by the implementing class.- Specified by:
getImplVersion
in interfaceEvolvable
- Specified by:
getImplVersion
in classAbstractEvolvable
- 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
- 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
- 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:ExternalizableLite
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in 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:ExternalizableLite
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-