|
|
|||||||||||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||||||||||
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.database.AbstractDatabase<O>
O - the type of DatabaseObject as element of the databasepublic abstract class AbstractDatabase<O extends DatabaseObject>
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.
| Field Summary | |
|---|---|
private AssociationMaps |
associations
Map to hold association maps. |
private Map<Integer,O> |
content
Map to hold the objects of the database. |
private int |
counter
Counter to provide a new Integer id. |
private Associations |
globalAssociations
Map to hold global associations. |
protected List<DatabaseListener> |
listenerList
Holds the listener of this database. |
private List<Integer> |
reusableIDs
Provides a list of reusable ids. |
| Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
|---|
debug, logger |
| Constructor Summary | |
|---|---|
protected |
AbstractDatabase()
Provides an abstract database including 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. |
| Method Summary | ||
|---|---|---|
void |
addDatabaseListener(DatabaseListener l)
Adds a listener for the DatabaseEvent posted after the
database changes. |
|
|
associate(AssociationID<T> associationID,
Integer objectID,
T association)
Associates a association in a certain relation to a certain Object. |
|
|
associateGlobally(AssociationID<T> associationID,
T association)
Associates a global association in a certain relation to the database. |
|
O |
delete(Integer id)
Removes and returns the object with the given id from the database. |
|
void |
delete(O object)
Removes all objects from the database that are equal to the given object. |
|
protected void |
deleteAssociations(Integer id)
Deletes associations for the given id if there are any. |
|
int |
dimensionality()
Returns the dimensionality of the data contained by this database in case of O extends FeatureVector. |
|
protected void |
fireObjectInserted(Integer objectID)
Notifies all listeners that have registered interest for notification on this event type. |
|
protected void |
fireObjectRemoved(Integer objectID)
Notifies all listeners that have registered interest for notification on this event type. |
|
protected void |
fireObjectsChanged(List<Integer> objectIDs)
Notifies all listeners that have registered interest for notification on this event type. |
|
protected void |
fireObjectsInserted(List<Integer> objectIDs)
Notifies all listeners that have registered interest for notification on this event type. |
|
protected void |
fireObjectsRemoved(List<Integer> objectIDs)
Notifies all listeners that have registered interest for notification on this event type. |
|
O |
get(Integer id)
Returns the DatabaseObject represented by the specified id. |
|
|
getAssociation(AssociationID<T> associationID,
Integer objectID)
Returns the association specified by the given associationID and related to the specified Object. |
|
Associations |
getAssociations(Integer id)
Returns all associations for a given ID. |
|
|
getGlobalAssociation(AssociationID<T> associationID)
Returns the global association specified by the given associationID. |
|
List<Integer> |
getIDs()
Returns a list of all ids currently in use in the database. |
|
String |
getName()
Get a user-understandable name for this result. |
|
protected List<O> |
getObjects(List<Pair<O,Associations>> objectAndAssociationsList)
Helper method to extract the list of database objects from the specified list of objects and their associations. |
|
protected abstract Collection<Pair<OptionID,Object>> |
getParameters()
|
|
void |
insert(List<Pair<O,Associations>> objectsAndAssociationsList)
Initializes the database by inserting the specified objects and their associations into the database. |
|
Integer |
insert(Pair<O,Associations> objectAndAssociations)
Inserts the given object into the database. |
|
boolean |
isSet(AssociationID<?> associationID)
Checks whether an association is set for at least one id in the database. |
|
boolean |
isSetForAllObjects(AssociationID<?> associationID)
Checks whether an association is set for every id in the database. |
|
boolean |
isSetGlobally(AssociationID<?> associationID)
Checks whether a global association is set in the database. |
|
Iterator<Integer> |
iterator()
Returns an iterator iterating over all keys of the database. |
|
Database<O> |
partition(List<Integer> ids)
Returns a partition of this database according to the specified Lists of IDs. |
|
Map<Integer,Database<O>> |
partition(Map<Integer,List<Integer>> partitions)
Returns a Map of partition IDs to Databases according to the specified Map of partition IDs to Lists of IDs. |
|
Map<Integer,Database<O>> |
partition(Map<Integer,List<Integer>> partitions,
Class<? extends Database<O>> dbClass,
Collection<Pair<OptionID,Object>> dbParameters)
Returns a Map of partition IDs to Databases of the specified class according to the specified Map of partition IDs to Lists of IDs. |
|
Set<Integer> |
randomSample(int k,
long seed)
Returns a random sample of k ids. |
|
void |
removeDatabaseListener(DatabaseListener l)
Removes a listener previously added with addTreeModelListener. |
|
protected void |
restoreID(Integer id)
Makes the given id reusable for new insertion operations. |
|
protected void |
setAssociations(Integer id,
Associations idAssociations)
Sets the specified association to the specified id. |
|
protected Integer |
setNewID(O object)
Provides a new id for the specified database object suitable as key for a new insertion and sets this id in the specified database object. |
|
int |
size()
Returns the number of objects contained in this Database. |
|
| Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
|---|
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning |
| 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 |
|---|
bulkKNNQueryForID, kNNQueryForID, kNNQueryForObject, rangeQuery, rangeQuery, reverseKNNQuery |
| Field Detail |
|---|
private final Associations globalAssociations
private final AssociationMaps associations
private int counter
private List<Integer> reusableIDs
private Map<Integer,O extends DatabaseObject> content
protected List<DatabaseListener> listenerList
| Constructor Detail |
|---|
protected AbstractDatabase()
deleteAssociations(id)).
| Method Detail |
|---|
public void insert(List<Pair<O,Associations>> objectsAndAssociationsList)
throws UnableToComplyException
Database
insert in interface Database<O extends DatabaseObject>objectsAndAssociationsList - the list of objects and their
associations to be inserted
UnableToComplyException - if initialization is not possible
public Integer insert(Pair<O,Associations> objectAndAssociations)
throws UnableToComplyException
Database
insert in interface Database<O extends DatabaseObject>objectAndAssociations - the object and its associations to be inserted
UnableToComplyException - if database reached limit of storage
capacitypublic void delete(O object)
Database
delete in interface Database<O extends DatabaseObject>object - the object to be removed from databasepublic O delete(Integer id)
Database
delete in interface Database<O extends DatabaseObject>id - the id of an object to be removed from the database
public final int size()
Database
size in interface Database<O extends DatabaseObject>public final O get(Integer id)
Database
get in interface Database<O extends DatabaseObject>id - the id of the Object to be obtained from the Database
public final Iterator<Integer> iterator()
iterator in interface Database<O extends DatabaseObject>iterator in interface Iterable<Integer>- for a Database {@code db}, this allows the
construct {@code for(Integer id : db) // work with database ids }.
public <T> void associate(AssociationID<T> associationID,
Integer objectID,
T association)
Database
associate in interface Database<O extends DatabaseObject>T - association data typeassociationID - the id of the association, respectively the name of
the relationobjectID - the id of the Object to which the association is relatedassociation - the association to be associated with the specified
Object
public <T> void associateGlobally(AssociationID<T> associationID,
T association)
throws ClassCastException
associateGlobally in interface Database<O extends DatabaseObject>T - association data typeassociationID - the id of the association, respectively the name of
the relationassociation - the association to be associated with the database
ClassCastException - if the association cannot be cast as the class
that is specified by the associationID
public <T> T getAssociation(AssociationID<T> associationID,
Integer objectID)
Database
getAssociation in interface Database<O extends DatabaseObject>T - association data typeassociationID - the id of the association, respectively the name of
the relationobjectID - the id of the Object to which the association is related
public <T> T getGlobalAssociation(AssociationID<T> associationID)
getGlobalAssociation in interface Database<O extends DatabaseObject>T - association data typeassociationID - the id of the association, respectively the name of
the relation
protected Integer setNewID(O object)
throws UnableToComplyException
object - the object for which a new id should be provided
UnableToComplyException - if the database has reached the limit and,
therefore, new insertions are not possibleprotected void restoreID(Integer id)
id - the id to become reusableprotected void deleteAssociations(Integer id)
id - id of which all associations are to be deletedpublic Associations getAssociations(Integer id)
getAssociations in interface Database<O extends DatabaseObject>id - the id for which the associations are to be returned
protected void setAssociations(Integer id,
Associations idAssociations)
id - the id which is to associate with specified associationsidAssociations - the associations to be associated with the specified
id
public Database<O> partition(List<Integer> ids)
throws UnableToComplyException
Database
partition in interface Database<O extends DatabaseObject>ids - a Lists of IDs defining a partition of the database
UnableToComplyException - in case of problems during insertion
public Map<Integer,Database<O>> partition(Map<Integer,List<Integer>> partitions)
throws UnableToComplyException
Databasepartition(partitions, null, null).
partition in interface Database<O extends DatabaseObject>partitions - a Map of partition IDs to Lists of IDs defining a
partition of the database
UnableToComplyException - in case of problems during insertion
public Map<Integer,Database<O>> partition(Map<Integer,List<Integer>> partitions,
Class<? extends Database<O>> dbClass,
Collection<Pair<OptionID,Object>> dbParameters)
throws UnableToComplyException
Database
partition in interface Database<O extends DatabaseObject>partitions - a Map of partition IDs to Lists of IDs defining a
partition of the databasedbClass - the class of the databases to be returned, if this argument
is null the returned databases have the same class as
this databasedbParameters - the parameter array of the returned database class,
only necessary if parameter dbClass is not null
UnableToComplyException - in case of problems during insertion or
class instantiationprotected abstract Collection<Pair<OptionID,Object>> getParameters()
public boolean isSetForAllObjects(AssociationID<?> associationID)
isSetForAllObjects in interface Database<O extends DatabaseObject>associationID - an association id to be checked
public boolean isSet(AssociationID<?> associationID)
isSet in interface Database<O extends DatabaseObject>associationID - an association id to be checked
public boolean isSetGlobally(AssociationID<?> associationID)
Database
isSetGlobally in interface Database<O extends DatabaseObject>associationID - an association id to be checked
public final Set<Integer> randomSample(int k,
long seed)
Database
randomSample in interface Database<O extends DatabaseObject>k - the number of ids to returnseed - for random generator
public List<Integer> getIDs()
getIDs in interface Database<O extends DatabaseObject>Database.getIDs()
public int dimensionality()
throws UnsupportedOperationException
DatabaseO extends FeatureVector.
dimensionality in interface Database<O extends DatabaseObject>UnsupportedOperationException - if O does not extend
FeatureVector or the
database is emptyprotected List<O> getObjects(List<Pair<O,Associations>> objectAndAssociationsList)
objectAndAssociationsList - the list of objects and their associations
public void addDatabaseListener(DatabaseListener l)
DatabaseEvent posted after the
database changes.
addDatabaseListener in interface Database<O extends DatabaseObject>l - the listener to addremoveDatabaseListener(de.lmu.ifi.dbs.elki.database.DatabaseListener)public void removeDatabaseListener(DatabaseListener l)
addTreeModelListener.
removeDatabaseListener in interface Database<O extends DatabaseObject>l - the listener to removeaddDatabaseListener(de.lmu.ifi.dbs.elki.database.DatabaseListener)protected void fireObjectsChanged(List<Integer> objectIDs)
objectIDs - the ids of the database objects that have been removedprotected void fireObjectsInserted(List<Integer> objectIDs)
objectIDs - the ids of the database objects that have been removedprotected void fireObjectInserted(Integer objectID)
objectID - the ids of the database object that has been removedprotected void fireObjectsRemoved(List<Integer> objectIDs)
objectIDs - the ids of the database objects that have been removedprotected void fireObjectRemoved(Integer objectID)
objectID - the id of the database object that has been removedpublic String getName()
Result
getName in interface Result
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||