Package elki.database

Class 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
    • Field Detail

      • LOG

        private static final Logging LOG
        Our logger
      • 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 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(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 interface UpdatableDatabase
        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 calling doDelete(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 interface UpdatableDatabase
        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