Package elki.database
Class HashmapDatabase
- java.lang.Object
-
- elki.database.AbstractDatabase
-
- elki.database.HashmapDatabase
-
- All Implemented Interfaces:
Database
,UpdatableDatabase
@Description("Database using an in-memory hashtable and at least providing linear scans.") public class HashmapDatabase extends AbstractDatabase implements UpdatableDatabase
Database storing data using hashtable storage, and thus allowing additional and removal of objects.- Since:
- 0.1
- Author:
- Arthur Zimek, Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HashmapDatabase.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description protected DatabaseConnection
databaseConnection
The data source we get the initial data from.private DBIDView
idrep
The DBID representation we useprivate HashSetModifiableDBIDs
ids
IDs of this databaseprivate static Logging
LOG
Our logger-
Fields inherited from class elki.database.AbstractDatabase
eventManager, indexFactories, relations
-
-
Constructor Summary
Constructors Constructor Description HashmapDatabase()
Constructor with no indexes.HashmapDatabase(DatabaseConnection databaseConnection, java.util.Collection<? extends IndexFactory<?>> indexFactories)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.SingleObjectBundle
delete(DBIDRef id)
Removes the object from the database (by callingdoDelete(DBIDRef)
) and indexes and fires a deletion event.MultipleObjectsBundle
delete(DBIDs ids)
Removes the objects from the database (by callingdoDelete(DBIDRef)
for each object) and indexes and fires a deletion event.private void
doDelete(DBIDRef id)
Removes the object with the specified id from this database.protected Logging
getLogger()
Get the class logger.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.-
Methods inherited from class elki.database.AbstractDatabase
accumulateDataStoreEvents, addDataStoreListener, flushDataStoreEvents, getBundle, getLongName, getRelation, getRelations, getShortName, removeDataStoreListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.database.Database
accumulateDataStoreEvents, addDataStoreListener, flushDataStoreEvents, getBundle, getRelation, getRelations, removeDataStoreListener
-
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Our logger
-
ids
private HashSetModifiableDBIDs 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, java.util.Collection<? extends 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 interfaceDatabase
-
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 interfaceUpdatableDatabase
- 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 callingdoDelete(DBIDRef)
for each object) and indexes and fires a deletion event. Removes and returns the specified objects with the given ids from the database.- Specified by:
delete
in interfaceUpdatableDatabase
- Parameters:
ids
- the ids of the object to be removed from the database- Returns:
- the objects that have been removed
-
delete
public SingleObjectBundle delete(DBIDRef id)
Removes the object from the database (by callingdoDelete(DBIDRef)
) and indexes and fires a deletion event. Removes and returns the specified objects with the given ids from the database.- Specified by:
delete
in interfaceUpdatableDatabase
- Parameters:
id
- the id of the object to be removed from the database- Returns:
- the object that have been removed
-
doDelete
private void doDelete(DBIDRef id)
Removes the object with the specified id from this database.- Parameters:
id
- id the id of the object to be removed
-
getLogger
protected Logging getLogger()
Description copied from class:AbstractDatabase
Get the class logger.- Specified by:
getLogger
in classAbstractDatabase
- Returns:
- Class logger
-
-