ostore.introspect
Class SemanticDistanceModel.Table

java.lang.Object
  |
  +--ostore.introspect.SemanticDistanceModel.Table
All Implemented Interfaces:
QuickSerializable
Enclosing class:
SemanticDistanceModel

public static class SemanticDistanceModel.Table
extends Object
implements QuickSerializable

The actual semantic distance table.

Version:
$Id: SemanticDistanceModel.java,v 1.11 2003/11/17 23:52:43 emilong Exp $
Author:
Jeff Pang

Field Summary
static String class_tag
           
 
Constructor Summary
SemanticDistanceModel.Table(InputBuffer buffer)
           
SemanticDistanceModel.Table(int bound, Time now)
          Constructor.
 
Method Summary
 int getClients()
          Get the number of clients represented by this model.
 Distance getDistance(QuickSerializable from, QuickSerializable to)
          Get the distance between observations from and to.
 Iterator getDistances(QuickSerializable from)
          Get a sorted iterator of the distances between from and other types.
 Set getKeys()
          Get the set of all observation types known.
protected  SemanticDistanceModel.BoundedPrioQueue getQueue(QuickSerializable key)
          Get the queue of distances associated with key
protected  Time getTime(QuickSerializable key)
          Get the last time we saw this observation
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 void setClients(int clients)
          Set the number of clients represented by this model
 void setDistance(SemanticDistanceModel.Filter filter, QuickSerializable from, QuickSerializable to, Distance d)
          Explicitly set the distance between observation type from and to.
 void setMaxRelations(int num)
          Set the maximum number of distances to keep for each observation type.
protected  void setTime(QuickSerializable key, Time time)
          Set the last time we saw this observation
 String toString()
          Warning: this method takes O(n^2) time.
 void update(SemanticDistanceModel.Filter filter, QSVector times)
          Update the semantic distance table with the observations parameterized by type and time.
protected  void update(SemanticDistanceModel.Filter filter, QuickSerializable key, SemanticDistanceModel.BoundedPrioQueue oq, Distance oage, int oclients, Time access_time)
          Update one row of the semantic distance table with the distance values from the other table.
 void update(SemanticDistanceModel.Filter filter, QuickSerializable type, Time time)
          Update the semantic distance table with the observation parameterized by type and time.
 void update(SemanticDistanceModel.Filter filter, SemanticDistanceModel.Table other, boolean save_times)
          Update the semantic distance table with the distance values from the other table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

class_tag

public static final String class_tag
See Also:
Constant Field Values
Constructor Detail

SemanticDistanceModel.Table

public SemanticDistanceModel.Table(int bound,
                                   Time now)
Constructor.

Parameters:
bound - the max number of relations per table row.
now - the time this model was created.

SemanticDistanceModel.Table

public SemanticDistanceModel.Table(InputBuffer buffer)
                            throws QSException
Method Detail

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface QuickSerializable
Parameters:
buffer - the output buffer to add the object to

update

public void update(SemanticDistanceModel.Filter filter,
                   QSVector times)
Update the semantic distance table with the observations parameterized by type and time.

Parameters:
filter - the filter used to recalculate the semantic distance
times - new observations in a Vector< QuickSerializable type, Time time >.

update

public void update(SemanticDistanceModel.Filter filter,
                   QuickSerializable type,
                   Time time)
Update the semantic distance table with the observation parameterized by type and time.

Parameters:
filter - the filter used to recalculate the semantic distance
type - the type of observation
time - the time it was observed

update

public void update(SemanticDistanceModel.Filter filter,
                   SemanticDistanceModel.Table other,
                   boolean save_times)
Update the semantic distance table with the distance values from the other table. This distances and age of the table is updated -- the number of clients represented is NOT updated.

Parameters:
filter - the filter used to recalculate the semantic distance
other - the other table to incorporate values from
save_times - save the latest access times from the other table if they are more recent than the ones in our current table.

update

protected void update(SemanticDistanceModel.Filter filter,
                      QuickSerializable key,
                      SemanticDistanceModel.BoundedPrioQueue oq,
                      Distance oage,
                      int oclients,
                      Time access_time)
Update one row of the semantic distance table with the distance values from the other table.

Parameters:
filter - the filter used to recalculate the semantic distance
key - the row to update (distances from this type)
oq - the queue of new distances
oage - the age of the new distances
oclients - the number of clients represented by new distances
access_time - update the latest access time of this key to this value if this value is > the last access time. If this value is null, do not update the latest access time.

setMaxRelations

public void setMaxRelations(int num)
Set the maximum number of distances to keep for each observation type. The table keeps around the num semantically closest values for each observation type.

Parameters:
num - the new max number of distances.

getDistance

public Distance getDistance(QuickSerializable from,
                            QuickSerializable to)
Get the distance between observations from and to.

Parameters:
from - the type from
to - the type to
Returns:
the distance from from to to null if from is not a known type.

getDistances

public Iterator getDistances(QuickSerializable from)
Get a sorted iterator of the distances between from and other types.

Parameters:
from - the type from
Returns:
an Iterator<Tuple> of the distances between from and other types. null if from is not a known type.

getTime

protected Time getTime(QuickSerializable key)
Get the last time we saw this observation

Parameters:
key - the type of the observation
Returns:
the last access time of the observation

setTime

protected void setTime(QuickSerializable key,
                       Time time)
Set the last time we saw this observation

Parameters:
key - the type of the observation
time - the time to set it to

getQueue

protected SemanticDistanceModel.BoundedPrioQueue getQueue(QuickSerializable key)
Get the queue of distances associated with key

Parameters:
key - the type from
Returns:
the bounded prio queue associated with key

getKeys

public Set getKeys()
Get the set of all observation types known.

Returns:
Set<QuickSerializable obs> of all known obs types

setDistance

public void setDistance(SemanticDistanceModel.Filter filter,
                        QuickSerializable from,
                        QuickSerializable to,
                        Distance d)
Explicitly set the distance between observation type from and to.

Parameters:
from - the from observation type.
to - the to observation type.
d - the distance to set it to.

setClients

public void setClients(int clients)
Set the number of clients represented by this model


getClients

public int getClients()
Get the number of clients represented by this model.


toString

public String toString()
Warning: this method takes O(n^2) time.

Overrides:
toString in class Object