Package elki.database.relation
Class MaterializedRelation<O>
- java.lang.Object
-
- elki.database.relation.MaterializedRelation<O>
-
- Type Parameters:
O- Data type
- All Implemented Interfaces:
ModifiableRelation<O>,Relation<O>
public class MaterializedRelation<O> extends java.lang.Object implements ModifiableRelation<O>
Represents a single representation. This is attached to a DBIDs object, which you are supposed to manage first. I.e. put the new DBID in, then invoke set(), remove the DBID, then delete().TODO: is this semantic sane?
- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private DataStore<O>contentMap to hold the objects of the database.private StaticDBIDsidsThe DBIDs this is supposed to be defined for.private java.lang.StringnameThe relation name.private SimpleTypeInformation<O>typeThe class of objects we store.
-
Constructor Summary
Constructors Constructor Description MaterializedRelation(SimpleTypeInformation<O> type, DBIDs ids)Constructor.MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids)Constructor.MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids, DataStore<O> content)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(DBIDRef id)Delete an objects values.Oget(DBIDRef id)Get the representation of an object.SimpleTypeInformation<O>getDataTypeInformation()Get the data type of this representationStaticDBIDsgetDBIDs()Get the IDs the query is defined for.java.lang.StringgetLongName()Get a long (human readable) name for the relation.voidinsert(DBIDRef id, O val)Set (or insert) an object representation.DBIDIteriterDBIDs()Get an iterator access to the DBIDs.intsize()Get the number of DBIDs.
-
-
-
Field Detail
-
type
private final SimpleTypeInformation<O> type
The class of objects we store.
-
ids
private final StaticDBIDs ids
The DBIDs this is supposed to be defined for. Note: we only keep an unmodifiable reference.
-
name
private java.lang.String name
The relation name.
-
-
Constructor Detail
-
MaterializedRelation
public MaterializedRelation(SimpleTypeInformation<O> type, DBIDs ids)
Constructor.- Parameters:
type- Type informationids- IDs
-
MaterializedRelation
public MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids)Constructor.- Parameters:
name- Nametype- Type informationids- IDs
-
MaterializedRelation
public MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids, DataStore<O> content)Constructor.- Parameters:
name- Nametype- Type informationids- IDscontent- Content
-
-
Method Detail
-
get
public O get(DBIDRef id)
Description copied from interface:RelationGet the representation of an object.
-
insert
public void insert(DBIDRef id, O val)
Description copied from interface:ModifiableRelationSet (or insert) an object representation.- Specified by:
insertin interfaceModifiableRelation<O>- Parameters:
id- Object IDval- Value
-
delete
public void delete(DBIDRef id)
Delete an objects values.- Specified by:
deletein interfaceModifiableRelation<O>- Parameters:
id- ID to delete
-
getDBIDs
public StaticDBIDs getDBIDs()
Description copied from interface:RelationGet the IDs the query is defined for.If possible, prefer
Relation.iterDBIDs().
-
iterDBIDs
public DBIDIter iterDBIDs()
Description copied from interface:RelationGet an iterator access to the DBIDs.To iterate over all IDs, use the following code fragment:
for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { relation.get(iter); // Get the current element }
-
size
public int size()
Description copied from interface:RelationGet the number of DBIDs.
-
getDataTypeInformation
public SimpleTypeInformation<O> getDataTypeInformation()
Description copied from interface:RelationGet the data type of this representation- Specified by:
getDataTypeInformationin interfaceRelation<O>- Returns:
- Data type
-
getLongName
public java.lang.String getLongName()
Description copied from interface:RelationGet a long (human readable) name for the relation.- Specified by:
getLongNamein interfaceRelation<O>- Returns:
- Relation name
-
-