Package com.oracle.coherence.ai.distance
Class AbstractDistance<T>
java.lang.Object
com.oracle.coherence.ai.distance.AbstractDistance<T>
- Type Parameters:
T- the type of the vector the algorithm uses
- All Implemented Interfaces:
DistanceAlgorithm<T>,ExternalizableLite,PortableObject,Serializable
- Direct Known Subclasses:
CosineDistance,InnerProductDistance,L2SquaredDistance
public abstract class AbstractDistance<T>
extends Object
implements DistanceAlgorithm<T>, ExternalizableLite, PortableObject
A base class for
distance algorithm implementations.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract doubledistance(byte[] v1, byte[] v2) Calculate the distance between two Int8 (byte) vectors.protected abstract doubledistance(float[] v1, float[] v2) Calculate the distance between two Float32 (float) vectors.doubleCalculate the distance between the specified vectors.protected abstract doubleCalculate the distance between two bit vectors.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.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.
-
Constructor Details
-
AbstractDistance
public AbstractDistance()
-
-
Method Details
-
distance
Description copied from interface:DistanceAlgorithmCalculate the distance between the specified vectors.- Specified by:
distancein interfaceDistanceAlgorithm<T>- Parameters:
v1- the vector to calculate the distance fromv2- the vector to calculate the distance to- Returns:
- the distance between the specified vectors
-
distance
Calculate the distance between two bit vectors.- Parameters:
v1- the first bit vectorv2- the second bit vector- Returns:
- the distance between the two bit vectors
-
distance
protected abstract double distance(byte[] v1, byte[] v2) Calculate the distance between two Int8 (byte) vectors.- Parameters:
v1- the first Int8 vectorv2- the second Int8 vector- Returns:
- the distance between the two Int8 vectors
-
distance
protected abstract double distance(float[] v1, float[] v2) Calculate the distance between two Float32 (float) vectors.- Parameters:
v1- the first Float32 vectorv2- the second Float32 vector- Returns:
- the distance between the two Float32 vectors
-
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
-
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
-