de.lmu.ifi.dbs.elki.database
Class AbstractDatabase

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.result.AbstractHierarchicalResult
      extended by de.lmu.ifi.dbs.elki.database.AbstractDatabase
All Implemented Interfaces:
Database, HierarchicalResult, Result
Direct Known Subclasses:
HashmapDatabase, ProxyDatabase, StaticArrayDatabase

public abstract class AbstractDatabase
extends AbstractHierarchicalResult
implements Database

Abstract base class for database API implementations. Provides default management of relations, indexes and events as well as default query matching.


Field Summary
protected  DatabaseEventManager eventManager
          The event manager, collects events and fires them on demand.
static OptionID INDEX_ID
          Parameter to specify the indexes to use.
protected  List<Index> indexes
          Indexes
protected  Collection<IndexFactory<?,?>> indexFactories
          Index factories
protected  List<Relation<?>> relations
          The relations we manage.
 
Constructor Summary
AbstractDatabase()
          Constructor.
 
Method Summary
 void accumulateDataStoreEvents()
          Collects all insertion, deletion and update events until Database.flushDataStoreEvents() is called.
 void addDataStoreListener(DataStoreListener l)
          Adds a listener for the DataStoreEvent posted after the content of the database changes.
 void addIndex(Index index)
          Add a new index to the database.
 void flushDataStoreEvents()
          Fires all collected insertion, deletion and update events as one DataStoreEvent, i.e. notifies all registered DataStoreListener how the content of the database has been changed since Database.accumulateDataStoreEvents() has been called.
 SingleObjectBundle getBundle(DBID id)
          Returns the DatabaseObject represented by the specified id.
<O,D extends Distance<D>>
DistanceQuery<O,D>
getDistanceQuery(Relation<O> objQuery, DistanceFunction<? super O,D> distanceFunction, Object... hints)
          Get the distance query for a particular distance function.
 Collection<Index> getIndexes()
          Collection of known indexes
<O,D extends Distance<D>>
KNNQuery<O,D>
getKNNQuery(DistanceQuery<O,D> distanceQuery, Object... hints)
          Get a KNN query object for the given distance query.
protected abstract  Logging getLogger()
           
 String getLongName()
          A "pretty" name for the result, for use in titles, captions and menus.
<O,D extends Distance<D>>
RangeQuery<O,D>
getRangeQuery(DistanceQuery<O,D> distanceQuery, Object... hints)
          Get a range query object for the given distance query.
<O> Relation<O>
getRelation(TypeInformation restriction, Object... hints)
          Get an object representation.
 Collection<Relation<?>> getRelations()
          Get all relations of a database.
<O,D extends Distance<D>>
RKNNQuery<O,D>
getRKNNQuery(DistanceQuery<O,D> distanceQuery, Object... hints)
          Get a rKNN query object for the given distance query.
 String getShortName()
          A short name for the result, useful for file names.
<O,D extends Distance<D>>
SimilarityQuery<O,D>
getSimilarityQuery(Relation<O> objQuery, SimilarityFunction<? super O,D> similarityFunction, Object... hints)
          Get the similarity query for a particular similarity function.
 void removeDataStoreListener(DataStoreListener l)
          Removes a listener previously added with Database.addDataStoreListener(DataStoreListener).
 void removeIndex(Index index)
          Remove a particular index
 
Methods inherited from class de.lmu.ifi.dbs.elki.result.AbstractHierarchicalResult
addChildResult, getHierarchy, setHierarchy
 
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.database.Database
getDBIDs, initialize, size
 
Methods inherited from interface de.lmu.ifi.dbs.elki.result.HierarchicalResult
getHierarchy, setHierarchy
 

Field Detail

INDEX_ID

public static final OptionID INDEX_ID
Parameter to specify the indexes to use.

Key: -db.index


eventManager

protected final DatabaseEventManager eventManager
The event manager, collects events and fires them on demand.


relations

protected final List<Relation<?>> relations
The relations we manage.


indexes

protected final List<Index> indexes
Indexes


indexFactories

protected final Collection<IndexFactory<?,?>> indexFactories
Index factories

Constructor Detail

AbstractDatabase

public AbstractDatabase()
Constructor.

Method Detail

addIndex

public void addIndex(Index index)
Description copied from interface: Database
Add a new index to the database.

Specified by:
addIndex in interface Database
Parameters:
index - Index to add

getIndexes

public Collection<Index> getIndexes()
Description copied from interface: Database
Collection of known indexes

Specified by:
getIndexes in interface Database

removeIndex

public void removeIndex(Index index)
Description copied from interface: Database
Remove a particular index

Specified by:
removeIndex in interface Database
Parameters:
index - Index to remove

getBundle

public SingleObjectBundle getBundle(DBID id)
Description copied from interface: Database
Returns the DatabaseObject represented by the specified id.

Specified by:
getBundle in interface Database
Parameters:
id - the id of the Object to be obtained from the Database
Returns:
Bundle containing the objects' data

getRelations

public Collection<Relation<?>> getRelations()
Description copied from interface: Database
Get all relations of a database.

Specified by:
getRelations in interface Database
Returns:
All relations in the database

getRelation

public <O> Relation<O> getRelation(TypeInformation restriction,
                                   Object... hints)
                        throws NoSupportedDataTypeException
Description copied from interface: Database
Get an object representation.

Specified by:
getRelation in interface Database
Type Parameters:
O - Object type
Parameters:
restriction - Type restriction
hints - Optimizer hints
Returns:
representation
Throws:
NoSupportedDataTypeException

getDistanceQuery

public <O,D extends Distance<D>> DistanceQuery<O,D> getDistanceQuery(Relation<O> objQuery,
                                                                     DistanceFunction<? super O,D> distanceFunction,
                                                                     Object... hints)
Description copied from interface: Database
Get the distance query for a particular distance function.

Specified by:
getDistanceQuery in interface Database
Type Parameters:
O - Object type
D - Distance result type
Parameters:
objQuery - Relation used
distanceFunction - Distance function to use
hints - Optimizer hints
Returns:
Instance to query the database with this distance

getSimilarityQuery

public <O,D extends Distance<D>> SimilarityQuery<O,D> getSimilarityQuery(Relation<O> objQuery,
                                                                         SimilarityFunction<? super O,D> similarityFunction,
                                                                         Object... hints)
Description copied from interface: Database
Get the similarity query for a particular similarity function.

Specified by:
getSimilarityQuery in interface Database
Type Parameters:
O - Object type
D - Similarity result type
Parameters:
objQuery - Relation used
similarityFunction - Similarity function to use
hints - Optimizer hints
Returns:
Instance to query the database with this similarity

getKNNQuery

public <O,D extends Distance<D>> KNNQuery<O,D> getKNNQuery(DistanceQuery<O,D> distanceQuery,
                                                           Object... hints)
Description copied from interface: Database
Get a KNN query object for the given distance query. When possible, this will use an index, but it may default to an expensive linear scan. Hints include:

Specified by:
getKNNQuery in interface Database
Type Parameters:
O - Object type
D - Distance type
Parameters:
distanceQuery - Distance query
hints - Optimizer hints
Returns:
KNN Query object

getRangeQuery

public <O,D extends Distance<D>> RangeQuery<O,D> getRangeQuery(DistanceQuery<O,D> distanceQuery,
                                                               Object... hints)
Description copied from interface: Database
Get a range query object for the given distance query. When possible, this will use an index, but it may default to an expensive linear scan. Hints include:

Specified by:
getRangeQuery in interface Database
Type Parameters:
O - Object type
D - Distance type
Parameters:
distanceQuery - Distance query
hints - Optimizer hints
Returns:
KNN Query object

getRKNNQuery

public <O,D extends Distance<D>> RKNNQuery<O,D> getRKNNQuery(DistanceQuery<O,D> distanceQuery,
                                                             Object... hints)
Description copied from interface: Database
Get a rKNN query object for the given distance query. When possible, this will use an index, but it may default to an expensive linear scan. Hints include:

Specified by:
getRKNNQuery in interface Database
Type Parameters:
O - Object type
D - Distance type
Parameters:
distanceQuery - Distance query
hints - Optimizer hints
Returns:
KNN Query object

addDataStoreListener

public void addDataStoreListener(DataStoreListener l)
Description copied from interface: Database
Adds a listener for the DataStoreEvent posted after the content of the database changes.

Specified by:
addDataStoreListener in interface Database
Parameters:
l - the listener to add
See Also:
Database.removeDataStoreListener(DataStoreListener), DataStoreListener, DataStoreEvent

removeDataStoreListener

public void removeDataStoreListener(DataStoreListener l)
Description copied from interface: Database
Removes a listener previously added with Database.addDataStoreListener(DataStoreListener).

Specified by:
removeDataStoreListener in interface Database
Parameters:
l - the listener to remove
See Also:
Database.addDataStoreListener(DataStoreListener), DataStoreListener, DataStoreEvent

accumulateDataStoreEvents

public void accumulateDataStoreEvents()
Description copied from interface: Database
Collects all insertion, deletion and update events until Database.flushDataStoreEvents() is called.

Specified by:
accumulateDataStoreEvents in interface Database
See Also:
DataStoreEvent

flushDataStoreEvents

public void flushDataStoreEvents()
Description copied from interface: Database
Fires all collected insertion, deletion and update events as one DataStoreEvent, i.e. notifies all registered DataStoreListener how the content of the database has been changed since Database.accumulateDataStoreEvents() has been called.

Specified by:
flushDataStoreEvents in interface Database
See Also:
DataStoreListener, DataStoreEvent

getLongName

public String getLongName()
Description copied from interface: Result
A "pretty" name for the result, for use in titles, captions and menus.

Specified by:
getLongName in interface Result
Returns:
result name

getShortName

public String getShortName()
Description copied from interface: Result
A short name for the result, useful for file names.

Specified by:
getShortName in interface Result
Returns:
result name

getLogger

protected abstract Logging getLogger()

Release 0.4.0 (2011-09-20_1324)