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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.result.AbstractHierarchicalResult
      extended by de.lmu.ifi.dbs.elki.database.AbstractDatabase
          extended by de.lmu.ifi.dbs.elki.database.HashmapDatabase
All Implemented Interfaces:
Database, UpdatableDatabase, HierarchicalResult, Result, InspectionUtilFrequentlyScanned, Parameterizable

@Description(value="Database using an in-memory hashtable and at least providing linear scans.")
public class HashmapDatabase
extends AbstractDatabase
implements UpdatableDatabase, Parameterizable

Provides a mapping for associations based on a Hashtable and functions to get the next usable ID for insertion, making IDs reusable after deletion of the entry.


Nested Class Summary
static class HashmapDatabase.Parameterizer
          Parameterization class.
 
Field Summary
protected  DatabaseConnection databaseConnection
          The data source we get the initial data from.
private  DBIDView idrep
          The DBID representation we use
private  TreeSetModifiableDBIDs ids
          IDs of this database
private static Logging logger
          Our logger
 
Fields inherited from class de.lmu.ifi.dbs.elki.database.AbstractDatabase
eventManager, INDEX_ID, indexes, indexFactories, relations
 
Constructor Summary
HashmapDatabase()
          Constructor with no indexes.
HashmapDatabase(DatabaseConnection databaseConnection, Collection<IndexFactory<?,?>> indexFactories)
          Constructor.
 
Method Summary
private  Relation<?> addNewRelation(SimpleTypeInformation<?> meta)
          Add a new representation for the given meta.
protected  Relation<?>[] alignColumns(ObjectBundle pack)
          Find a mapping from package columns to database columns, eventually adding new database columns when needed.
 MultipleObjectsBundle delete(DBIDs ids)
          Removes the objects from the database (by calling doDelete(DBID) for each object) and indexes and fires a deletion event.
private  void doDelete(DBID id)
          Removes the object with the specified id from this database.
 StaticDBIDs getDBIDs()
          Deprecated. 
protected  Logging getLogger()
           
 void initialize()
          Initialize the database by getting the initial data from the database connection.
 DBIDs insert(ObjectBundle objpackages)
          Inserts the given object(s) and their associations into the database.
private  void restoreID(DBID id)
          Makes the given id reusable for new insertion operations.
 int size()
          Deprecated. 
 
Methods inherited from class de.lmu.ifi.dbs.elki.database.AbstractDatabase
accumulateDataStoreEvents, addDataStoreListener, addIndex, flushDataStoreEvents, getBundle, getDistanceQuery, getIndexes, getKNNQuery, getLongName, getRangeQuery, getRelation, getRelations, getRKNNQuery, getShortName, getSimilarityQuery, removeDataStoreListener, removeIndex
 
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
accumulateDataStoreEvents, addDataStoreListener, addIndex, flushDataStoreEvents, getBundle, getDistanceQuery, getIndexes, getKNNQuery, getRangeQuery, getRelation, getRelations, getRKNNQuery, getSimilarityQuery, removeDataStoreListener, removeIndex
 
Methods inherited from interface de.lmu.ifi.dbs.elki.result.HierarchicalResult
getHierarchy, setHierarchy
 
Methods inherited from interface de.lmu.ifi.dbs.elki.result.Result
getLongName, getShortName
 

Field Detail

logger

private static final Logging logger
Our logger


ids

private TreeSetModifiableDBIDs ids
IDs of this database


idrep

private final DBIDView idrep
The DBID representation we use


databaseConnection

protected DatabaseConnection databaseConnection
The data source we get the initial data from.

Constructor Detail

HashmapDatabase

public HashmapDatabase(DatabaseConnection databaseConnection,
                       Collection<IndexFactory<?,?>> indexFactories)
Constructor.

Parameters:
databaseConnection - Database connection to get the initial data from.
indexFactories - Indexes to add

HashmapDatabase

public HashmapDatabase()
Constructor with no indexes.

Method Detail

initialize

public void initialize()
Initialize the database by getting the initial data from the database connection.

Specified by:
initialize in interface Database

insert

public DBIDs insert(ObjectBundle objpackages)
Description copied from interface: UpdatableDatabase
Inserts the given object(s) and their associations into the database.

Specified by:
insert in interface UpdatableDatabase
Parameters:
objpackages - the objects to be inserted
Returns:
the IDs assigned to the inserted objects

alignColumns

protected Relation<?>[] alignColumns(ObjectBundle pack)
Find a mapping from package columns to database columns, eventually adding new database columns when needed.

Parameters:
pack - Package to process
Returns:
Column mapping

addNewRelation

private Relation<?> addNewRelation(SimpleTypeInformation<?> meta)
Add a new representation for the given meta.

Parameters:
meta - meta data
Returns:
new representation

delete

public MultipleObjectsBundle delete(DBIDs ids)
Removes the objects from the database (by calling doDelete(DBID) for each object) and indexes and fires a deletion event.

Specified by:
delete in interface UpdatableDatabase
Parameters:
ids - the ids of the object to be removed from the database
Returns:
the objects that have been removed

doDelete

private void doDelete(DBID id)
Removes the object with the specified id from this database.

Parameters:
id - id the id of the object to be removed

size

@Deprecated
public final int size()
Deprecated. 

Description copied from interface: Database
Returns the number of objects contained in this Database.

Specified by:
size in interface Database
Returns:
the number of objects in this Database

getDBIDs

@Deprecated
public StaticDBIDs getDBIDs()
Deprecated. 

Description copied from interface: Database
Returns a list comprising all IDs currently in use. The list returned shall not be linked to any actual list possibly hold in the database implementation.

Specified by:
getDBIDs in interface Database
Returns:
a list comprising all IDs currently in use

restoreID

private void restoreID(DBID id)
Makes the given id reusable for new insertion operations.

Parameters:
id - the id to become reusable

getLogger

protected Logging getLogger()
Specified by:
getLogger in class AbstractDatabase

Release 0.4.0 (2011-09-20_1324)