net.obsearch.dimension
Class DimensionByte

java.lang.Object
  extended by net.obsearch.dimension.AbstractDimension
      extended by net.obsearch.dimension.DimensionByte
All Implemented Interfaces:
Comparable<DimensionByte>

public class DimensionByte
extends net.obsearch.dimension.AbstractDimension
implements Comparable<DimensionByte>

DimensionByte Stores objects of type byte.

Author:
Arnoldo Jose Muller Molina

Constructor Summary
DimensionByte(int position, byte value)
          Creates a new DimensionByte object.
 
Method Summary
 int compareTo(DimensionByte other)
          Compares this object with other.
static byte euclidean(byte[] a, byte[] b)
          Calculates the euc distance for two tuples
static byte[] getBasicTuple(OBByte[] pivots, OBByte object)
          Creates a byte array from the given pivots and the given object.
static byte[] getPrimitiveTuple(long[] pivots, long objectId, net.obsearch.Index<? extends OBByte> index)
          Calculates the smap tuple for the given objectId, and the given pivots
static byte[] getPrimitiveTuple(OBByte[] pivots, OBByte object)
          Calculates the smap tuple for the given objectId, and the given pivots
static DimensionByte[] getTuple(long[] pivots, long objectId, net.obsearch.Index<? extends OBByte> index)
          Creates a dimension array from the given pivots and the given object id.
static DimensionByte[] getTuple(OBByte[] pivots, OBByte object)
          Creates a dimension array from the given pivots and the given object.
 byte getValue()
           
static byte lInfinite(byte[] a, byte[] b)
          Calculates L-inf for two byte tuples.
static byte minDistance(List<Long> objects, net.obsearch.Index<OBByte> index)
          Calculate the minimum distance of the given objects (all objects compared against all objects)
static long[] select(int k, Random r, cern.colt.list.LongArrayList source, net.obsearch.Index<OBByte> index, cern.colt.list.LongArrayList excludes, byte minDistance)
          Selects k random elements from the given source.
static DimensionByte[] transformPrimitiveTuple(byte[] tuple)
          Transform the given primitive tuple into a Dimension tuple.
 
Methods inherited from class net.obsearch.dimension.AbstractDimension
getOrder, mapId, max, select
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DimensionByte

public DimensionByte(int position,
                     byte value)
Creates a new DimensionByte object.

Parameters:
position - The position of this dimension.
value - The value of this dimension.
Method Detail

getTuple

public static DimensionByte[] getTuple(OBByte[] pivots,
                                       OBByte object)
                                throws net.obsearch.exception.IllegalIdException,
                                       IllegalAccessException,
                                       InstantiationException,
                                       net.obsearch.exception.OBException
Creates a dimension array from the given pivots and the given object.

Parameters:
pivots - The pivots used for the embedding.
object - The object to be projected.
Returns:
A new dimension array.
Throws:
net.obsearch.exception.IllegalIdException
IllegalAccessException
InstantiationException
net.obsearch.exception.OBException

select

public static long[] select(int k,
                            Random r,
                            cern.colt.list.LongArrayList source,
                            net.obsearch.Index<OBByte> index,
                            cern.colt.list.LongArrayList excludes,
                            byte minDistance)
                     throws net.obsearch.exception.IllegalIdException,
                            net.obsearch.exception.OBException,
                            IllegalAccessException,
                            InstantiationException
Selects k random elements from the given source.

Parameters:
k - number of elements to select
r - Random object used to randomly select objects.
source - The source of item ids.
index - underlying index.
will - not add pivots included in excludes.
minDistance - The min distance required by the objects.
Returns:
The ids of selected objects.
Throws:
net.obsearch.exception.IllegalIdException
net.obsearch.exception.OBException
IllegalAccessException
InstantiationException

minDistance

public static byte minDistance(List<Long> objects,
                               net.obsearch.Index<OBByte> index)
                        throws net.obsearch.exception.IllegalIdException,
                               net.obsearch.exception.OBException,
                               IllegalAccessException,
                               InstantiationException
Calculate the minimum distance of the given objects (all objects compared against all objects)

Parameters:
objects -
Returns:
the min distance
Throws:
net.obsearch.exception.IllegalIdException
net.obsearch.exception.OBException
IllegalAccessException
InstantiationException

getBasicTuple

public static byte[] getBasicTuple(OBByte[] pivots,
                                   OBByte object)
                            throws net.obsearch.exception.IllegalIdException,
                                   IllegalAccessException,
                                   InstantiationException,
                                   net.obsearch.exception.OBException
Creates a byte array from the given pivots and the given object.

Parameters:
pivots - The pivots used for the embedding.
object - The object to be projected.
Returns:
A new byte array.
Throws:
net.obsearch.exception.IllegalIdException
IllegalAccessException
InstantiationException
net.obsearch.exception.OBException

getTuple

public static DimensionByte[] getTuple(long[] pivots,
                                       long objectId,
                                       net.obsearch.Index<? extends OBByte> index)
                                throws net.obsearch.exception.IllegalIdException,
                                       IllegalAccessException,
                                       InstantiationException,
                                       net.obsearch.exception.OBException
Creates a dimension array from the given pivots and the given object id. Loads the objects from the DB.

Throws:
net.obsearch.exception.IllegalIdException
IllegalAccessException
InstantiationException
net.obsearch.exception.OBException

compareTo

public int compareTo(DimensionByte other)
Compares this object with other.

Specified by:
compareTo in interface Comparable<DimensionByte>

getValue

public byte getValue()

getPrimitiveTuple

public static byte[] getPrimitiveTuple(long[] pivots,
                                       long objectId,
                                       net.obsearch.Index<? extends OBByte> index)
                                throws net.obsearch.exception.IllegalIdException,
                                       IllegalAccessException,
                                       InstantiationException,
                                       net.obsearch.exception.OBException
Calculates the smap tuple for the given objectId, and the given pivots

Parameters:
pivots -
objectId -
Returns:
Throws:
net.obsearch.exception.IllegalIdException
IllegalAccessException
InstantiationException
net.obsearch.exception.OBException

transformPrimitiveTuple

public static DimensionByte[] transformPrimitiveTuple(byte[] tuple)
Transform the given primitive tuple into a Dimension tuple.

Parameters:
tuple - The tuple that will be transformed.
Returns:
A DimensionByte of dimensions.

getPrimitiveTuple

public static byte[] getPrimitiveTuple(OBByte[] pivots,
                                       OBByte object)
                                throws net.obsearch.exception.IllegalIdException,
                                       IllegalAccessException,
                                       InstantiationException,
                                       net.obsearch.exception.OBException
Calculates the smap tuple for the given objectId, and the given pivots

Parameters:
pivots -
objectId -
Returns:
Throws:
net.obsearch.exception.IllegalIdException
IllegalAccessException
InstantiationException
net.obsearch.exception.OBException

lInfinite

public static byte lInfinite(byte[] a,
                             byte[] b)
Calculates L-inf for two byte tuples.

Parameters:
a - tuple
b - tuple
Returns:
L-infinite for a and b.

euclidean

public static byte euclidean(byte[] a,
                             byte[] b)
Calculates the euc distance for two tuples

Parameters:
a - tuple
b - tuple
Returns:
L-infinite for a and b.


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.