Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.database
Class SpatialIndexDatabase<O extends NumberVector<O,?>,N extends SpatialNode<N,E>,E extends SpatialEntry>

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.IndexDatabase<O>
                  extended by de.lmu.ifi.dbs.elki.database.SpatialIndexDatabase<O,N,E>
All Implemented Interfaces:
Database<O>, Loggable, Parameterizable

public class SpatialIndexDatabase<O extends NumberVector<O,?>,N extends SpatialNode<N,E>,E extends SpatialEntry>
extends IndexDatabase<O>

SpatialIndexDatabase is a database implementation which is supported by a spatial index structure.

Author:
Elke Achtert

Field Summary
protected  SpatialIndex<O,N,E> index
          The index structure storing the data.
static OptionID INDEX_ID
          OptionID for INDEX_PARAM
private  ClassParameter<SpatialIndex> INDEX_PARAM
          Parameter to specify the spatial index to use.
 
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
 
Constructor Summary
SpatialIndexDatabase()
           
 
Method Summary
<D extends Distance<D>>
List<List<QueryResult<D>>>
bulkKNNQueryForID(List<Integer> ids, int k, DistanceFunction<O,D> distanceFunction)
          Performs k-nearest neighbor queries for the given object IDs.
 String description()
          Returns a short description of the database.
 SpatialIndex<O,N,E> getIndex()
          Returns the index of this database.
 List<E> getLeaves()
          Returns a list of the leaf nodes of the underlying spatial index of this database.
 E getRootEntry()
          Returns the id of the root of the underlying index.
 void insert(List<ObjectAndAssociations<O>> objectsAndAssociationsList)
          Calls the super method and afterwards inserts the specified objects into the underlying index structure.
 Integer insert(ObjectAndAssociations<O> objectAndAssociations)
          Calls the super method and afterwards inserts the specified object into the underlying index structure.
<D extends Distance<D>>
List<QueryResult<D>>
kNNQueryForID(Integer id, int k, DistanceFunction<O,D> distanceFunction)
          Performs a k-nearest neighbor query for the given object ID.
<D extends Distance<D>>
List<QueryResult<D>>
kNNQueryForObject(O queryObject, int k, DistanceFunction<O,D> distanceFunction)
          Performs a k-nearest neighbor query for the given object.
<D extends Distance<D>>
List<QueryResult<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<QueryResult<D>>
reverseKNNQuery(Integer id, int k, DistanceFunction<O,D> distanceFunction)
          Performs a reverse k-nearest neighbor query for the given object ID.
 String[] setParameters(String[] args)
          Sets the values for the parameter bulk.
 String toString()
          Returns a string representation of this database.
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.IndexDatabase
delete, delete, getLogicalPageAccess, getPhysicalReadAccess, getPhysicalWriteReadAccess, resetPageAccess
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.AbstractDatabase
addDatabaseListener, associate, associateGlobally, deleteAssociations, dimensionality, fireObjectInserted, fireObjectRemoved, fireObjectsChanged, fireObjectsInserted, fireObjectsRemoved, get, getAssociation, getAssociations, getGlobalAssociation, getIDs, getObjects, 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, checkGlobalParameterConstraints, deleteOption, description, description, getAttributeSettings, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, getAttributeSettings, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

INDEX_ID

public static final OptionID INDEX_ID
OptionID for INDEX_PARAM


INDEX_PARAM

private final ClassParameter<SpatialIndex> INDEX_PARAM
Parameter to specify the spatial index to use.

Key: -spatialindexdb.index


index

protected SpatialIndex<O extends NumberVector<O,?>,N extends SpatialNode<N,E>,E extends SpatialEntry> index
The index structure storing the data.

Constructor Detail

SpatialIndexDatabase

public SpatialIndexDatabase()
Method Detail

insert

public Integer insert(ObjectAndAssociations<O> objectAndAssociations)
               throws UnableToComplyException
Calls the super method and afterwards inserts the specified object into the underlying index structure.

Specified by:
insert in interface Database<O extends NumberVector<O,?>>
Overrides:
insert in class AbstractDatabase<O extends NumberVector<O,?>>
Parameters:
objectAndAssociations - the object and its associations to be inserted
Returns:
the ID assigned to the inserted object
Throws:
UnableToComplyException - if database reached limit of storage capacity
See Also:
Database.insert(ObjectAndAssociations)

insert

public void insert(List<ObjectAndAssociations<O>> objectsAndAssociationsList)
            throws UnableToComplyException
Calls the super method and afterwards inserts the specified objects into the underlying index structure. If the option bulk load is enabled and the index structure is empty, a bulk load will be performed. Otherwise the objects will be inserted sequentially.

Specified by:
insert in interface Database<O extends NumberVector<O,?>>
Overrides:
insert in class AbstractDatabase<O extends NumberVector<O,?>>
Parameters:
objectsAndAssociationsList - the list of objects and their associations to be inserted
Throws:
UnableToComplyException - if initialization is not possible
See Also:
Database.insert(java.util.List)

rangeQuery

public <D extends Distance<D>> List<QueryResult<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 in ascending order to the distance to the query object.

Parameters:
id - the ID of the query object
epsilon - the string representation of the query range
distanceFunction - the distance function that computes the distances beween the objects
Returns:
a List of the query results
See Also:
Database.rangeQuery(Integer,String,de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction)

kNNQueryForObject

public <D extends Distance<D>> List<QueryResult<D>> kNNQueryForObject(O queryObject,
                                                                      int k,
                                                                      DistanceFunction<O,D> distanceFunction)
Description copied from interface: Database
Performs a k-nearest neighbor query for the given object. The query result is in ascending order to the distance to the query object.

Parameters:
queryObject - the query object
k - the number of nearest neighbors to be returned
distanceFunction - the distance function that computes the distances beween the objects
Returns:
a List of the query results
See Also:
Database.kNNQueryForObject(de.lmu.ifi.dbs.elki.data.DatabaseObject,int,de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction)

kNNQueryForID

public <D extends Distance<D>> List<QueryResult<D>> kNNQueryForID(Integer id,
                                                                  int k,
                                                                  DistanceFunction<O,D> distanceFunction)
Description copied from interface: Database
Performs a k-nearest neighbor query for the given object ID. The query result is in ascending order to the distance to the query object.

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 beween the objects
Returns:
a List of the query results
See Also:
Database.kNNQueryForID(Integer,int,de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction)

bulkKNNQueryForID

public <D extends Distance<D>> List<List<QueryResult<D>>> bulkKNNQueryForID(List<Integer> ids,
                                                                            int k,
                                                                            DistanceFunction<O,D> distanceFunction)
Description copied from interface: Database
Performs k-nearest neighbor queries for the given object IDs. The query result is in ascending order to the distance to the query object.

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 beween the objects
Returns:
a List of List of the query results
See Also:
Database.bulkKNNQueryForID(java.util.List,int,de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction)

reverseKNNQuery

public <D extends Distance<D>> List<QueryResult<D>> reverseKNNQuery(Integer id,
                                                                    int k,
                                                                    DistanceFunction<O,D> distanceFunction)
Performs a reverse k-nearest neighbor query for the given object ID. The query result is in ascending order to the distance to the query object.

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 beween the objects
Returns:
a List of the query results

toString

public String toString()
Returns a string representation of this database.

Overrides:
toString in class Object
Returns:
a string representation of this database.

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Sets the values for the parameter bulk. If the parameters is not specified the default value is set.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

getLeaves

public List<E> getLeaves()
Returns a list of the leaf nodes of the underlying spatial index of this database.

Returns:
a list of the leaf nodes of the underlying spatial index of this database

getRootEntry

public E getRootEntry()
Returns the id of the root of the underlying index.

Returns:
the id of the root of the underlying index

getIndex

public SpatialIndex<O,N,E> getIndex()
Returns the index of this database.

Specified by:
getIndex in class IndexDatabase<O extends NumberVector<O,?>>
Returns:
the index of this database

description

public String description()
Returns a short description of the database. (Such as: efficiency in space and time, index structure...)

Specified by:
description in interface Database<O extends NumberVector<O,?>>
Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
a description of the database
See Also:
Parameterizable.description()

Release 0.1 (2008-07-10_1838)