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 key
V - the type of the cache value
T - 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:
  • Field Details

    • POF_IMPL_VERSION

      public static final int POF_IMPL_VERSION
      The POF implementation version.
      See Also:
  • Constructor Details

  • Method Details

    • oversamplingFactor

      public BinaryQuantIndex<K,V,T> oversamplingFactor(int nOversamplingFactor)
      Set the oversampling factor.
      Parameters:
      nOversamplingFactor - the oversampling factor
      Returns:
      this BinaryQuantIndex for fluent API calls
    • extract

      public Vector<T> extract(V v)
      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 interface ValueExtractor<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,Vector<T>> createIndex(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 interface IndexAwareExtractor<K,V>
      Parameters:
      b - true iff the contents of the indexed information should be ordered; false otherwise
      comparator - the Comparator object which imposes an ordering of entries in the index contents; or null if the entries' values natural ordering should be used
      map - Map<ValueExtractor, MapIndex> to be updated with the created index
      backingMapContext - The context the index is associate with.
      Returns:
      the created index; null if the index has not been created
    • destroyIndex

      public MapIndex<K,V,Vector<T>> destroyIndex(Map<ValueExtractor<V,Vector<T>>,MapIndex> map)
      Description copied from interface: IndexAwareExtractor
      Destroy an existing index and remove it from the given map of indexes.
      Specified by:
      destroyIndex in interface IndexAwareExtractor<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

      public boolean equals(Object o)
      Description copied from interface: ValueExtractor
      This instance is considered equal to parameter o when both have same non-null ValueExtractor.getCanonicalName().

      Note: Fall back to implementation specific equals/hashCode when both canonical names are null.

      Specified by:
      equals in interface ValueExtractor<K,V>
      Overrides:
      equals in class Object
      Returns:
      true iff the extractors are deemed to be equal
    • 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.

      Specified by:
      hashCode in interface ValueExtractor<K,V>
      Overrides:
      hashCode in class Object
      Returns:
      hashCode computed from non-null canonical name.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getImplVersion

      public int getImplVersion()
      Description copied from class: AbstractEvolvable
      Determine the serialization version supported by the implementing class.
      Specified by:
      getImplVersion in interface Evolvable
      Specified by:
      getImplVersion in class AbstractEvolvable
      Returns:
      the serialization version supported by this object
    • readExternal

      public void readExternal(PofReader in) throws IOException
      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 interface PortableObject
      Parameters:
      in - the PofReader from which to read the object's state
      Throws:
      IOException - if an I/O error occurs
    • writeExternal

      public void writeExternal(PofWriter out) throws IOException
      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 interface PortableObject
      Parameters:
      out - the PofWriter to which to write the object's state
      Throws:
      IOException - if an I/O error occurs
    • readExternal

      public void readExternal(DataInput in) throws IOException
      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 interface ExternalizableLite
      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

      public void writeExternal(DataOutput out) throws IOException
      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 interface ExternalizableLite
      Parameters:
      out - the DataOutput stream to write the state of this object to
      Throws:
      IOException - if an I/O exception occurs