Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.database
Class SequentialDatabase<O extends DatabaseObject>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.database.AbstractDatabase<O>
              extended by de.lmu.ifi.dbs.elki.database.SequentialDatabase<O>
Type Parameters:
O - the type of FeatureVector as element of the database
All Implemented Interfaces:
Database<O>, Result, Parameterizable, Iterable<Integer>

public class SequentialDatabase<O extends DatabaseObject>
extends AbstractDatabase<O>

SequentialDatabase is a simple implementation of a Database.

It does not support any index structure and holds all objects in main memory (as a Map).

Author:
Arthur Zimek

Field Summary
 
Fields inherited from class de.lmu.ifi.dbs.elki.database.AbstractDatabase
listenerList
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
SequentialDatabase()
          Provides a database for main memory holding all objects in a hashtable.
 
Method Summary
<D extends Distance<D>>
List<List<DistanceResultPair<D>>>
bulkKNNQueryForID(List<Integer> ids, int k, DistanceFunction<O,D> distanceFunction)
          Retrieves the k nearest neighbors for the query objects.
<D extends Distance<D>>
List<DistanceResultPair<D>>
kNNQueryForID(Integer id, int k, DistanceFunction<O,D> distanceFunction)
          Retrieves the k nearest neighbors for the query object.
<D extends Distance<D>>
List<DistanceResultPair<D>>
kNNQueryForObject(O queryObject, int k, DistanceFunction<O,D> distanceFunction)
          Retrieves the k nearest neighbors for the query object.
<D extends Distance<D>>
List<DistanceResultPair<D>>
rangeQuery(Integer id, String epsilon, DistanceFunction<O,D> distanceFunction)
          Performs a range query for the given object ID with the given epsilon range and the according distance function.
<D extends Distance<D>>
List<DistanceResultPair<D>>
reverseKNNQuery(Integer id, int k, DistanceFunction<O,D> distanceFunction)
          Performs a reverse k-nearest neighbor query for the given object ID.
 String shortDescription()
          Provides a description for SequentialDatabase.
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.AbstractDatabase
addDatabaseListener, associate, associateGlobally, delete, delete, deleteAssociations, dimensionality, fireObjectInserted, fireObjectRemoved, fireObjectsChanged, fireObjectsInserted, fireObjectsRemoved, get, getAssociation, getAssociations, getGlobalAssociation, getIDs, getObjects, insert, insert, isSet, isSetForAllObjects, isSetGlobally, iterator, partition, partition, randomSample, removeDatabaseListener, restoreID, setAssociations, setNewID, size
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters, setParameters
 

Constructor Detail

SequentialDatabase

public SequentialDatabase()
Provides a database for main memory holding all objects in a hashtable.

Method Detail

kNNQueryForObject

public <D extends Distance<D>> List<DistanceResultPair<D>> kNNQueryForObject(O queryObject,
                                                                             int k,
                                                                             DistanceFunction<O,D> distanceFunction)
Retrieves the k nearest neighbors for the query object. The result contains always exactly k objects, including the query object if it is an element of the database. Ties in case of equal distances are resolved by the underlying KNNList, see KNNList.add(DistanceResultPair).

Type Parameters:
D - distance type
Parameters:
queryObject - the query object
k - the number of nearest neighbors to be returned
distanceFunction - the distance function that computes the distances between the objects
Returns:
a List of the query results
See Also:
Database.kNNQueryForObject(DatabaseObject, int, DistanceFunction)

kNNQueryForID

public <D extends Distance<D>> List<DistanceResultPair<D>> kNNQueryForID(Integer id,
                                                                         int k,
                                                                         DistanceFunction<O,D> distanceFunction)
Retrieves the k nearest neighbors for the query object. The result contains always exactly k objects. Ties in case of equal distances are resolved by the underlying KNNList, see KNNList.add(DistanceResultPair).

Type Parameters:
D - distance type
Parameters:
id - the ID of the query object
k - the number of nearest neighbors to be returned
distanceFunction - the distance function that computes the distances between the objects
Returns:
a List of the query results
See Also:
Database.kNNQueryForObject(DatabaseObject, int, DistanceFunction)

bulkKNNQueryForID

public <D extends Distance<D>> List<List<DistanceResultPair<D>>> bulkKNNQueryForID(List<Integer> ids,
                                                                                   int k,
                                                                                   DistanceFunction<O,D> distanceFunction)
Retrieves the k nearest neighbors for the query objects. The result contains always exactly k objects. Ties in case of equal distances are resolved by the underlying KNNList, see KNNList.add(DistanceResultPair).

Type Parameters:
D - distance type
Parameters:
ids - the IDs of the query objects
k - the number of nearest neighbors to be returned
distanceFunction - the distance function that computes the distances between the objects
Returns:
a List of List of the query results
See Also:
Database.kNNQueryForObject(DatabaseObject, int, DistanceFunction)

rangeQuery

public <D extends Distance<D>> List<DistanceResultPair<D>> rangeQuery(Integer id,
                                                                      String epsilon,
                                                                      DistanceFunction<O,D> distanceFunction)
Description copied from interface: Database

Performs a range query for the given object ID with the given epsilon range and the according distance function.

The query result is sorted in ascending order w.r.t. the distance to the query object.

Type Parameters:
D - distance type
Parameters:
id - the ID of the query object
epsilon - the string representation of the query range
distanceFunction - the distance function that computes the distances between the objects
Returns:
a List of the query results

reverseKNNQuery

public <D extends Distance<D>> List<DistanceResultPair<D>> reverseKNNQuery(Integer id,
                                                                           int k,
                                                                           DistanceFunction<O,D> distanceFunction)
Description copied from interface: Database

Performs a reverse k-nearest neighbor query for the given object ID.

The query result is sorted in ascending order w.r.t. the distance to the query object.

Generally, it is assumed that the database does not contain less than k objects.

Type Parameters:
D - distance type
Parameters:
id - the ID of the query object
k - the size of k-nearest neighborhood of any database object o to contain a database object in order to include o in the result list
distanceFunction - the distance function that computes the distances between the objects
Returns:
a List of the query results

shortDescription

public String shortDescription()
Provides a description for SequentialDatabase.

Specified by:
shortDescription in interface Parameterizable
Overrides:
shortDescription in class AbstractParameterizable
Returns:
Description of the class

Release 0.2 (2009-07-06_1820)